Highcharts Rotated Labels Column 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 column chart with rotated labels using highcharts library with examples.

Highcharts Rotated Labels Column Chart Example

Following is the example of creating a column chart with rotated labels by setting the required column chart properties using highcharts library.

 

<html>

<head>

    <title>Highcharts Rotated Labels Column 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: 'column'

                },

                title: {

                    text: 'World\'s largest cities per 2017'

                },

                subtitle: {

                    text: 'Source: Wikipedia'

                },

                xAxis: {

                    type: 'category',

                    labels: {

                        rotation: -45,

                        style: {

                            fontSize: '13px',

                            fontFamily: 'Verdana, sans-serif'

                        }

                    }

                },

                yAxis: {

                    min: 0,

                    title: {

                        text: 'Population (millions)'

                    }

                },

                legend: {

                    enabled: false

                },

                tooltip: {

                    pointFormat: 'Population in 2017: <b>{point.y:.1f} millions</b>'

                },

                series: [{

                    name: 'Population',

                    data: [

                        ['Shanghai', 24.2],

                        ['Beijing', 20.8],

                        ['Karachi', 14.9],

                        ['Shenzhen', 13.7],

                        ['Guangzhou', 13.1],

                        ['Istanbul', 12.7],

                        ['Mumbai', 12.4],

                        ['Moscow', 12.2],

                        ['São Paulo', 12.0],

                        ['Delhi', 11.7],

                        ['Kinshasa', 11.5],

                        ['Tianjin', 11.2],

                        ['Lahore', 11.1],

                        ['Jakarta', 10.6],

                        ['Dongguan', 10.6],

                        ['Lagos', 10.6],

                        ['Bengaluru', 10.3],

                        ['Seoul', 9.8],

                        ['Foshan', 9.3],

                        ['Tokyo', 9.3]

                    ],

                    dataLabels: {

                        enabled: true,

                        rotation: -90,

                        color: '#FFFFFF',

                        align: 'right',

                        format: '{point.y:.1f}', // one decimal

                        y: 10, // 10 pixels down from the top

                        style: {

                            fontSize: '13px',

                            fontFamily: 'Verdana, sans-serif'

                        }

                    }

                }]

            });

        });

    </script>

</head>

<body>

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

</body>

</html>

If you observe the above example, we created a column chart with rotated labels using highcharts library with required properties.

 

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

 

Highcharts Rotated Labels Column Chart Example Result

 

This is how we can create a column chart with rotated labels using highcharts library with required properties. 

Topics Covered