charts - 如何从chartjs中的所需点制作虚线?
问题描述
我需要在预设时间段内画一条虚线。我怎样才能在chartjs中做到这一点?例如,实线表示 3 个月,虚线表示其他
下面的错误实现
var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'line',
// The data for our dataset
data: {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [{
label: "Red",
borderColor: 'rgb(255, 0, 0)',
data: [0, 10, 5, 2, 20, 30, 45],
}, {
label: "Blue",
borderColor: 'rgb(0, 0, 255)',
data: [38, 24, 32],
}, {
label: "Blue",
borderColor: 'rgb(0, 0, 255)',
data: [null, null, 32, 0, 0, 0, 0],
borderDash: [5, 5],
}]
},
// Configuration options go here
options: {}
});
.container {
width: 640px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>
<div class='container'>
<canvas id="myChart"></canvas>
</div>
解决方案
推荐阅读
- tensorflow - TensorFlow Timeline 中 GPU_0_bfc 分配器和 GPU_host_bfc 分配器的区别
- google-apps-script - 每个用户的 Google Script addEmailReminder 时间不同
- python - 访问 Python 字典中的项目
- java - 在 Flutter 应用和桌面 Java 应用之间发送/接收数据
- angular - 无法使用角度服务向角度组件显示数据
- javascript - Click 事件在 IE 中不起作用,但在其他浏览器中可以正常工作
- python - Pandas 如何计算协方差矩阵?
- javascript - 如何使用 onchange() 清除 select 中的 innerHTML 选项?
- amazon-web-services - AWS Elastic Beanstalk - Go 示例应用程序
- azure - Azure DNS CNAME 记录