DrawXAxis() & DrawYAxis() functions do not properly convert the min and max property values to numbers

Share RGraph:   Share or Like RGraph on Facebook!

« 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 Jason on 25th September 2015
Using RGraph4.31 version (2015-07-24).

I've hit an issue in the DrawXAxis() and DrawYAxis() functions, defined in the RGraph.drawing.xaxis.js and RGraph.drawing.yaxis.js files respectively.

When `min` and `max` values are specified as string data, the values are not converted to a usable format. I've corrected this locally by simply providing a casting to a Number() type.

In RGraph.drawing.xaxis.js:519

var y = this.y;
// @TODO [jtm 20150916] Max/Min not provided as numbers fix
var min = Number(prop['chart.min']);
var max = Number(prop['chart.max']);
var labels = prop['chart.labels'];

In RGraph.drawing.yaxis.js:537

var height = ca.height - this.gutterBottom - this.gutterTop;
// @TODO [jtm 20150916] Max/Min not provided as numbers fix
var min = prop['chart.min'] ? Number(prop['chart.min']) : 0;
var max = Number(prop['chart.max']);
var title = prop['chart.title'] ? prop['chart.title'] : '';

I also corrected a potential error in the YAxis properties when dealing with the `decimals` value, to match what was specified over on the XAxis properties:

var formatter = prop['chart.scale.formatter'];
var decimals = Number(prop['chart.scale.decimals']);
var invert = prop['chart.scale.invert'];
Posted by Richard Heyes on 26th September 2015
Hi there,

Thanks. I've added in conversions to numbers to the properties.



Richard

Add a reply




« Back to message list