-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Round Y-Axis numbers to a Nicer Format #162
Comments
I'd like to see a way to use a function to generate the y labels, or However, the code proposed only changes the label and not the corresponding On Thursday, January 17, 2013, radagaisus wrote:
Adam Pope Tel | 01225 580 500 |
Yes, there's definitely scope to improve this code. Fudging the line numbers is not the right answer though. The graph bounds need to be calculated more intelligently and so do the numLines. |
See also #168. |
Not sure if there's been any work on this but I was looking for an option to only have int numbers on the Y-Axis and couldn't find anything. I'm trying to graph the number of visits a profile had during the last 30 days and numbers on the Y-Axis are coming like [0, 0.3, 0.5, 0.8, 1] when the maximum number of visits for a profile is one. It's weird seeing these numbers as there will never be a 0.8 visit to a profile... |
I'll add it to my todo list. FWIW, I'll be uploading a change with new y-axis labelling this weekend,
|
I've just completed the first round of this work and checked it into master. It'll massage the bounds of the chart to fit a 'friendlier' set of y labels. It won't change the number of grid lines or force non-decimal increments for charts over a very small Y range (like @t3chn0r's problem above), but it should improve rendering for the majority of cases. Before: After: I'll be including this with a v0.4.2 release this week. |
Just grabbed the latest source code. Yes this is MUCH better! |
Awesome dude. The new graphs look great. |
Hi @oesmith, just an update on my previous comment. I was able to "patch" Morris to prevent those fraction numbers in the grid. I did the following, I don't know Coffee script so if you are OK with the changes maybe you or someone else can add the changes to the script: First of all I created a new parameter named "onlyIntegers" defaulting to "false" to maintain compatibility, so the list of variables now look something like this:
Then around line 257 after the ymax value is calculated I added the following lines:
That small piece of code adjust the number of lines in the grid according to the max value of Y. I have tested these changes with all my graphs and everything is working perfectly now. Regards, |
@GrizzlyBearded I've just pushed a fix for the decimal label overflow problem onto master. @t3chn0r I'm not sure that fix will work everywhere (for example, false origins and negative y-values will cause problems). I'll keep thinking about it. |
I'm going to cut a v0.4.2 release now with the new behaviour, so I'll close this. Lets move the integer Y-labels discussion to issue #221. |
I have a quick question. How do you change a decimal mark from 1,000.00 (current) to 1.000,00? @oesmith |
Something like this perhaps? yLabelFormat: function (y) {
var parts = y.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".");
return parts.join(",");
} |
Thank you @t3chn0r I will test it. |
Can i have created this kind of graph (https://user-images.githubusercontent.com/5277834/36530130-15de79fa-17dc-11e8-8815-410bd03fe851.jpeg) But i want to remove the colored area and to be shown like this https://web.whatsapp.com/1c0c1fa7-78d2-4b20-bc80-8afe74489fc0 |
Hi,
So my area chart looks like this:
But the axis numbers are not round and nice numbers people like to see, like 250 and 500. We can tweak this behaviour.
The text was updated successfully, but these errors were encountered: