

const getGraphChart = (nodes, links) => {

  const option = {
    // title: {
    //   text: '企业关系网络',
    //   subtext: '节点图标表示企业，箭头表示关联方向',
    //   top: 'top',
    //   left: 'center',
    //   textStyle: {
    //     fontSize: 20,
    //     color: '#2c3e50'
    //   }
    // },
    // tooltip: {
    //   formatter: function (params) {
    //     if (params.dataType === 'node') {
    //       return `<div style="font-weight:bold;margin-bottom:5px">${params.data.name}</div>
    //                       <div>类别: ${categories[params.data.category].name}</div>
    //                       <div>关联度: ${params.data.value}</div>`;
    //     } else {
    //       return `<div>${nodes[params.data.source].name} → ${nodes[params.data.target].name}</div>
    //                       <div>关联强度: ${params.data.value}</div>`;
    //     }
    //   }
    // },
    legend: {
      // data: categories.map(c => c.name),
      show: false,
      top: 40,
      textStyle: {
        fontSize: 12
      }
    },
    animation: true,
    animationDuration: 1000,
    animationEasing: 'cubicOut',
    series: [{
      type: 'graph',
      itemStyle: {
        color: '#73C0DE'
      },
      layout: 'force',
      data: nodes,
      links: links,
      // categories: categories,
      roam: true,
      label: {
        show: true,
        position: 'bottom',
        formatter: '{b}',
        fontSize: 12,
        fontWeight: 'bold',
        // backgroundColor: 'rgba(255,255,255,0.8)',
        padding: [4, 6],
        borderRadius: 4
      },
      lineStyle: {
        color: 'source',
        curveness: 0,
        width: 2,
        type: 'dashed',
        color: '#AED6FF'
      },
      edgeSymbol: ['none', 'arrow'],
      edgeSymbolSize: [0, 10],
      emphasis: {
        focus: 'adjacency',
        lineStyle: {
          width: 4
        },
        label: {
          show: true,
          fontSize: 14
        }
      },
      force: {
        repulsion: 300,
        gravity: 0,
        edgeLength: 240
      }
    }],
    // color: ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de']
  };

  return option

}

export default getGraphChart