How to make integer scale in Chartjs(如何在 Chartjs 中制作整数刻度)
问题描述
我正在尝试制作具有整数比例的水平条形图.正如 this question 中的建议,我尝试设置 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.
推荐答案
链接的问题是针对 Chart.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
},
...
<小时>
小提琴 - https://jsfiddle.net/jkufz1b9/
这篇关于如何在 Chartjs 中制作整数刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Chartjs 中制作整数刻度


基础教程推荐
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01