您当前的位置: 首页 >  ar

145Echarts - 矩形树图(Show Parent Labels)

杨林伟 发布时间:2019-05-05 14:28:09 ,浏览量:2

效果图

在这里插入图片描述

源代码
myChart.showLoading();

$.get('data/asset/data/disk.tree.json', function (diskData) {
    myChart.hideLoading();

    function colorMappingChange(value) {
        var levelOption = getLevelOption(value);
        chart.setOption({
            series: [{
                levels: levelOption
            }]
        });
    }

    var formatUtil = echarts.format;

    function getLevelOption() {
        return [
            {
                itemStyle: {
                    normal: {
                        borderColor: '#777',
                        borderWidth: 0,
                        gapWidth: 1
                    }
                },
                upperLabel: {
                    normal: {
                        show: false
                    }
                }
            },
            {
                itemStyle: {
                    normal: {
                        borderColor: '#555',
                        borderWidth: 5,
                        gapWidth: 1
                    },
                    emphasis: {
                        borderColor: '#ddd'
                    }
                }
            },
            {
                colorSaturation: [0.35, 0.5],
                itemStyle: {
                    normal: {
                        borderWidth: 5,
                        gapWidth: 1,
                        borderColorSaturation: 0.6
                    }
                }
            }
        ];
    }

    myChart.setOption(option = {

        title: {
            text: 'Disk Usage',
            left: 'center'
        },

        tooltip: {
            formatter: function (info) {
                var value = info.value;
                var treePathInfo = info.treePathInfo;
                var treePath = [];

                for (var i = 1; i < treePathInfo.length; i++) {
                    treePath.push(treePathInfo[i].name);
                }

                return [
                    '
' + formatUtil.encodeHTML(treePath.join('/')) + '
', 'Disk Usage: ' + formatUtil.addCommas(value) + ' KB', ].join(''); } }, series: [ { name:'Disk Usage', type:'treemap', visibleMin: 300, label: { show: true, formatter: '{b}' }, upperLabel: { normal: { show: true, height: 30 } }, itemStyle: { normal: { borderColor: '#fff' } }, levels: getLevelOption(), data: diskData } ] }); });
关注
打赏
1688896170
查看更多评论

杨林伟

暂无认证

  • 2浏览

    0关注

    3183博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.3308s