Graph 力引导布局
配置项如下
var uploadedDataURL = "/asset/get/s/data-1461736688440-B1OeSA6x.gexf";
myChart.showLoading();
$.get(uploadedDataURL, function (xml) {
myChart.hideLoading();
var graph = echarts.dataTool.gexf.parse(xml);
var categories = [];
for (var i = 0; i < 9; i++) {
categories[i] = {
name: '类目' + i
};
}
graph.nodes.forEach(function (node) {
node.itemStyle = null;
node.symbolSize = 10;
node.value = node.symbolSize;
node.category = node.attributes.modularity_class;
// Use random x, y
node.x = node.y = null;
node.draggable = true;
});
option = {
title: {
text: 'Les Miserables',
subtext: 'Default layout',
top: 'bottom',
left: 'right'
},
tooltip: {},
legend: [{
// selectedMode: 'single',
data: categories.map(function (a) {
return a.name;
})
}],
animation: false,
series : [
{
name: 'Les Miserables',
type: 'graph',
layout: 'force',
data: graph.nodes,
links: graph.links,
categories: categories,
roam: true,
label: {
normal: {
position: 'right'
}
},
force: {
repulsion: 100
}
}
]
};
myChart.setOption(option);
}, 'xml');