简体   繁体   English

如何使用Highchart.js创建具有累积线的堆积图

[英]How to create a stacked chart with cumulative line using Highchart.js

Does anyone have any examples of using Highchart to achieve a result like the one in the image? 有没有人有使用Highchart达到图像中所示结果的示例?

function drawChart(result) {
    var response =
        {
            Month: result.Month,
            Data: result.Data,
            Title: result.title
        };
    $('#dvChart').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: title
        },

        xAxis: {
            categories: response.Month
        },
        yAxis: [{
            min: 0,
            title: {
                text: "# Of Tests"
            },

        }, 

        ],

        plotOptions: {
            column: {
                pointPadding: 0.2,
                borderWidth: 0,
                stacking: 'normal',

                }
            }
        }

        ,    
        series:                 
             response.Data                                       
    });

}

My code above can achieve stacked chart but I dont know how to put cumulative lines to the chart. 我上面的代码可以实现堆叠图表,但是我不知道如何在图表上放置累积线。

带有累积线的堆积图

To get line type series with stacked column series you should set type of type per series for ones with other type than the one defined in chart.type option. 为了获得line与堆叠式系列column系列,你应该设置每个系列类型的类型的人与其他类型相比,chart.type选项中定义的一个。

Example: http://jsfiddle.net/t3v579uj/ 示例: http//jsfiddle.net/t3v579uj/

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        xAxis: {
            categories: ['r', 'e', 's', 'p', 'o']
        },
        yAxis: [{
            min: 0,
            title: {
                text: "# Of Tests"
            }
        }],
        plotOptions: {
            column: {
                pointPadding: 0.2,
                borderWidth: 0,
                stacking: 'normal'
            }
        },
        series: [{
            data: [1,2,3,4]
        },{
            data: [1,2,3,4]
        },{
            data: [1,2,3,4]
        },{
            type: 'line',
            data: [2,3,4,5]
        }]
    });
});

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

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