Changing chart Y axis max min value distorts the chart


« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by wrox on 1st September 2015
Hey There,

In one of use case we want to change chart y-max and Y-min value. changing it display chart with wrong plotting.

For Example :
Case : Need to display data more clearly

Data : Want to plot [20.2345,20.5674,20.7892,20.2346]

so we change Y-Max = 21 and Y-Min = 19

but the values displayed being distorted. 20.2345 displayed on chart should be very near to Y-Axis 20 label line but it seems its more then it.

Thanks
Gaurav Teli




 
Posted by Richard on 1st September 2015
Hi,

How about this:

www.rgraph.net/fiddle/view.html/a-line-chart-with-a-small-range


Richard
If RGraph has helped you - please share the website and give your feedback - thanks!
Posted by wrox on 4th September 2015
Hi Richard,

Is there some way to set yMax and yMin automatically according to data ?
Posted by Richard Heyes on 4th September 2015
Hi there,

Not rally. Though I suppose you could do this:

// Say your maximum value in your data is 9
var maximum = 9;
var scale = RGraph.getScale2(obj, {
     max: maximum
});
var maximum = scale.max;
alert(maximum);

Like this example:

www.rgraph.net/fiddle/view.html/a-line-chart-getting-the-max

Then set the ymax option to that value. For ymin you could round your numbers down I guess. Say you have 21.2:

1. Times it by ten - giving you 212
2. Round it to the nearest hundred (for example) giving you 200
3. Divide it by ten.
4. You end up with 20.

Something like that perhaps.

Richard
If RGraph has helped you - please share the website and give your feedback - thanks!

Add a reply

 




« Back to message list
RGraph on social media