143Echarts - 矩形树图(ECharts Option Query)

简介: 143Echarts - 矩形树图(ECharts Option Query)
效果图

源代码
var uploadedDataURL = "data/asset/data/ec-option-doc-statistics-201604.json";
myChart.showLoading();
$.getJSON(uploadedDataURL, function (rawData) {
    myChart.hideLoading();
    function convert(source, target, basePath) {
        for (var key in source) {
            var path = basePath ? (basePath + '.' + key) : key;
            if (key.match(/^\$/)) {
            }
            else {
                target.children = target.children || [];
                var child = {
                    name: path
                };
                target.children.push(child);
                convert(source[key], child, path);
            }
        }
        if (!target.children) {
            target.value = source.$count || 1;
        }
        else {
            target.children.push({
                name: basePath,
                value: source.$count
            });
        }
    }
    var data = [];
    convert(rawData, data, '');
    myChart.setOption(option = {
        title: {
            text: 'ECharts 配置项查询分布',
            subtext: '2016/04',
            left: 'leafDepth'
        },
        tooltip: {},
        series: [{
            name: 'option',
            type: 'treemap',
            visibleMin: 300,
            data: data.children,
            leafDepth: 2,
            levels: [
                {
                    itemStyle: {
                        normal: {
                            borderColor: '#555',
                            borderWidth: 4,
                            gapWidth: 4
                        }
                    }
                },
                {
                    colorSaturation: [0.3, 0.6],
                    itemStyle: {
                        normal: {
                            borderColorSaturation: 0.7,
                            gapWidth: 2,
                            borderWidth: 2
                        }
                    }
                },
                {
                    colorSaturation: [0.3, 0.5],
                    itemStyle: {
                        normal: {
                            borderColorSaturation: 0.6,
                            gapWidth: 1
                        }
                    }
                },
                {
                    colorSaturation: [0.3, 0.5]
                }
            ]
        }]
    })
});
目录
相关文章
|
5天前
|
存储 JavaScript 数据可视化
vue3+echarts应用——深度遍历html的dom结构并用树图进行可视化
vue3+echarts应用——深度遍历html的dom结构并用树图进行可视化
44 1
|
7月前
147Echarts - 矩形树图(Gradient Mapping)
147Echarts - 矩形树图(Gradient Mapping)
32 0
|
7月前
146Echarts - 矩形树图(Basic Treemap)
146Echarts - 矩形树图(Basic Treemap)
54 0
|
7月前
145Echarts - 矩形树图(Show Parent Labels)
145Echarts - 矩形树图(Show Parent Labels)
29 0
|
7月前
144Echarts - 矩形树图(How $3.7 Trillion is Spent)
144Echarts - 矩形树图(How $3.7 Trillion is Spent)
25 0
|
5月前
142Echarts - 矩形树图(Disk Usage)
142Echarts - 矩形树图(Disk Usage)
21 0
|
7月前
141Echarts - 树图(From Top to Bottom Tree)
141Echarts - 树图(From Top to Bottom Tree)
22 0
|
7月前
140Echarts - 树图(Radial Tree)
140Echarts - 树图(Radial Tree)
13 0
|
7月前
139Echarts - 树图(From Right to Left Tree)
139Echarts - 树图(From Right to Left Tree)
17 0
|
7月前
138Echarts - 树图(From Bottom to Top Tree)
138Echarts - 树图(From Bottom to Top Tree)
22 0