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 中制作整数刻度


基础教程推荐
- fetch 是否支持原生多文件上传? 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01