Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Column spacing in Highcharts

I am working with Highcharts and have come across a little problem that I am struggling to overcome.

I have created a jsfiddle so you can see my issue:

http://jsfiddle.net/gokninski/qkBsA/

And here is the code I am using:

$('#output-chart').highcharts({
        chart: { type: 'column' },
        title: { text: null },
        xAxis: { categories: ['Column 1', 'Column 2', 'Column 3', 'Column 4'] },
        yAxis: { allowDecimals: false, min: 0, labels: { format: '£{value}' }, title: { text: ''} },
        plotOptions: { column: { stacking: 'normal'}, series: { pointWidth: 50, pointPadding: 0, groupPadding: 0} },
        series: [{
            name: 'Product 1 Element 1',
            data: [0, 100 - 125, 100 - 150, 100 - 175],
            stack: 'Item1'                
        }, {
            name: 'Product 1 Element 2',
            data: [100, 125, 150, 175],
            stack: 'Item1'                          
        }, {
            name: 'Product 2 Element 1',
            data: [0, 100 - 125, 100 - 150, 100 - 175],
            stack: 'Item2'                            
        }, {
            name: 'Product 2 Element 2',
            data: [100, 125, 150, 175],
            stack: 'Item2'                    
        }]
    });

So, there are two bars in each column and I want to put those two bars right against each other but still have a gap between the columns.

I hope that makes sense!

Any help would be very much appreciated.

Many thanks

G.

like image 612
gok-nine Avatar asked Dec 05 '25 11:12

gok-nine


2 Answers

If you want to have to bars together, but also have padding between pair of them you need to set only pointPadding and don't change pointWidth. See: http://jsfiddle.net/Fusher/FpKjQ/16/

like image 149
Paweł Fus Avatar answered Dec 07 '25 01:12

Paweł Fus


you can use groupPadding: 0.1 then it will come much closer.

like image 39
naveen goyal Avatar answered Dec 06 '25 23:12

naveen goyal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!