简体   繁体   English

HighCharts线系列与堆叠的条形组合图无法正确显示

[英]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/ 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. 如果拆开条形图,则看起来正确。

Remove the stacking: 'normal' from plotOptions, and apply it individually at a series level, to the column series only. 从plotOptions中删除stacking: 'normal' ,并在系列级别将其单独应用到仅列系列。

Updated Jsfiddle 更新的Jsfiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM