Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reduce gap between series data in Bar Highchart

I want to reduce space between bar chart series data. Below mentioned is the image which gives a clear picture :

enter image description here

Can anyone suggest the best approach to do it?

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Historic World Population by Region'
        },
        subtitle: {
            text: 'Source: Wikipedia.org'
        },
        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: 100,
            floating: true,
            borderWidth: 1,
            backgroundColor: '#FFFFFF',
            shadow: true
        },
        credits: {
            enabled: false
        },
        series: [{
            name: 'Year 1800',
            data: [107, 31, 635],
            pointWidth: 22,
        }, {
            name: 'Year 1900',
            data: [133, 156, 947],
            pointWidth: 22
        }]

    });
});

http://jsfiddle.net/fMdk3/5/

like image 806
Aditya Sethi Avatar asked Nov 12 '13 07:11

Aditya Sethi


1 Answers

The options you want to play with are pointPadding (padding between bars) and groupPadding (padding between seies).

e.g.

 plotOptions: {
        series: {
            pointPadding: 0,
            groupPadding: 0.1,
        }
    },

e.g. http://jsfiddle.net/BZzWQ/

like image 174
SteveP Avatar answered Sep 28 '22 03:09

SteveP