YM
2024-04-30 f4c14c24cb6cf1ed1c09cab760f6b9c8381df557
src/pages/character/index.vue
@@ -369,10 +369,8 @@
                padding: [3, 8],
                borderRadius: 30,
                position: "middle", // 设置标签文本在线的中间位置上居中显示
                // bottom: -(FontSize+10),
                z: 10, // 设置标签的z轴高度,使其比连接线更高
                // offset: [0, 15] ,// 往下移动 10 像素
                distance: -(Distance + 1) // 将标签放置在连接线上
                // z: -1, // 设置标签的z轴高度,使其比连接线更高
                distance: -10 // 将标签放置在连接线上
              }
            });
          }
@@ -383,8 +381,6 @@
        return {
          name: node.name,
          id: node.id,
          x: Math.random() * 2000, // 设置随机x坐标位置
          y: Math.random() * 600, // 设置随机y坐标位置
          itemStyle: {
            color: "#eae0eb", // 可以根据索引设置不同的颜色
            borderWidth: BorderWidth,
@@ -392,20 +388,7 @@
          }
        };
      });
      // 设置颜色
      function getColorByIndex() {
        // 生成随机的 R、G、B 分量值,限制在更高的范围内
        var r = Math.floor(Math.random() * 106) + 150; // 150 到 255 之间的随机数
        var g = Math.floor(Math.random() * 106) + 150; // 150 到 255 之间的随机数
        var b = Math.floor(Math.random() * 106) + 150; // 150 到 255 之间的随机数
        // 将 R、G、B 分量值转换为十六进制,并确保每个分量值都是两位数
        var hexR = r.toString(16).padStart(2, "0"); // 使用 padStart 方法确保生成的十六进制数为两位
        var hexG = g.toString(16).padStart(2, "0");
        var hexB = b.toString(16).padStart(2, "0");
        // 拼接十六进制颜色值
        var color = "#" + hexR + hexG + hexB;
        return color;
      }
      var option;
      option = {
        title: {
@@ -434,7 +417,7 @@
        series: [
          {
            type: "graph",
            layout: "none",
            layout: "force",
            roam: true,
            symbolSize: SymbolSize, // 调整节点大小
            label: {
@@ -442,7 +425,7 @@
              color: "black", // 设置节点文字颜色为黑色
              fontSize: FontSize // 设置文字大小
            },
            edgeSymbol: ["circle"],
            edgeSymbol: ["circle", "arrow"],
            edgeSymbolSize: [4, 10],
            data: nodeData,
            links: links,
@@ -456,6 +439,12 @@
              lineStyle: {
                width: 10
              }
            },
            force: {
              initLayout: null,
              // gravity: 0
              repulsion: 800,
              edgeLength: 400
            }
          }
        ]
@@ -463,9 +452,10 @@
      // 将生成的连接线添加到echarts图表的option中
      option.series[0].links = links;
      // 设置点击事件监听
      myChart.off("click");
      myChart.on("click", (params) => {
        // menuNav2 = !menuNav1
        if (params.componentType === "series") {
        console.log(params);
        if (params.dataType === "node") {
          this.spaceTimeArr(params.data.id);
        }
      });