-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not displaying tick zero value in callback for radar chart with scale's min below zero #11503
Comments
Hi Megaemce, I attempted to fix this as my first contribution to Chart.js and found the issue in the file src/scales/scale.radialLinear.js. The code skips ticks[0] at lines 581 and 648, which appears to always be the lowest value tick. They have included this to skip the 0th tick of auto generated ticks in radial graphs to not have a label at the center of the graph. I've made a fix for it in my own forked repo, but find it unlikely that they will merge the pull request because it may break other people's projects. You can check out my fix at https://github.com/finnegantdewitt/Chart.js. A work around I'd recommend is including another if in the callback for the lowest value. That should stop it generating all those extra lines that the return without an if makes. |
Thank you for you support @finnegantdewitt. There should be a logic here that if the min is set below 0 then this tick should be displayed. I am not so sure about using if (index !== 0 || (index === 0 && this.min < 0)) {
offset = this.getDistanceFromCenterForValue(tick.value);
const context = this.getContext(index);
const optsAtIndex = grid.setContext(context);
const optsAtIndexBorder = border.setContext(context);
drawRadiusLine(this, optsAtIndex, offset, labelCount, optsAtIndexBorder); Can you give it a try and see if there is no errors (for example from
That is why we use github and versioning bro! |
Maybe it would be best to not display based off the |
I just mentioned getDistance... as a reference to thorough code review before creating a merge request. The getDistance actually should make no harm here. I just briefly checked getContex(index) and setContext and in my undestand this should make no issues at all. Just try out my solution on your own device and if it works - make a merge request |
@finnegantdewitt you were right. I changed both lines and did pull request (#11682) which should fix this issue. |
Expected behavior
By default when creating radar chart the tick's zero value is not displayed.
However when the scale's min value is changed it's shown again. When user set a tick's callback, the zero should be handled and displayed just like any other value.
Current behavior
When tick's callback is set the zero value will not be shown. The only possible (and dirty) workaround is to return all the values like so:
Reproducible sample
https://codepen.io/kowal66b/pen/vYvJryv
Optional extra steps/info to reproduce
No response
Possible solution
No response
Context
I want show only limited amount of ticks with zero value as well
chart.js version
4.4.0
Browser name and version
No response
Link to your project
www.correlations.world
The text was updated successfully, but these errors were encountered: