Highcharts Tree Map with Color Axis Chart

In the previous chapters, we learned how to setup highcharts library and how to create a chart with required configurations using highcharts library in our webpage. Now, we will learn how to create a tree map chart using highcharts library with examples.

Highcharts Tree Map Chart Example

Following is the example of creating a tree map chart with color axis by setting the required chart properties using highcharts library.

 

Live Preview

<html>

<head>

    <title>Highcharts Tree Map with Color Axis Chart</title>

    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

    <script src="https://code.highcharts.com/highcharts.js"></script>

    <script src="https://code.highcharts.com/modules/heatmap.js"></script>

    <script src="https://code.highcharts.com/modules/treemap.js"></script>

    <script type="text/javascript">

        $(function() {

            Highcharts.chart('container', {

                colorAxis: {

                    minColor: '#FFFFFF',

                    maxColor: Highcharts.getOptions().colors[0]

                },

                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}

                          ]

                }],

                title: {

                    text: 'Highcharts Treemap'

                }

            });

        });

    </script>

</head>

<body>

    <div id="container"></div>

</body>

</html>

If you observe the above example, we created a tree map chart with color axis using highcharts library with required properties.

 

When we execute the above highcharts example, we will get the result like as shown below.

 

Highcharts Tree Map with Color Axis Example Result

 

This is how we can create a tree map chart with color axis using highcharts library with required properties.

Topics Covered