简体   繁体   中英

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?

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.

Example: 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]
        }]
    });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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