Chart.js how to get Combined Bar and line charts?

后端 未结 6 1592
眼角桃花
眼角桃花 2020-12-02 08:14

i would like to ask is that possible using Chart.js http://www.chartjs.org/ to get Combined Bar and line charts?

Thanks for any advice.

6条回答
  •  渐次进展
    2020-12-02 08:37

    One minor code addition is needed. In the "buildScale" section, you need to include the data from eachPoints as well. This is, because calculatedY is only using the data from bar to determine the height; the data using line is ignored. If the data using the line is higher than the data using bar, the line graph will be cut off at the top.

    buildScale : function(labels){
        var self = this;
    
        var dataTotal = function(){
            var values = [];
            self.eachBars(function(bar){
                values.push(bar.value);
            });
    // missing code ↓↓↓
            self.eachPoints(function(point){
                values.push(point.value);
            });
    // missing code ↑↑↑
            return values;
        };
    

提交回复
热议问题