Highcharts-tree-levels

提供:Dev Guides
移動先:案内検索

ハイチャート-レベル付きのツリーマップ

link:/highcharts/highcharts_configuration_syntax [Highcharts設定構文]の章でチャートを描画するために使用される設定はすでに見ました。

レベル付きのツリーマップチャートの例を以下に示します。

構成

ここで、追加の構成/実行された手順を見てみましょう。

series.type

シリーズタイプをツリーマップベースに設定します。 タイプを「ツリーマップ」として設定します。

var series = {
   type: 'treemap'
};

*_highcharts_tree_levels_*
<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: 'Fruit consumption'
            };
            var series = [{
               type: "treemap",
               layoutAlgorithm: 'stripes',
               alternateStartingDirection: true,

               levels: [{
                  level: 1,
                  layoutAlgorithm: 'sliceAndDice',
                  dataLabels: {
                     enabled: true,
                     align: 'left',
                     verticalAlign: 'top',
                     style: {
                        fontSize: '15px',
                        fontWeight: 'bold'
                     }
                  }
               }],
               data: [
                  {
                     id: 'A',
                     name: 'Apples',
                     color: "#EC2500"
                  },
                  {
                     id:'B',
                     name: 'Bananas',
                     color: "#ECE100"
                  },
                  {
                     id: 'O',
                     name: 'Oranges',
                     color: '#EC9800'
                  },
                  {
                     name: 'Anne',
                     parent: 'A',
                     value: 5
                  },
                  {
                     name: 'Rick',
                     parent: 'A',
                     value: 3
                  },
                  {
                     name: 'Peter',
                     parent: 'A',
                     value: 4
                  },
                  {
                     name: 'Anne',
                     parent: 'B',
                     value: 4
                  },
                  {
                     name: 'Rick',
                     parent: 'B',
                     value: 10
                  },
                  {
                     name: 'Peter',
                     parent: 'B',
                     value: 1
                  },
                  {
                     name: 'Anne',
                     parent: 'O',
                     value: 1
                  },
                  {
                     name: 'Rick',
                     parent: 'O',
                     value: 3
                  },
                  {
                     name: 'Peter',
                     parent: 'O',
                     value: 3
                  },
                  {
                     name: 'Susanne',
                     parent: 'Kiwi',
                     value: 2,
                     color: '#9EDE00'
                  }
               ]
            }];

            var json = {};
            json.title = title;
            json.series = series;

            $('#container').highcharts(json);
         });
      </script>
   </body>

</html>

結果

結果を確認します。