Highcharts Basic Bar 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 basic bar chart using highcharts library with examples.

Highcharts Basic Bar Chart Example

Following is the example of creating a basic bar chart by setting the required bar chart properties using highcharts library.

 

Live Preview

<html>

<head>

    <title>Highcharts Basic Bar 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/exporting.js"></script>

    <script src="https://code.highcharts.com/modules/export-data.js"></script>

    <script type="text/javascript">

        $(function() {

            Highcharts.chart('container', {

                chart: {

                    type: 'bar'

                },

                title: {

                    text: 'Historic World Population by Region'

                },

                subtitle: {

                    text: 'Source: Wikipedia'

                },

                xAxis: {

                    categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania'],

                    title: {

                        text: null

                    }

                },

                yAxis: {

                    min: 0,

                    title: {

                        text: 'Population (millions)',

                        align: 'high'

                    },

                    labels: {

                        overflow: 'justify'

                    }

                },

                tooltip: {

                    valueSuffix: ' millions'

                },

                plotOptions: {

                    bar: {

                        dataLabels: {

                            enabled: true

                        }

                    }

                },

                legend: {

                    layout: 'vertical',

                    align: 'right',

                    verticalAlign: 'top',

                    x: -40,

                    y: 80,

                    floating: true,

                    borderWidth: 1,

                    backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),

                    shadow: true

                },

                credits: {

                    enabled: false

                },

                series: [{

                    name: 'Year 1800',

                    data: [107, 31, 635, 203, 2]

                }, {

                    name: 'Year 1900',

                    data: [133, 156, 947, 408, 6]

                }, {

                    name: 'Year 2000',

                    data: [814, 841, 3714, 727, 31]

                }, {

                    name: 'Year 2016',

                    data: [1216, 1001, 4436, 738, 40]

                }]

            });

        });

    </script>

</head>

<body>

    <div id="container" style="width: 100%; height: 400px;"> </div>

</body>

</html>

If you observe the above example, we created a basic bar chart using highcharts library with required properties.

 

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

 

Highcharts basic bar chart example result

 

This is how we can create a basic bar chart using highcharts library with required properties.