admin管理员组文章数量:1356003
I have created a line chart in chart.js that plots data from financial markets.
How can I control the width of the gridlines from the x axis?
The data is time based and when the chart starts the space between the gridlines is too big.
As the data is added the chart condenses the space automatically.
I would like to control the spacing to a uniform amount that I can set from the start.
Any help much appreciated.
I have created a line chart in chart.js that plots data from financial markets.
How can I control the width of the gridlines from the x axis?
The data is time based and when the chart starts the space between the gridlines is too big.
As the data is added the chart condenses the space automatically.
I would like to control the spacing to a uniform amount that I can set from the start.
Any help much appreciated.
Share Improve this question edited May 4, 2018 at 10:00 k11k2 2,0442 gold badges24 silver badges37 bronze badges asked May 3, 2018 at 15:01 kmm2908kmm2908 211 gold badge1 silver badge2 bronze badges 5- 1 add your code also – Vikasdeep Singh Commented May 3, 2018 at 15:08
- How would the code help? It's a 2000 line script. – kmm2908 Commented May 4, 2018 at 6:45
-
I haven't yet needed to adjust the
gridLines
except for hiding the horizontal ones. With that said I found this (chartjs/docs/latest/axes/…) within the docs, try play around with theborderDash
property - I think this will help. – Koshux Commented May 4, 2018 at 16:55 - Thanks @Koshux, will try that next – kmm2908 Commented May 5, 2018 at 9:47
- @kmm2908 Hey did you solve this, if so how? I am also having the same problem. – Jereme Commented Jul 2, 2020 at 16:25
3 Answers
Reset to default 7You can set a maximum number of vertical grid lines (for x axis) :
scales: {
xAxes: [{
ticks: {
maxTicksLimit: 20,
},
}]
},
Might not be the best solution but by setting a fix hight or width you can control the max-space between the gridLines
<canvas id="myChart" width="1200px"></canvas>
I've spent a few days trying to solve this exact problem. This video led me to the ultimate solution to this: https://www.youtube./watch?v=XUAP3szj_u8
本文标签: javascriptchartjs control space betweensize of gridlinesStack Overflow
版权声明:本文标题:javascript - chart.js control space betweensize of gridlines - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743977705a2570942.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论