import CompanyImg from "../symbol.png"

const getGraph = () => {
  const nodes = [
    '宁德时代', '泰丰先行', '国轩高科', '晶科能源', '容百科技',
    '江西紫宸', '比亚迪', '长盈精密', '昆仑化学',
    '海辰储能', '华阳集团', '嘉源科技', '天合光能',
    '铜陵有色', '紫江企业', '格林美', '德方纳米'
  ];

  return {
    series: [{
      type: 'graph',
      layout: 'force',
      symbolSize: 60,
      roam: true,
      label: {
        show: true,
        position: 'bottom',
        color: '#333',
        fontWeight: 'bold'
      },
      edgeSymbol: ['arrow', 'none'],
      edgeSymbolSize: [8, 4],
      force: {
        repulsion: 800,
        gravity: 0.1,
        edgeLength: 240
      },
      data: nodes.map((name, idx) => ({
        name,
        draggable: true,
        symbol: `image://${CompanyImg}`,
        itemStyle: { 
          color: '#fff', // 设置圆形背景色
          borderColor: 'rgb(59, 65, 75)', // 可选：圆形边框色
          borderWidth: 3 // 可选：圆形边框宽度
        },
        symbolKeepAspect: true, // 保持图片比例
        symbolSize: 60,
        symbolClip: true, // 裁剪为圆形
        label: {
          show: true,
          position: 'bottom',
          color: '#333',
          fontWeight: 'bold'
        }
      })),
      links: [
        { source: 0, target: 1, label: { show: true, formatter: '合作' } },
        { source: 0, target: 2, label: { show: true, formatter: '持股' } },
        { source: 0, target: 3, label: { show: true, formatter: '合作' } },
        { source: 0, target: 4, lineStyle: { type: 'dashed', color: '#d32f2f' }, label: { show: true, formatter: '从属' } },
        { source: 0, target: 5, label: { show: true, formatter: '合作' } },
        { source: 0, target: 6, label: { show: true, formatter: '持股' } },
        { source: 0, target: 7, label: { show: true, formatter: '合作' } },
        { source: 0, target: 8, label: { show: true, formatter: '合作' } },
        { source: 0, target: 9, lineStyle: { type: 'dashed', color: '#d32f2f' }, label: { show: true, formatter: '从属' } },
        { source: 0, target: 10, lineStyle: { type: 'dashed', color: '#d32f2f' }, label: { show: true, formatter: '合作' } },
        { source: 0, target: 11, label: { show: true, formatter: '合作' } },
        { source: 0, target: 12, label: { show: true, formatter: '合作' } },
        { source: 0, target: 13, label: { show: true, formatter: '合作' } },
        { source: 0, target: 14, label: { show: true, formatter: '合作' } },
        { source: 0, target: 15, label: { show: true, formatter: '合作' } },
        { source: 0, target: 16, label: { show: true, formatter: '合作' } }
      ],
      edgeLabel: {
        show: true,
        position: 'middle',
        fontSize: 14,
        color: '#666',
        backgroundColor: 'rgba(255,255,255,0.9)',
        borderColor: '#bbb',
        borderWidth: 1,
        borderRadius: 8,
        padding: [4, 8],
        formatter: params => params.data.label ? params.data.label.formatter : ''
      }
    }]
  }
}

export default getGraph