pizza247
pizza247

Reputation: 3897

HighCharts line series not displaying properly with stacked bar combo chart

The line series don't properly match up.

$(function () {
  $('#container').highcharts({
    title: {
        text: 'Combination chart'
    },
    xAxis: {
        categories: ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']
    },
    labels: {
        items: [{
            html: 'Total fruit consumption',
            style: {
                left: '50px',
                top: '18px',
                color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
            }
        }]
    },
    plotOptions: {
        series: {
            stacking: 'normal'
        }
    },
    series: [{
        type: 'column',
        name: 'Jane',
        data: [3, 2, 1, 3, 4],
        stack: 0
    }, {
        type: 'column',
        name: 'John',
        data: [2, 3, 5, 7, 6],
        stack: 0
    }, {
        type: 'column',
        name: 'Joe',
        data: [4, 3, 3, 9, 0],
        stack: 0
    }, {
        type: 'line',
        name: 'Average',
        data: [3, 2.67, 3, 6.33, 3.33],
        marker: {
            lineWidth: 2,
            lineColor: Highcharts.getOptions().colors[3],
            fillColor: 'white'
        }
    }, {
        type: 'line',
        name: 'Total consumption',
        data: [3, 2.67, 3, 6.33, 3.33],
        center: [100, 80],
        size: 100,
        showInLegend: false,
        dataLabels: {
            enabled: false
        }
    }]
  });
});

Here's a fiddle to show what I'm doing:

http://jsfiddle.net/tn7b0fb0/

The numbers for the line's are the same, why aren't they on top of eachother?

If you unstack the bar charts, it looks right.

Upvotes: 1

Views: 458

Answers (1)

sheilak
sheilak

Reputation: 5873

Remove the stacking: 'normal' from plotOptions, and apply it individually at a series level, to the column series only.

Updated Jsfiddle

Upvotes: 1

Related Questions