const getGraphChart = (graphData) => {
  const option = {
    title: { text: "", left: "center" },
    tooltip: {},
    // legend: {
    // 	data: graphData.categories.map(item => item.name),
    // 	left: "left"
    // },
    series: [
      {
        type: "graph",
        layout: "force", // 力导向布局
        force: {
          repulsion: 500, // 节点排斥力
          edgeLength: [30, 80] // 边长度范围
        },
        data: graphData.nodes,
        links: graphData.links,
        categories: graphData.categories,
        roam: true, // 支持缩放、平移
        label: {
          show: true,
          fontSize: 14,
          position: "bottom",
          formatter: function (params) {
            // 根据条件返回不同样式的文本
            if (params.data.category === 0) {
              return `{a|${params.name}}`; // 使用富文本样式
            } else if (params.data.category === 1) {
              return `{b|${params.name}}`;
            } else {
              return params.name; // 默认样式
            }
          },
          rich: {
            a: {
              // 重要节点的样式
              color: "#000",
              fontSize: 14,
              padding: [2, 4],
              borderRadius: 2
            },
            b: {
              // 普通节点的样式
              color: "rgba(5, 95, 194, 1)",
              fontSize: 14,
              fontWeight: "bold",
            }
          }
        },
        edgeSymbol: ["arrow", "none"], // 边的箭头
        edgeSymbolSize: [8, 50],
        itemStyle: {
          color: "rgba(5, 95, 194, 1)"
          // borderColor: "red",
          // borderWidth: 1
        },
        lineStyle: {
          color: "rgba(174, 214, 255, 1)",
          width: 2,
          opacity: 0.5
        },
        emphasis: {
          focus: "adjacency",
          lineStyle: {
            width: 2
          }
        }
      }
    ]
  };

  return option
}

export default getGraphChart