[英]Set Minimum date for X Axis in scatter plot ChartJS
When I pass my data points with a numerical value for the Y coordinate and a date value for the x coordinate the scatter plot starts the x axis at 1976 even though my earliest date is 2018. How can I set the x axis starting value?当我使用 Y 坐标的数值和 x 坐标的日期值传递我的数据点时,散点图从 1976 年开始 x 轴,即使我最早的日期是 2018 年。如何设置 x 轴的起始值? Here is what my data and options look like.
这是我的数据和选项的样子。 Date Format: 2018/06/30
日期格式:2018/06/30
data: {
datasets: [{
label: 'Scatter Dataset',
data: [{
x: 10,
y: ‘2018/06/30’
}, {
x: 0,
y: ‘2018/06/01’
}, {
x: 100,
y: ‘2018/06/04’
}]
}]
}
options: {
scales: {
xAxes: [{
type: 'time',
ticks: {
suggestedMin: ‘2018/01/01’,
}
}]
}
}
I have trying passing new Date('2018/01/01') to the suggestedMin, I have also tried using Min instead of suggestedMin.我尝试将 new Date('2018/01/01') 传递给SuggestedMin,我也尝试使用Min而不是suggestMin。
We can add minimum starting point on x axis like this,我们可以像这样在 x 轴上添加最小起点,
data: {
datasets: [
{
label: 'Scatter Dataset',
data: [
{
x: 10,
y: ‘2018/06/30’
}, {
x: 0,
y: ‘2018/06/01’
}, {
x: 100,
y: ‘2018/06/04’
}
]
}
]
},
options: {
scales: {
xAxes: [{
type: 'time',
ticks: {
suggestedMin: '2018/01/01',
},
time: {
min:2018/01/01,
max:2028/02/02
}
}]
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.