javascript ChartJS 设置 yAxes“刻度线”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49392688/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 08:34:03  来源:igfitidea点击:

ChartJS set yAxes "ticks"

javascripthtmlcsschart.js

提问by Bryce Snyder

I am trying to adjust the scales on my yAxes and cannot find any information that isn't outdated.

我正在尝试调整 yAxes 上的比例,但找不到任何未过时的信息。

Basically, I want my yAxes to go from 0 - 100 with steps of 25.

基本上,我希望我的 yAxes 从 0 到 100,步长为 25。

https://codepen.io/brycesnyder/pen/wmJKyv

https://codepen.io/brycesnyder/pen/wmJKyv

            yAxes: [
                {
                    ticks: {
                        beginAtZero: true,
                        steps: 10,
                        stepValue: 10,
                        max: 100
                    }
                }
            ]

回答by JTM

To do this, change stepValue: 10to stepSize: 25, and remove steps: 10,.

为此,请更改stepValue: 10stepSize: 25,然后删除steps: 10,

See chart.js docs

参见 chart.js 文档