Highcharts教程

Highcharts 树状图

以下是带有颜色轴的树状图示例。
我们已经在Highcharts配置语法一章中看到了用于绘制图表的配置。

配置

现在让我们看看额外的配置/步骤。

系列.类型

将系列类型配置为基于树状图。将类型设置为"树状图"。
var series = {
   type: 'treemap'
};

示例

highcharts_tree_map.htm
<html>
   <head>
      <title>Highcharts Tutorial</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
      <script src = "https://code.highcharts.com/highcharts.js"></script>    
      <script src = "https://code.highcharts.com/modules/treemap.js"></script>    
      <script src = "https://code.highcharts.com/modules/heatmap.js"></script>  
   </head>
   
   <body>
      <div id = "container" style = "width: 550px; height: 400px; margin: 0 auto"></div>
      <script language = "JavaScript">
         $(document).ready(function() {    
            var title = {
               text: 'Highcharts Treemap'   
            };       
            var colorAxis = {
               minColor: '#FFFFFF',
               maxColor: Highcharts.getOptions().colors[0]
            };
            var series = [{
               type: "treemap",
               layoutAlgorithm: 'squarified',
               data: [
                  {
                     name: 'A',
                     value: 6,
                     colorValue: 1
                  }, 
                  {
                     name: 'B',
                     value: 6,
                     colorValue: 2
                  }, 
                  {
                     name: 'C',
                     value: 4,
                     colorValue: 3
                  }, 
                  {
                     name: 'D',
                     value: 3,
                     colorValue: 4
                  }, 
                  {
                     name: 'E',
                     value: 2,
                     colorValue: 5
                  }, 
                  {
                     name: 'F',
                     value: 2,
                     colorValue: 6
                  }, 
                  {
                     name: 'G',
                     value: 1,
                     colorValue: 7
                  }
               ]
            }];     
            var json = {};     
            json.title = title;          
            json.colorAxis = colorAxis;   
            json.series = series;       
   
            $('#container').highcharts(json);
         });
      </script>
   </body>
   
</html>
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4