Skip to content
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

NaN string displayed when clicking on legend to hide a horizontal bar chart with Y-axis labels as strings #4216

Closed
singhrasster opened this issue May 2, 2017 · 5 comments · Fixed by #4425

Comments

@singhrasster
Copy link

I have a horizontal bar chart. And my X-axis labels are numbers whereas the Y-axis labels are strings. when I click on the legend to hide the bar chart, the chart is hidden, however I see a string NaN on the top left of the Y-axis. Is it a bug? What is the fix for this?

@etimberg
Copy link
Member

etimberg commented May 2, 2017

@singhrasster do you have a test case that reproduces this?

@singhrasster
Copy link
Author

Yes, so I have a horizontalBar chart where I have 2 categories of bars ( horizontal). The Y-axis labels are strings whereas the X-axis labels are numbers. Since there are two bars, there are two legends created. I click on each legend to hide the corresponding bar. When both bars are hidden (after clicking on the two legends), I see NaN on the top left of the X-axis.

There can be any number of categories of horiontal bars, say N. Whenever all N bars are hidden by clicking on all the corresponding N legends, the string NaN gets displayed left to the Y-axis.

I don't have anything setup online to show exactly. But, on some google search, I came across someone's fiddle where there is a horizontal bar. In that you can click on the Green legend left to the text "Test" to hide the bar. The bar is hidden but then you will see a text 'NaN' displayed to the left of the Y-axis.
Here is the link of the fiddle I mentioned above (again its not setup by me but it shows the issue I am talking about):
https://jsfiddle.net/4r26box7/

@etimberg
Copy link
Member

etimberg commented May 3, 2017

Looks like something goes wrong when there is no data, and the text that shows up should have been on the x axis. Definitely a bug that needs to be fixed

apoorvasrinivasan added a commit to apoorvasrinivasan/Chart.js that referenced this issue May 10, 2017
@singhrasster
Copy link
Author

singhrasster commented May 16, 2017

@etimberg Is this issue fixed now? If yes, how can I use it? Do I need to update my chart.js library to a newer version? Currently I am using "chart.js": "2.5.0", in my package.json

@etimberg
Copy link
Member

@singhrasster this is not yet fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants