Highcharts Treemap

Highcharts Treemap is a chart type used to represent hierarchical data in a rectangular layout. The size and color of each rectangle are used to represent the values of the data. The rectangles are nested inside each other to represent the hierarchy.

To create a treemap chart in Highcharts, you can use the chart.type option set to 'treemap'. The data for the chart should be in a hierarchical format, with each data point having a name and value property. If you want to display a nested hierarchy, you can include a children property with an array of child data points.

Here's an example of how to create a basic treemap chart in Highcharts:

Highcharts.chart('container', {
  chart: {
    type: 'treemap'
  },
  title: {
    text: 'Treemap Chart'
  },
  series: [{
    type: 'treemap',
    layoutAlgorithm: 'squarified',
    data: [{
      name: 'Category 1',
      value: 10
    }, {
      name: 'Category 2',
      value: 20
    }, {
      name: 'Category 3',
      value: 30
    }]
  }]
});

In this example, we first create a Highcharts chart object and configure it with the following options:

  • chart.type is set to 'treemap' to create a treemap chart
  • title.text is set to 'Treemap Chart' to set the main title
  • series is set to an array of objects with a type, layoutAlgorithm, and data property to define the series data. The type property is set to 'treemap' to specify the chart type, the layoutAlgorithm property is set to 'squarified' to specify the layout algorithm to use, and the data property contains an array of objects with name and value properties.

With these options, you can create a basic treemap chart in Highcharts. You can also customize the chart further by adding additional data points, setting the color scheme and style of the chart, and configuring the layout algorithm to optimize the representation of your data.

  1. Customizing Highcharts Treemap:

    • Customize appearance by modifying various Treemap options such as colors, borders, and tooltips.
    Highcharts.chart('container', {
        series: [{
            type: 'treemap',
            data: [...], // Treemap data
            layoutAlgorithm: 'squarified', // Set layout algorithm
            color: '#7CB5EC', // Set default color
            borderColor: 'black', // Set border color
            borderWidth: 2 // Set border width
        }],
        // Other configuration options...
    });
    
  2. Interactive Treemaps with Highcharts:

    • Enable interactivity by configuring features like drilldowns, tooltips, and events.
    Highcharts.chart('container', {
        series: [{
            type: 'treemap',
            allowDrillToNode: true, // Enable drilldown to node
            dataLabels: {
                enabled: true // Show data labels
            },
            // Other configuration options...
        }],
        // Other configuration options...
    });
    
  3. Highcharts Treemap data format:

    • Format Treemap data appropriately using an array of objects with name and value properties.
    data: [{
        name: 'Category 1',
        value: 10
    }, {
        name: 'Category 2',
        value: 15
    }],
    
  4. Highcharts Treemap drilldown example:

    • Implement drilldown functionality by defining a drilldown series.
    series: [{
        type: 'treemap',
        data: [...],
        drilldown: {
            series: [{
                name: 'Subcategory 1',
                id: 'subcategory1',
                data: [...]
            }]
        }
    }],
    
  5. Highcharts Treemap color options:

    • Customize colors using the color option or a color axis.
    colorAxis: {
        minColor: '#FFFFFF',
        maxColor: '#7CB5EC'
    },
    
  6. Highcharts Treemap hierarchical data:

    • Display hierarchical data by organizing it in a nested structure.
    data: [{
        name: 'Category 1',
        value: 10,
        children: [{
            name: 'Subcategory 1',
            value: 5
        }]
    }],
    
  7. Highcharts Treemap tooltip customization:

    • Customize tooltips to display relevant information.
    tooltip: {
        pointFormat: '<b>{point.name}</b>: {point.value}'
    },
    
  8. Highcharts Treemap integration with JavaScript:

    • Integrate Treemap with JavaScript and handle events as needed.
    Highcharts.chart('container', {
        chart: {
            events: {
                load: function () {
                    // Handle chart load event
                }
            }
        },
        // Other configuration options...
    });
    
  9. Highcharts Treemap responsive design:

    • Ensure a responsive design using the responsive option.
    responsive: {
        rules: [{
            condition: {
                maxWidth: 500
            },
            // Adjust options for smaller screens
        }]
    },
    
  10. Highcharts Treemap with JSON data:

    • Load Treemap data from a JSON source.
    series: [{
        type: 'treemap',
        data: {
            // JSON data
        }
    }],
    
  11. Highcharts Treemap events handling:

    • Handle events like click, drilldown, etc., for enhanced interactivity.
    series: [{
        type: 'treemap',
        point: {
            events: {
                click: function () {
                    // Handle click event
                }
            }
        },
        // Other configuration options...
    }],