Removing the padding for a bar chart - Javascript highcharts

Javascript examples for highcharts:Bar Chart

Description

Removing the padding for 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="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
$(function () {/* www . j  ava2s  . c  om*/
    var chart;
    $(document).ready(function () {
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                type: 'bar',
                margin: [0,0,0,0]
            },
            legend: {
                enabled: false,
            },
            title: {
                text: ''
            },
            xAxis: {
                lineWidth: 0,
                labels: {
                    enabled: false
                },
                minorTickLength: 0,
                tickLength: 0
            },
            yAxis: {
                min: 0,
                title: {
                    text: ''
                },
                lineWidth: 0,
                gridLineWidth:0,
                lineColor: 'transparent',
                labels: {
                    enabled: false
                },
                minorTickLength: 0,
                tickLength: 0
            },
            tooltip: {
                enabled: false
            },
            plotOptions: {
                bar: {
                    stacking: 'percent'
                },
                 series: {
            pointPadding: 0,
            groupPadding: 0,
        }
            },
            series: [{
                name: 'max',
                data: [40],
                color: 'red'
            }, {
                name: 'current',
                data: [60],
                color: 'green'
            }]
        });
    });
});

      </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="border: 1px black dotted; width: 500px; height: 60px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials