【发布时间】:2020-11-24 16:18:11
【问题描述】:
我目前正在练习使用 Chart.js 制作图表。 问题是我想制作一个如下图: enter image description here
我能够制作水平虚线,但我不知道如何处理垂直虚线。 我写到现在的代码如下:
var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
type: 'line',
data: {
labels: ['0', '1', '2', '3', '4', '5', '6'],
datasets: [{
label: 'My First dataset',
backgroundColor: 'transparent',
borderColor: 'rgb(0, 0, 0)',
data: [0, 10, 20, 30, 40, 50, 60]
},{
label: 'My First dataset2',
backgroundColor: 'transparent',
borderColor: 'rgb(0, 0, 0)',
data: [60, 50, 40, 30, 20, 10, 0]
},{
backgroundColor: 'transparent',
borderColor: 'rgb(0,0,0)',
data: [30, 30, 30, 30],
borderDash: [10, 5]
}]
},
// Configuration options go here
options: {
title:{
display: true,
text: 'Demand and Supply'
},
legend:{
display: false
}
}
});
【问题讨论】:
标签: javascript html graph chart.js