Highcharts Stacked Column Chart

A stacked column chart is a chart type that displays data as a series of columns stacked on top of each other, with each column representing a category or data series and the height of the column representing the value of that category or series. Highcharts supports stacked column charts with the chart.type option set to 'column' and the plotOptions.column.stacking option enabled.

To create a stacked column chart using Highcharts, you can follow these steps:

  • Include the Highcharts library in your HTML file. You can either download it from the Highcharts website or include it from a CDN like this:
<script src="https://code.highcharts.com/highcharts.js"></script>
  • Create a container element for the chart in your HTML file, like this:
<div id="chart-container"></div>
  • In your JavaScript code, create a Highcharts chart object and configure it with the data and chart options. For example:
Highcharts.chart('chart-container', {
  chart: {
    type: 'column'
  },
  title: {
    text: 'Stacked Column Chart'
  },
  xAxis: {
    categories: ['Category 1', 'Category 2', 'Category 3', 'Category 4', 'Category 5']
  },
  yAxis: {
    title: {
      text: 'Y Axis Label'
    }
  },
  plotOptions: {
    column: {
      stacking: 'normal'
    }
  },
  series: [{
    name: 'Series 1',
    data: [10, 20, 30, 40, 50]
  }, {
    name: 'Series 2',
    data: [20, 30, 40, 50, 60]
  }, {
    name: 'Series 3',
    data: [30, 40, 50, 60, 70]
  }]
});

In this example, we're creating a stacked column chart with the Highcharts chart function and passing in a set of options:

  • chart.type is set to 'column' to create a column chart
  • title.text is set to 'Stacked Column Chart' to set the main title
  • xAxis.categories is set to an array of category labels for the x-axis
  • yAxis.title is used to set the label for the y-axis
  • plotOptions.column.stacking is set to 'normal' to enable stacking of columns
  • series is set to an array of objects with a name and data property to define the series data. The data property contains an array of values for each category, which are displayed as stacked columns. The columns are stacked on top of each other to show the contribution of each data series to the overall value.

With these options, you can create a stacked column chart with customizable data and appearance. Note that Highcharts supports other options to customize the appearance of column charts, including the color, marker, and tooltip options.

  1. Customizing appearance in Highcharts Stacked Column Chart:

    • Highcharts allows extensive customization of the appearance. You can modify colors, borders, tooltips, etc.
    Highcharts.chart('container', {
        chart: {
            type: 'column'
        },
        plotOptions: {
            column: {
                color: '#FFA07A', // Set column color
                borderColor: 'black', // Set border color
                borderWidth: 2 // Set border width
            }
        },
        // Other configuration options...
    });
    
  2. Adding data to Highcharts Stacked Column Chart:

    • Simply define your data in the series array.
    Highcharts.chart('container', {
        series: [{
            name: 'Series 1',
            data: [5, 3, 4, 7, 2]
        }, {
            name: 'Series 2',
            data: [2, 4, 1, 3, 5]
        }],
        // Other configuration options...
    });
    
  3. Grouped Stacked Column Chart in Highcharts:

    • You can achieve grouping by configuring the stacking option and providing categories for grouping.
    Highcharts.chart('container', {
        chart: {
            type: 'column'
        },
        plotOptions: {
            column: {
                stacking: 'normal' // 'normal' for grouped stacking
            }
        },
        // Other configuration options...
    });
    
  4. Interactive features in Highcharts Stacked Column Chart:

    • Highcharts supports various interactive features like tooltips, drilldowns, and events.
    Highcharts.chart('container', {
        tooltip: {
            formatter: function () {
                return 'Point value: ' + this.y;
            }
        },
        // Other configuration options...
    });
    
  5. Handling multiple series in Highcharts Stacked Column Chart:

    • Handle multiple series by defining each series within the series array.
    Highcharts.chart('container', {
        series: [{
            name: 'Series 1',
            data: [1, 2, 3]
        }, {
            name: 'Series 2',
            data: [4, 5, 6]
        }],
        // Other configuration options...
    });