我正在使用Chart.js horizontalBar。
我需要从自定义值启动图表,而不是数据中的零或最小数字,但无法找到任何方法来实现此目的。
beginAtZero: true // I need this to start not from zero, but from my predefined value.
答案 0 :(得分:0)
您可以为每个轴设置一个最小值和最大值,在这种情况下,您应该为xAxes设置它。
options: {
scales: {
xAxes: [{
ticks: {
Min: 5,
Max: 10,
}
}]
}
}
还可以设置如果数据集数据超过值将被忽略的建议的建议值和建议的值
options: {
scales: {
xAxes: [{
ticks: {
suggestedMin: 5, // If the actual min value in your dataset is minor of 5, this property will be ignored
suggestedMax: 10, // If the actual max value in your dataset is major of 10, this property will be ignored
}
}]
}
}
检查Documentation以获得更多信息