Я строю данные на графике с диаграммой js. Раньше это работало, но я не знаю, почему я постоянно получаю uncaught exception: 0 and 1587533402000 are too far apart with stepSize of 1 hour
, хотя ни 0, ни 1587533402000 не являются частью данных, которые я строю.
Вот как я строю график:
var chart_temperature = new Chart(ctx_temperature, {
// The type of chart we want to create
type: 'line',
// The data for our dataset
data: {
labels: timeXValues,
fill: false, // no inner color
datasets: [{
label: 'Temperature',
borderColor: 'rgb(255, 99, 132)',
data: temperatureData
}]
},
// Configuration options go here
options: {
responsive: true,
layout: {
padding: {
bottom: 50
}
},
elements: {
point: {
radius: 0 // don't show points
},
line: {
fill: false
}
},
scales: {
xAxes: [{
type: 'time',
time: {
unit: 'hour',
displayFormats: {
hour: 'DD/MM/YYYY HH:mm'
}
},
ticks: {
beginAtZero: false // tried true, and also removed all this as it used to be
}
}],
yAxes: [{
scaleLabel: {
display: true,
labelString: 'T°C'
}
}]
},
showLines: true, // the points will be connected
// Optimization
animation: {
duration: 0 // general animation time
},
hover: {
animationDuration: 0 // duration of animations when hovering an item
},
responsiveAnimationDuration: 0 // animation duration after a resize
}
});
Почему график js использует 0, тогда как график не начинается с 0? Где я должен смотреть?
Любая помощь приветствуется :-)
Редактировать:
Комментирование следующей строки (в scales.xAxes
) делает отображаемая диаграмма:
// type: 'time',
Но ось X становится бесполезной, поскольку отображаются метки времени.