uneven distribution of xaxis time scale with 'autoSkip:true' and maxTicksLimit
See original GitHub issueHere initially gap is 5 days but at end it gets increased and data is cluttered at the end of the scale. Data:
"x_axis": [
1465084800000,
1466553600000,
1467417600000,
1470096000000,
1471651200000,
1472083200000,
1472688000000,
1472774400000,
1473033600000,
1473120000000,
1473206400000
],
"y_axis": [
1,
2,
4,
2,
3,
2,
3,
2,
4,
1.8,
1.3
]
and options set are
ticks: {
autoSkip:true,
maxTicksLimit:20,
maxRotation:30
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:12 (4 by maintainers)
Top Results From Across the Web
How can I evenly distribute ticks when using maxTicksLimit?
This solution works most of the time, but still occasionally has a wider gap for the last column. I have a graph that...
Read more >Linear Axis - Chart.js
The linear scale is used to chart numerical data. It can be placed on either the x or y-axis. The scatter chart type...
Read more >How to make an XY graph with a time-scale on the X axis ...
When creating an XY data table (and graph), Prism allows the entry of date/time information either in the form of total elapsed time...
Read more >Customize X-axis and Y-axis properties - Power BI
Screenshot of the Visualizations pane and an empty stacked column chart. To set the X-axis values, from the Fields pane, select Time > ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@etimberg This problem also affects category scale, not just time scale.
This bug is an “emergent behavior” of how the tick skipping is performed. If the number of plot points on the x axis is evenly divisible by the number of labels Chart.js decides to render, then the gap will not appear.
A contributing factor is the insistence on always plotting the last tick mark. Perhaps this should be an option that can be disabled. What I would like is interpolation and nearest neighbor matching for tick placement.
So, maybe there needs to be a config option like:
I was able to work around it and get a more aesthetically pleasing plot (in my opinion) by making the following change to Chart.js. Locate the _autoSkip() function and replace:
with
Still an issue in ChartJS 2.7.0, with the new time series options. Here’s a sample of my options for my time series graph.
Here’s a screenshot of what my graph looks like;
Penultimate tick still missing here. I would look into submitting a PR with a fix but I don’t have the time 😦