首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将JSON文件转换为GEXF文件

将JSON文件转换为GEXF文件
EN

Stack Overflow用户
提问于 2020-07-09 10:36:50
回答 1查看 844关注 0票数 0

是否存在将JSON文件转换为GEXF文件的问题?

我目前正在使用这个echarts循环布局图(https://echarts.apache.org/examples/en/editor.html?c=graph-circular-layout)。

但是,必须将JSON文件转换为GEXF文件格式,才能在图形中使用它。

注意:我的代码在Javascript中。

谢谢!

更新为代码

下面是使用圆形布局图的示例代码。它从gexf文件中获取数据。但是,图的输入数据在JSON文件中。

代码语言:javascript
运行
复制
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循环布局图中填充的文件。

EN

回答 1

Stack Overflow用户

发布于 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图。我不确定这是否正是您需要的格式,但可能是一个起点。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62812963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档