reverse a bar chart - Javascript highcharts

Javascript examples for highcharts:Bar Chart

Description

reverse a bar chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
$(function () {// w w  w  . j  a v  a  2 s.  c om
    var chart;
    $(document).ready(function() {
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                type: 'bar'
            },
            title: {
                text: 'Marks in 5th grade'
            },
            xAxis: {
                reversed:true,
                categories: ['John', 'Sandy', 'Carl', 'Maria'],
                title: {
                    text: null
                },
                opposite: true
            },
            yAxis: {
                min: -6,
                max: 0,
                title: {
                    text: 'Marks from  6 (very bad) to 1 (yery good)',
                    align: 'high'
                },
                labels: {
                    overflow: 'justify',
                    formatter: function() {
                    return this.value * -1;
                }
                }
            },
            plotOptions: {
                bar: {
                    dataLabels: {
                        enabled: true
                    }
                }
            },
            credits: {
                enabled: false
            },
            series: [{
                name: 'Year 2012',
                data: [-1,]            }, {
                name: 'Year 2011',
                data: [-1.99]
            }, {
                name: 'Year 2010',
                data: [-1.74]
            }]
        });
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials