0
votes

I need to make a separation between bars from a bar chart based on the bar width. That means that if a bar has a width of 1X, the separation between bars must be 1.5X. Is that possible? I played with variables like pointPadding and groupPadding but I couldn't solve this. Here I set pointPadding on 0.15 but it doesn't seem to make a 1.5-bars space between them:

Highcharts.chart('container', {
    chart: {
        type: 'column'
    },
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug']
    },

    plotOptions: {
        series: {
            pointPadding: 0.15
        }
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5]
    }]
});

https://jsfiddle.net/5nza8q1s/19/

Also, I need to make the first and last separation (between the bar and the chart borders) of 0.5X, is that possible too?

1

1 Answers

1
votes

For the first requirement you can use groupPadding with calculated values from proportion: 0.3 - 0.4 - 0.3, which gives us 0.6 between columns - 150% of 0.4 (all in axis units).

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

To achieve shorter distance at axis ends, use min and max properties:

    xAxis: {
        ...,
        min: 0.1, // increased from 0
        max: 6.9 // reduced from 7
    },

Live demo: https://jsfiddle.net/BlackLabel/6uktc3as/

API Reference:

https://api.highcharts.com/highcharts/xAxis.max

https://api.highcharts.com/highcharts/xAxis.min

https://api.highcharts.com/highcharts/series.column.groupPadding