是否存在将JSON文件转换为GEXF文件的问题?
我目前正在使用这个echarts循环布局图(https://echarts.apache.org/examples/en/editor.html?c=graph-circular-layout)。
但是,必须将JSON文件转换为GEXF文件格式,才能在图形中使用它。
注意:我的代码在Javascript中。
谢谢!
更新为代码
下面是使用圆形布局图的示例代码。它从gexf文件中获取数据。但是,图的输入数据在JSON文件中。
myChart.showLoading();
$.get(ROOT_PATH + '/data/asset/data/les-miserables.gexf', 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.value = node.symbolSize;
    node.symbolSize /= 1.5;
    node.label = {
        normal: {
            show: node.symbolSize > 10
        }
    };
    node.category = node.attributes.modularity_class;
});
option = {
    title: {
        text: 'Les Miserables',
        subtext: 'Circular layout',
        top: 'bottom',
        left: 'right'
    },
    tooltip: {},
    legend: [{
        data: categories.map(function (a) {
            return a.name;
        })
    }],
    animationDurationUpdate: 1500,
    animationEasingUpdate: 'quinticInOut',
    series: [
        {
            name: 'Les Miserables',
            type: 'graph',
            layout: 'circular',
            circular: {
                rotateLabel: true
            },
            data: graph.nodes,
            links: graph.links,
            categories: categories,
            roam: true,
            label: {
                position: 'right',
                formatter: '{b}'
            },
            lineStyle: {
                color: 'source',
                curveness: 0.3
            }
        }
    ]
};
myChart.setOption(option);
}, 'xml');Github示例代码
这个图形的github有JSON文件(代码)的源代码,它用于填充图https://github.com/hecore/echart_demo/blob/master/data/hecore.json ( ->
我不知道这些代码是如何转换成这个https://github.com/hecore/echart_demo/blob/master/data/les-miserables.json的
最后,这是他们用https://github.com/hecore/echart_demo/blob/master/data/les-miserables.gexf格式的echarts循环布局图中填充的文件。
发布于 2020-09-03 01:11:40
您可以安装伤寒(https://gephi.org/users/install/),然后再安装用于伤寒(https://gephi.org/plugins/#/plugin/jsonexporter-plugin)的(https://gephi.org/plugins/#/plugin/jsonexporter-plugin)。然后在地理信息库中打开gexf文件,然后转到file>export>graph file>json图。我不确定这是否正是您需要的格式,但可能是一个起点。
https://stackoverflow.com/questions/62812963
复制相似问题