Highcharts Reverse Bar Chart

A reverse bar chart, also known as a horizontal bar chart, is a chart type that displays data in horizontal bars rather than vertical bars. Highcharts supports horizontal bar charts with the chart.type option set to 'bar' and the xAxis and yAxis options reversed.

To create a reverse bar 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: 'bar'
  },
  title: {
    text: 'Reverse Bar Chart'
  },
  xAxis: {
    reversed: true,
    categories: ['Category 1', 'Category 2', 'Category 3', 'Category 4', 'Category 5']
  },
  yAxis: {
    title: {
      text: 'Y Axis Label'
    }
  },
  series: [{
    name: 'Series Name',
    data: [10, 20, 30, 40, 50]
  }]
});

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

  • chart.type is set to 'bar' to create a bar chart
  • title.text is set to 'Reverse Bar Chart' to set the main title
  • xAxis.reversed is set to true to reverse the direction of the horizontal bars
  • xAxis.categories is set to an array of category labels for the y-axis (which is displayed horizontally in a reverse bar chart)
  • yAxis.title is used to set the label for the x-axis
  • 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 horizontal bars.

With these options, you can create a reverse bar chart with customizable data and appearance. Note that Highcharts supports other options to customize the appearance of bar charts, including the color, stacking, and pointWidth options.

  1. Customizing appearance in Highcharts Reverse Bar Chart: To customize the appearance of a Reverse Bar Chart in Highcharts, you can use various options like colors, bar width, and more. Here's an example code snippet:

    Highcharts.chart('container', {
        chart: {
            type: 'bar'
        },
        plotOptions: {
            bar: {
                dataLabels: {
                    enabled: true
                }
            }
        },
        xAxis: {
            reversed: true // Reverse the order of the x-axis
        },
        series: [{
            name: 'Reverse Bar Data',
            data: [10, 20, 30, 40, 50]
        }]
    });
    
  2. Adding data to Highcharts Reverse Bar Chart: Adding data to a Reverse Bar Chart is similar to other bar charts. Use the data property within the series object. Here's an example:

    series: [{
        name: 'Reverse Bar Data',
        data: [10, 20, 30, 40, 50]
    }]
    
  3. Stacked Reverse Bar Chart in Highcharts: To create a stacked Reverse Bar Chart, you can set the stacking property in the plot options. Here's an example:

    plotOptions: {
        bar: {
            stacking: 'normal'
        }
    },
    series: [{
        name: 'Category 1',
        data: [10, 20, 30, 40, 50]
    }, {
        name: 'Category 2',
        data: [5, 10, 15, 20, 25]
    }]
    
  4. Grouped Reverse Bar Chart using Highcharts: To create a grouped Reverse Bar Chart, omit the stacking property. Here's an example:

    plotOptions: {
        bar: {
            // No stacking property for grouped chart
        }
    },
    series: [{
        name: 'Category 1',
        data: [10, 20, 30, 40, 50]
    }, {
        name: 'Category 2',
        data: [5, 10, 15, 20, 25]
    }]
    
  5. Interactive features in Highcharts Reverse Bar Chart: Highcharts supports interactive features like tooltips, click events, and legends in Reverse Bar Charts. You can enable these features to enhance user interaction. Here's a snippet for tooltip configuration:

    tooltip: {
        pointFormat: 'Value: {point.y}'
    }