Want to avoid the spacing between each stacked bar in tall charts?

I work with Highcharts and run into a small problem that I am struggling to overcome.

I created jsfiddle so you can see my problem:

http://jsfiddle.net/jo_pappi/0e5h8sts/3/ [A]

as you can see

Needed output format

I can achieve the above format in highcharts, as this rendering chart is based on dynamic data. When the values ​​of one group enter highcharts, it has so much space between the bars. There is an image here

And code

$('#container-one').highcharts({
    chart: {
        type: 'bar',
        events: {
            click: function (event) {
                console.log(event.pageX + ',' + event.pageY);
            }
        }
    },

    credits: {
        enabled: false
    },

    title: {
        text: 'Total fruit consumtion, grouped by gender'
    },

    xAxis: {
        categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'],
        minPadding: 1.1,
        maxPadding: 1.1
    },

    yAxis: {
        allowDecimals: false,
        min: 0,
        title: {
            text: 'Number of fruits'
        }
    },

    tooltip: {
        enabled: false,
        formatter: function () {
            return '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + this.y + '<br/>' +
                'Total: ' + this.point.stackTotal;
        }
    },

    plotOptions: {
        // column: {
        //     stacking: 'normal'
        // }
        series: {
            pointWidth: 20,
            stacking: 'normal',
            borderWidth: 0,
            events: {
                click: function (event) {
                    //reloadFlash();
                    //$('#report').html('click on yAxis title');
                    console.log(event.pageX + ',' + event.pageY);
                }
            }
        }
    },

    series: [{
        name: 'John',
        color: 'rgba(89,89,89,1)',
        data: [5],                     // data: [5, 3, 4, 7, 4],
        stack: 'male',
        pointPadding: -0.0,
        pointPlacement: -0.0
    }, {
        name: 'Joe',
        color: 'rgba(255,95,215,1)',
        data: [3],                    // data: [3, 4, 4, 2, 2],
        stack: 'male',
        pointPadding: -0.0,
        pointPlacement: -0.0
    }, {
        name: 'Jane',
        color: 'rgba(217,116,0,1)',
        data: [2],                    // data: [2, 5, 6, 2, 1],
        stack: 'female',
        pointPadding: -0.0,
        pointPlacement: -0.0
    }, {
        name: 'Janet',
        color: 'rgba(155,215,255,1)',
        data: [3],        // data: [3, 0, 4, 4, 3],
        stack: 'female',
        pointPadding: -0.0,
        pointPlacement: -0.0
    }]

});

Image shows the problem

How can I reduce the spaces between columns?

If you change the height of the chart, then one of the solutions means how I can achieve this dynamically?

+4
3

"pointWidth" . , . , . , , "210" "270". pointWidth.

$('#container-one').highcharts({

    chart: {
        type: 'bar',
        height: 210,
        ...
        .
        .
    plotOptions: {
        bar: {
            pointPadding: 0,
            borderWidth: 0
        },
        series: {
            //pointWidth: 20,
            stacking: 'normal',
        .
        .
});

, 270

$('#container-two').highcharts({

    chart: {
        type: 'bar',
        height: 270,
        ...
        .
        .
    plotOptions: {
        bar: {
            pointPadding: 0,
            borderWidth: 0
        },
        series: {
            //pointWidth: 20,
            stacking: 'normal',
        .
        .
});

Fiddle

, , . . , .

+2

'pointWidth: 20' ? . : ['', '', '', '', ''], .. .. , , , . :

 _chart.setSize(width,height)

highchart. pointWidth ...

+1

:

plotOptions:{
    bar:{
        pointPadding: 0,
        groupPadding: 0,
    }
}

.

series: {
            pointWidth: 20,

http://jsfiddle.net/d9f8b22x/

API , :

http://api.highcharts.com/highcharts#plotOptions.column.pointPadding

0

All Articles