127Echarts - 关系图(Graph Life Expectancy)

简介: 127Echarts - 关系图(Graph Life Expectancy)
效果图

源代码
option = {
    grid: {
        left: 0,
        bottom: 0,
        containLabel: true,
        top: 80
    },
    xAxis: {
        type: 'value'
    },
    yAxis: {
        type: 'value',
        scale: true
    },
    toolbox: {
        feature: {
            dataZoom: {}
        }
    },
    dataZoom: {
        type: 'inside'
    },
    series: []
};
$.get('data/asset/data/life-expectancy.json', function (data) {
    var series = data.series;
    option.visualMap = {
        show: false,
        min: 0,
        max: 100,
        dimension: 1
    };
    option.legend = {
        data: data.counties,
        selectedMode: 'single',
        right: 100
    };
    data.counties.forEach(function (country) {
        var data = series.map(function (yearData) {
            var item = yearData.filter(function (item) {
                return item[3] === country;
            })[0];
            return {
                label: {
                    normal: {
                        show: item[4] % 20 === 0 && item[4] > 1940
                    },
                    emphasis: {
                        position: 'top',
                        show: true
                    }
                },
                name: item[4],
                value: item
            };
        });
        var links = data.map(function (item, idx) {
            return {
                source: idx,
                target: idx + 1
            };
        });
        links.pop();
        option.series.push({
            name: country,
            type: 'graph',
            coordinateSystem: 'cartesian2d',
            data: data,
            links: links,
            edgeSymbol: ['none', 'arrow'],
            edgeSymbolSize: 5,
            legendHoverLink: false,
            lineStyle: {
                normal: {
                    color: '#333'
                }
            },
            itemStyle: {
                normal: {
                    borderWidth: 1,
                    borderColor: '#333'
                }
            },
            label: {
                normal: {
                    textStyle: {
                        color: '#333'
                    },
                    position: 'right'
                }
            },
            symbolSize: 10,
            animationDelay: function (idx) {
                return idx * 100;
            }
        });
    });
    myChart.setOption(option);
});
life-expectancy.json
{"countries":[[133,-27,"Australia"],[-100,54,"Canada"],[105,35,"China"],[-80,21.5,"Cuba"],[26,62,"Fi
目录
相关文章
|
11月前
130Echarts - 关系图(Graph Webkit Dep)
130Echarts - 关系图(Graph Webkit Dep)
39 0
|
6月前
|
JavaScript
echarts_自定义graph关系图
echarts_自定义graph关系图
111 0
131Echarts - 关系图(Calendar Graph)
131Echarts - 关系图(Calendar Graph)
43 0
|
11月前
|
JSON 数据格式
echarts关系图
echarts关系图
73 0
269Echarts - GL 关系图(1w 节点 2w7 边的NPM 依赖图)
269Echarts - GL 关系图(1w 节点 2w7 边的NPM 依赖图)
88 0
268Echarts - GL 关系图(GraphGL - Large Internet)
268Echarts - GL 关系图(GraphGL - Large Internet)
115 0
|
异构计算
267Echarts - GL 关系图(GraphGL GPU Layout)
267Echarts - GL 关系图(GraphGL GPU Layout)
85 0
182Echarts - 日历坐标系(Calendar Graph)
182Echarts - 日历坐标系(Calendar Graph)
33 0
129Echarts - 关系图(Simple Graph)
129Echarts - 关系图(Simple Graph)
47 0
128Echarts - 关系图(NPM Dependencies)
128Echarts - 关系图(NPM Dependencies)
71 0

热门文章

最新文章

下一篇
无影云桌面