您能告诉我如何在一段时间内在Chartjs中跳过数据吗?例如,我有10-> 11h30 am和1h-> 2h pm的数据。我在时间类型中构建了图表,但是我想从11h30-> 1h或2hpm-> 10h跳过/删除该行。
options = {
responsive: true,
title: {
display: true,
text: 'Chart.js Time Point Data'
},
scales: {
xAxes: [{
type: 'time',
display: true,
stacked: true,
scaleLabel: {
display: true,
labelString: 'Date'
},
ticks: {
major: {
fontStyle: 'bold',
fontColor: '#FF0000'
},
},
}],
yAxes: [{
stacked: true,
display: true,
scaleLabel: {
display: true,
labelString: 'value'
},
}]
},
};
谢谢
那么,chart.js之将展示什么labels
和data
遏制。因此,您可以创建一个函数来删除某个范围。
这是带有折线图的示例:https : //codepen.io/adelriosantiago/pen/xxRGVPW?editors=0010
该函数rangeWithSkips
基本上filter
将是startSkip
和之间的输入数组endSkip
。在代码的后面,您可以使用以下选项选择新范围:
data: {
labels: rangeWithSkips(3, 10).labels, // Pick the starting and end range here
datasets: [
{
label: "Volume",
data: rangeWithSkips(3, 10).data // Pick the starting and end range here too
}
]
}
这是一个更新的版本,与2个输入完全相同:https : //codepen.io/adelriosantiago/pen/yLVNOGX?editors=1011
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句