Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/409.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在chartjs中显示直角_Javascript_Chart.js - Fatal编程技术网

Javascript 如何在chartjs中显示直角

Javascript 如何在chartjs中显示直角,javascript,chart.js,Javascript,Chart.js,我使用chartjs库来显示一些数据。以下代码负责显示 new Chart(ctx, { type: 'line', data: { labels: ["00:00", "01:00", "02:00", "03:00", "04:00", "05:00", "06:00", "07:00", "08:00", "09:00", "10:00", "11:00",

我使用chartjs库来显示一些数据。以下代码负责显示

new Chart(ctx, {
        type: 'line',
        data: {
            labels: ["00:00", "01:00", "02:00", "03:00",
                "04:00", "05:00", "06:00", "07:00",
                "08:00", "09:00", "10:00", "11:00",
                "12:00", "13:00", "14:00", "15:00",
                "16:00", "17:00", "18:00", "19:00",
                "20:00", "21:00", "22:00", "23:00", "24:00"],
            datasets: [{
                lineTension: 0,
                label: 'Values',
                data: [0,0,0,0,0,0,5,5,5,5,5,5,5,5,5,5,5,0,0,0,5,5,0,0,0],
                backgroundColor: ['rgba(149, 0, 193, 0.5)'],
                borderWidth: 1
            }]
        },
        elements: {line: {tension: 0}},
        options: {
            bezierCurve : false,
            scales: {yAxes: [{stacked: false, ticks: {fixedStepSize: 1}}]}
        }
    });
因此,我有一个这样的图表(没有红线):


如何使图表JS以直线角显示数据,如以红线显示?

只需添加

steppedLine: true
到您的数据集

另见: