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
Line charts shows no data when all values are equal #76
Comments
+1 it's also true for Bar/Radar charts. |
This is a bit of a tricky one - how would you expect this to render? Basically Chart.js doesn't know whether your range of data should be 0 - 2 and your data should fit in the middle, or if your range should be 0-100 and your values are very low. If you know your universe of data you could hard code your Y scales? |
i would expect that the line is exactly in the middle... |
that would be my solution:
that should always draw a line in the middle. |
Something like that would work, yeah. To make your solution a bit more robust, I'd suggest perhaps flooring your min value so you don't end up with scales that have awkward decimal places. When it creates a dynamic scale it does a little bit of logic to ensure you get a nice even spread of scale values that cover your min and max values and makes sure the amount of steps fits nicely into the available canvas size. The issue is there is no way of knowing for each instance what range we should apply. I could some logic to figure out if the range of values is 0, and then put in a range of double what the repeated value is? So for this test case use 2 as a range? |
I just tried your workaround, and it does show a line, but always 1 scaleStep BELOW the actual value. |
I also just tried the workaround; as a complete neophyte, it took a little research to get working right (which should have been obvious) Instead of: var min = _.max(chartData.datasets[0].data) I had to use: var min = Math.max(chartData.datasets[0].data) I know, silly, but others like me might read this and benefit from it. |
I can't make the workaround of @fluxsaas works, even with the @bradmalloy's addition. Maybe I'm doing something wrong. Could someone explain me please ? I'd like to make it work and pull a request. Thanks |
Hello friends, I would like to ask where should I paste this fix? In my website I use Charts.js + https://github.com/arifLogic/respChartJS I'm not sure if it is correct, chartjs-option.js:
*/ function respChart(selector, data, options){
} Well, that solutions doesn't work for me. It seems to me that I pasted code in the wrong section. Let me know how to make it proper. |
Hey anyone can help me to fix it? I am not sure what is wrong and how to use your solution. :P Please answer my question. |
@fluxsaas Thanks man, this is great fix for me. |
Thanks for the fix! Keep in mind this works only if you have one series (i.e. only datasets[0]). |
Just got this fixed for my project and wanted to throw this out there in case anyone ran into it... My dataset was [2, 2], but when I tried to use Math.min() and Math.max(), it gave me "not a number" because apparently those were strings (even though I used parseInt when I populated that array). I just added code to my "for" loop where I created the array to give me the min and max. Worked like a charm! |
I used Charts.js + https://github.com/arifLogic/respChartJS |
@fluxsaas working for me too 👍 |
I am not able to reproduce this problem using the new version release candidate. Could you please check if this has been fixed and close or create a JSBin showing the issue. Thank you |
Behaviour in the latest version is to put in a difference of 1 if all the values are the same as suggested. |
Jup. Hasn't changed since #76 (comment) |
Hello, |
This is fixed in #898 |
Thanks, I have updated and its works fine. On Thu, Jan 29, 2015 at 4:25 AM, Evert Timberg notifications@github.com
|
When you have a growing data set that only changes every couple of minutes and the first values are always identical, the line chart will not show anything until a value changes. For testing use this code:
The text was updated successfully, but these errors were encountered: