0

I'm using jqplot for represent several parameters in series across the time. So I have one Xaxis represent the time and several Yaxes(yaxis, y2axis, y3axis, y4axis, etc.). Each parameter is in different units(temperature, voltage, current, pressure, etc.), so all the Yaxes set to auto for min and max because I dont know what values will come from the server. I'm using ajax request to fill the data and next for real time updating the series with new points.

So now I want for the user to be able to set manual min and max for any Y-axe. So I set by this way:

var axis_name="y2axis";
console.log(plot.axes[axis_name].max);
var new_max=prompt("Please enter max value?");
console.log(new_max);
var plotOptionsEval = "plotOptions = { axes: { "+axis_name+": { max: \""+new_max+"\" } } };";
eval(plotOptionsEval);
console.log(plotOptions);
plot.replot(plotOptions);
console.log(plot.axes[axis_name].max);

So , when I set new max for the first axis(yaxis) everythins is fine.

But when I try to set the max parameter of any other axis - y4axis for example something gone wrong and that max value has a some different value from this the user is entered.

enter image description here enter image description here enter image description here

This is a debug from console.log output

50
12
axes: y4axis: {max: "12"}
350

Any ideas?

iMarh
  • 189
  • 16

1 Answers1

0

So I have found a solution if someone asking the same.

The trick is you need to set min and max parameters for all Yaxis in your plot. So I have prepared the min/max axes object with its original values:

var plotOptions = {
    axes: {
        yaxis: {min: 11.568, max: 11.582}
        y2axis: {min: 11.688, max: 11.702}
        y3axis: {min: 6.390000000000001, max: 6.53}
        y4axis: {min: -300, max: 50}
    }
}

Next set the desired Yaxis min/max parameter in the plotOptions object:

var new_max=prompt("Please enter max value?");
plotOptions.axes.y2axis.max=parseFloat(new_max);

and finally replot it:

plot.replot(plotOptions);
iMarh
  • 189
  • 16