var categories = []; for (var i = 0; i < 9; i++) { categories[i] = { name: '类目' + i }; } var graph = { nodes: null, links: null }; graph.nodes = [{ name: '1', draggable: true, value: 10, attributes: { modularity_class: 0 }, category: 0 }, { name: '2', value: 20, draggable: true, symbolSize: 10, tooltip: { formatter: '{b}' }, attributes: { modularity_class: 0 }, category: 0 }, { name: '3', attributes: { modularity_class: 2 }, itemStyle: { normal: { color: 'yellowgreen', } }, category: 0, value: 10 }, { name: '4', attributes: { modularity_class: 0 }, category: 2, value: 10 }, { name: '5', attributes: { modularity_class: 0 }, category: 2, value: 10 }]; graph.links = [{ source: '1', target: '2' }, { source: '3', target: '2' }, { source: '4', target: '3' }, { source: '5', target: '3' }]; option = { cursor: 'pointer', title: { text: '000', subtext: '0.0', left: 'center' }, series: { name: 'Les Miserables', type: 'graph', layout: 'force', data: graph.nodes, links: graph.links, categories: categories, roam: true, force: { repulsion: 100, gravity: 0.4, edgeLength: 20, }, symbolSize: 5, edgeSymbol: ['', 'arrow'], edgeSymbolSize: 3, lineStyle: { normal: { color: 'target', width: 1, type: 'solid' } }, } }; myChart.on('click', function (params) { alert(params); myChart.showLoading() setTimeout(function () { myChart.setOption(option); myChart.hideLoading() }, 1000) });