启用Chart.Js中的步进行

时间:2017-07-05 07:40:20

标签: javascript charts chart.js

我正在尝试在ChartJs 2.6.0中启用阶梯线

var chartJsObj = {
        data: {
            labels: ["January", "February", "March", "April", "May", "June", "July"],
            datasets: [{
                label: "My First dataset",
                data: [2, 23, 15, 16, 24, 21, 17, 13],
                borderColor: 'rgb(54, 162, 235)',
                fill: false,
                steppedLine: true
            }],
        },

    }

但它绘制了一条普通的曲线。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

查看Github上的Chartjs示例,包括多个阶梯线图示例 - https://github.com/chartjs/Chart.js/blob/master/samples/charts/line/stepped.html

在Codepen上重新创建的示例 - https://codepen.io/Inlesco/pen/yXEvOz

Codepen示例中每个图表上steppedLine的配置都以小块定义,例如:

{
    steppedLine: true,
    label: 'No Step Interpolation',
    color: window.chartColors.red
}