首页 > 其他分享 >矩形树图

矩形树图

时间:2024-02-19 11:34:39浏览次数:27  
标签:name bundle 树图 Accounts value var path 矩形

案例1

<!--
	此示例下载自 https://echarts.apache.org/examples/zh/editor.html?c=treemap-simple
-->
<!DOCTYPE html>
<html lang="en" style="height: 100%">
<head>
  <meta charset="utf-8">
</head>
<body style="height: 100%; margin: 0">
  <div id="container" style="width: 400px;height: 350px"></div>
  
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/5.5.0/files/dist/echarts.min.js"></script>
  <!-- Uncomment this line if you want to dataTool extension
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/5.5.0/files/dist/extension/dataTool.min.js"></script>
  -->
  <!-- Uncomment this line if you want to use gl extension
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts-gl/2/files/dist/echarts-gl.min.js"></script>
  -->
  <!-- Uncomment this line if you want to echarts-stat extension
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts-stat/latest/files/dist/ecStat.min.js"></script>
  -->
  <!-- Uncomment this line if you want to use map
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/4.9.0/files/map/js/china.js"></script>
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/4.9.0/files/map/js/world.js"></script>
  -->
  <!-- Uncomment these two lines if you want to use bmap extension
  <script type="text/javascript" src="https://api.map.baidu.com/api?v=3.0&ak=YOUR_API_KEY"></script>
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/5.5.0/files/dist/extension/bmap.min.js"></script>
  -->

  <script type="text/javascript">
    var dom = document.getElementById('container');
    var myChart = echarts.init(dom, null, {
      renderer: 'canvas',
      useDirtyRect: false
    });
    var app = {};
    
    var option;

    option = {
  series: [
    {
      type: 'treemap',
      data: [
        {
          name: 'nodeA',
          value: 10,
          children: [
            {
              name: 'nodeAa',
              value: 4
            },
            {
              name: 'nodeAb',
              value: 6
            }
          ]
        },
        {
          name: 'nodeB',
          value: 20,
          children: [
            {
              name: 'nodeBa',
              value: 20,
              children: [
                {
                  name: 'nodeBa1',
                  value: 20
                }
              ]
            }
          ]
        }
      ]
    }
  ]
};

    if (option && typeof option === 'object') {
      myChart.setOption(option);
    }

    window.addEventListener('resize', myChart.resize);
  </script>
</body>
</html>
  • 效果图

案例2

点击查看代码
  • disk.tree.json
[
    {
        "value": 40,
        "name": "Accessibility",
        "path": "Accessibility"
    },
    {
        "value": 180,
        "name": "Accounts",
        "path": "Accounts",
        "children": [
            {
                "value": 76,
                "name": "Access",
                "path": "Accounts/Access",
                "children": [
                    {
                        "value": 12,
                        "name": "DefaultAccessPlugin.bundle",
                        "path": "Accounts/Access/DefaultAccessPlugin.bundle"
                    },
                    {
                        "value": 28,
                        "name": "FacebookAccessPlugin.bundle",
                        "path": "Accounts/Access/FacebookAccessPlugin.bundle"
                    },
                    {
                        "value": 20,
                        "name": "LinkedInAccessPlugin.bundle",
                        "path": "Accounts/Access/LinkedInAccessPlugin.bundle"
                    },
                    {
                        "value": 16,
                        "name": "TencentWeiboAccessPlugin.bundle",
                        "path": "Accounts/Access/TencentWeiboAccessPlugin.bundle"
                    }
                ]
            },
            {
                "value": 92,
                "name": "Authentication",
                "path": "Accounts/Authentication",
                "children": [
                    {
                        "value": 24,
                        "name": "FacebookAuthenticationPlugin.bundle",
                        "path": "Accounts/Authentication/FacebookAuthenticationPlugin.bundle"
                    },
                    {
                        "value": 16,
                        "name": "LinkedInAuthenticationPlugin.bundle",
                        "path": "Accounts/Authentication/LinkedInAuthenticationPlugin.bundle"
                    },
                    {
                        "value": 20,
                        "name": "TencentWeiboAuthenticationPlugin.bundle",
                        "path": "Accounts/Authentication/TencentWeiboAuthenticationPlugin.bundle"
                    },
                    {
                        "value": 16,
                        "name": "TwitterAuthenticationPlugin.bundle",
                        "path": "Accounts/Authentication/TwitterAuthenticationPlugin.bundle"
                    },
                    {
                        "value": 16,
                        "name": "WeiboAuthenticationPlugin.bundle",
                        "path": "Accounts/Authentication/WeiboAuthenticationPlugin.bundle"
                    }
                ]
            },
            {
                "value": 12,
                "name": "Notification",
                "path": "Accounts/Notification",
                "children": [
                    {
                        "value": 12,
                        "name": "SPAAccountsNotificationPlugin.bundle",
                        "path": "Accounts/Notification/SPAAccountsNotificationPlugin.bundle"
                    }
                ]
            }
        ]
    }
]
  • 代码如下
<!--
	此示例下载自 https://echarts.apache.org/examples/zh/editor.html?c=treemap-disk
-->
<!DOCTYPE html>
<html lang="en" style="height: 100%">
<head>
  <meta charset="utf-8">
</head>
<body style="height: 100%; margin: 0">
  <div id="container" style="height: 100%"></div>

  <script type="text/javascript" src="https://cdn.staticfile.org/jquery/3.7.1/jquery.min.js"></script>
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/5.5.0/files/dist/echarts.min.js"></script>
  <!-- Uncomment this line if you want to dataTool extension
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/5.5.0/files/dist/extension/dataTool.min.js"></script>
  -->
  <!-- Uncomment this line if you want to use gl extension
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts-gl/2/files/dist/echarts-gl.min.js"></script>
  -->
  <!-- Uncomment this line if you want to echarts-stat extension
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts-stat/latest/files/dist/ecStat.min.js"></script>
  -->
  <!-- Uncomment this line if you want to use map
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/4.9.0/files/map/js/china.js"></script>
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/4.9.0/files/map/js/world.js"></script>
  -->
  <!-- Uncomment these two lines if you want to use bmap extension
  <script type="text/javascript" src="https://api.map.baidu.com/api?v=3.0&ak=YOUR_API_KEY"></script>
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/5.5.0/files/dist/extension/bmap.min.js"></script>
  -->

  <script type="text/javascript">
    var dom = document.getElementById('container');
    var myChart = echarts.init(dom, null, {
      renderer: 'canvas',
      useDirtyRect: false
    });
    var app = {};
    // var ROOT_PATH = 'https://echarts.apache.org/examples';
    var option;
    
    // myChart.showLoading();
// $.get(ROOT_PATH + '/data/asset/data/disk.tree.json', function (diskData) {
$.get('./disk.tree.json', function (diskData) {
  // myChart.hideLoading();
  const formatUtil = echarts.format;
  function getLevelOption() {
    return [
      {
        itemStyle: {
          borderWidth: 0,
          gapWidth: 5
        }
      },
      {
        itemStyle: {
          gapWidth: 1
        }
      },
      {
        colorSaturation: [0.35, 0.5],
        itemStyle: {
          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 [
            '<div class="tooltip-title">' +
              formatUtil.encodeHTML(treePath.join('/')) +
              '</div>',
            'Disk Usage: ' + formatUtil.addCommas(value) + ' KB'
          ].join('');
        }
      },
      series: [
        {
          name: 'Disk Usage',
          type: 'treemap',
          visibleMin: 300,
          label: {
            show: true,
            formatter: '{b}'
          },
          itemStyle: {
            borderColor: '#fff'
          },
          levels: getLevelOption(),
          data: diskData
        }
      ]
    })
  );
});

    if (option && typeof option === 'object') {
      myChart.setOption(option);
    }

    window.addEventListener('resize', myChart.resize);
  </script>
</body>
</html>
  • 效果图

标签:name,bundle,树图,Accounts,value,var,path,矩形
From: https://www.cnblogs.com/dogleftover/p/18020724

相关文章

  • leetcode85. 最大矩形
    85.最大矩形-力扣(LeetCode)参考dp求最大字串和的思想,将一维dp转化为二维的形式,将当前列的和当成一维的数进行dp即可。这题和求最大子矩阵和的dp思路一样。1classSolution{2public:3intmaximalRectangle(vector<vector<char>>&matrix){4intn=m......
  • 用MATLAB创建一个矩阵,包含颗粒的ID,type,直径,密度,坐标等信息,并填充一个矩形的空间
    LIGGGHTS可以read_data命令通过读取.txt文件中的颗粒信息。.txt的内容参考链接:liggghts通过.txt文件导入颗粒信息。下面的MATLAB代码可以根据需要生成一系列的颗粒信息,包括颗粒的ID,type,diameter,density,coordinate等。颗粒数量为8000,并且能够填充一个范围在(x_min,y_min,z_min)到(......
  • 【C++】OpenCV4-线条、矩形、圆形、椭圆等图形的绘制与填充、RNG随机函数的使用
    图形的绘制与填充://图形的绘制与填充Matcanvas=Mat::zeros(Size(512,512),CV_8UC3);namedWindow("canvas",WINDOW_AUTOSIZE);//相关绘制API演示//绘制直线line(canvas,Point(10,10),Point(400,400),Scalar(255,0,0),1,LINE_8);//绘制矩形Rectrect(150,1......
  • 如何在ECharts中使用矩形树图展示数据层级结构
    Laravel是一个流行的PHP框架,它具有出色的可测试性,可以帮助开发人员在更短的时间内编写可靠的代码。但是,即使使用了这个框架,也可能会出现测试覆盖率较低的情况。测试覆盖率是指代码中已由测试案例覆盖的部分比例。测试覆盖率越高,代码质量越高。在本文中,我们将分享几种技巧,帮助您提......
  • 【教3妹学编程-算法题】对角线最长的矩形的面积
    3妹:好冷啊,冻得瑟瑟发抖啦2哥 :这才哪跟哪,上海这几天温度算是高的啦。你看看哈尔滨,那才是冰城。3妹:据说沈阳千名“搓澡大姨”支援哈尔滨?哈哈哈哈2哥 :就像今年的淄博烧烤,可能有炒作的成分3妹:不不,是去年的了,今年已经24年啦。2哥,你说哈尔滨的面积是多少,这么多人涌入哈尔滨,能住的......
  • [LeetCode Hot 100] LeetCode84. 柱状图中最大的矩形
    题目描述思路:枚举+优化(单调栈)先固定矩阵的高。然后向左向右找到第一个比当前元素值小的元素,确定好左右边界。对于元素2来说:向左找到第一个比当前元素值小的元素:1的右边界向右找到第一个比当前元素值小的元素:3的右边界枚举每个元素的上边界,确定往左数最远到达哪个边界......
  • [Halcon&拟合] 直线、矩形和圆的边缘提取
    作者:丶布布一、测量矩形拟合提取直线边缘1、封装的函数介绍:将整个算法进行封装,得到函数MS_LineDetecter。MS_LineDetecter(ImageIn:outDetectRectangle:iLineRow1,iLineCol1,iLineRow2,iLineCol2,iRectWidth,iRectHeight,iSigma,iThreshold:oLineRow1,oLineCol......
  • [贴装专题] 基于halcon的拟合矩形边缘验证贴装精度
    作者:丶布布......
  • Qt/C++音视频开发60-坐标拾取/按下鼠标获取矩形区域/转换到视频源真实坐标
    一、前言通过在通道画面上拾取鼠标按下的坐标,然后鼠标移动,直到松开,根据松开的坐标和按下的坐标,绘制一个矩形区域,作为热点或者需要电子放大的区域,拿到这个坐标区域,用途非常多,可以直接将区域中的画面放大,也可以将该圈起来的区域位置发给设备,由设备设定对应的热点区域作为集中观察点......
  • SixLabors.ImageSharp 圆角矩形路径代码
    原因因微软抛弃了System.Drawing.Common决定重写绘图底层,在学习绘制时常会用到部分绘图引擎,参考过几个都有缺陷例如:1.SkiaSharp字体布局问题参考布局问题2.opencvsharp不支持中文文字于是乎我就用到了imageSharp,其中看到作者有对于圆角矩形头像的示例代码,但这......