如何在Chartjs中进行整数缩放 [英] How to make integer scale in Chartjs
问题描述
我正在尝试制作一个带整数刻度的水平条形图。
正如这个问题所示,我试过了设置 scaleOverride
, scaleSteps
等,但似乎没有工作。我试图将它们放在数据集中,在选项中,在xScales中,但没有任何效果。
I'm trying to make a horizontal bar chart with an integer scale.
As suggested in this question, I've tried to set scaleOverride
, scaleSteps
etc, but it seems not to be working. I tried to put them in dataset, in options, in xScales but nothing worked.
这个jsfiddle 显示我试图做的事情。
This jsfiddle shows what I tried to do.
推荐答案
链接的问题是图表。 js版本1.x.对于新版本,您需要使用 ticks
选项。请参阅 http://www.chartjs.org/docs/#scales
The linked question is for Chart.js version 1.x. For the new version you need to use the ticks
option. See http://www.chartjs.org/docs/#scales
...
xAxes: [{
ticks: {
min: 0,
stepSize: 1,
max: 4
},
...
< hr>
小提琴 - https://jsfiddle.net/jkufz1b9/
这篇关于如何在Chartjs中进行整数缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!