Set background color for bar chart - Javascript highcharts

Javascript examples for highcharts:Bar Chart

Description

Set background color for 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://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from  w  ww  .  j av a 2s .  c om*/
var maxFruit = 10
$(function () {
    var chartConfig ={
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Stacked bar chart'
        },
        xAxis: {
            categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
        },
        yAxis: {
            min: 0,
            max: maxFruit,
            title: {
                text: 'Total fruit consumption'
            }
        },
        legend: {
            reversed: true
        },
        plotOptions: {
            series: {
                stacking: 'normal'
            }
        },
        series: [{
            name: 'John',
            index: 1,
            data: [5, 3, 4, 7, 2]
        }]
    }
    chartConfig.series.push({
        name: 'Remainder',
        index: 0,
        data: chartConfig.series[0].data.map(function(value) { return maxFruit - value })
    })
    $('#container').highcharts(chartConfig);
});
    });

      </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: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials