触发条件后,我不想在两个点之间画线。
我正在使用chartjs作为时间线图。
我的条件是当y
值减小时不画线,因此在此示例中,当其值从7变为1时
{x:3.5*3600,y:7},Do not draw line between these two points
{x:4*3600,y:1},
是否可以使用chartjs线形时间图?
var canvas = document.getElementById('myChart');
var config = {
"options": {
"scales": {
"xAxes": [
{
"type": 'time',"time": {
"unit": 'minute',"unitStepSize": 60,},"distribution": 'linear',"bounds": 'ticks',"ticks": {
"source": 'auto',"autoSkip": true,"stepSize": 10
}
}
],"data": {
"labels": ['2016-04-18T00:00:00Z','2016-04-18T23:59:00Z'],"datasets": [
{
"label": "line","type": "line","backgroundColor": "#00b","borderColor": "#00b",//"yAxisID": "axis4","borderWidth": 1,"fill": false,"data": [
{x:"2016-04-18T01:00:00Z",{x:"2016-04-18T04:00:00Z",y:2},{x:"2016-04-18T06:00:00Z",y:3},{x:"2016-04-18T08:00:00Z",{x:"2016-04-18T10:00:00Z",{x:"2016-04-18T14:00:00Z",]
},]
},};
var myBarChart = Chart.Line(canvas,config);
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.0/Chart.bundle.min.js"></script>
<canvas id="myChart" width="400" height="200"></canvas>
更新
我尝试在两个项目之间添加{x:null,y:null}
或null
,但出现此错误
Error: 0 and 1461023970000 are too far apart with stepSize of 60 minute
我的选择是:
"data": [
{x:"2016-04-18T01:00:00Z",{x:null,y:null},]
...
xAxes: [
{
type: 'time',time: {
unit: 'minute',unitStepSize: 60,parser: function(date) {
return moment(date).toLocaleString();
}
},distribution: 'linear',bounds: 'ticks',ticks: {
source: 'auto',autoSkip: true,stepSize: 10
}
}
],
就像chartjs认为null为大值一样