Open jango-fx opened 6 years ago
Hi, do you have a (runnable) example code to demonstrate the issue and the desired behaviour?
i assumed there should be either a Chart.getRange()
-method returning the range set by Chart.setRange(,)
or Chart.getMin()
and Chart.getMax()
would return those values, but they don't seem to do so:
import controlP5.*;
ControlP5 cp5 = new ControlP5(this);
Chart myChart = cp5.addChart("dataflow").setRange(-0.5, 0.5);
println(myChart.getMin() +" / "+ myChart.getMax());
expected: -0.5 / 0.5 returns: 0 / 0
i can call setMin()
/setMax()
as a makeshift solution explicitly myself, though…
import controlP5.*;
ControlP5 cp5;
Chart myChart;
void setup() {
size(300, 200);
cp5 = new ControlP5(this);
myChart = cp5.addChart("dataflow")
.setPosition(50, 50)
.setRange(-0.5, 0.5)
.setView(Chart.LINE)
;
myChart.addDataSet("incoming");
myChart.setData("incoming", new float[100]);
}
void draw() {
background(40);
float val = (float) new java.util.Random().nextGaussian();
myChart.push("incoming", val);
float currentMin = min(myChart.getMin(), val);
float currentMax = max(myChart.getMax(), val);
myChart.setMin(currentMin);
myChart.setMax(currentMax);
myChart.setRange(currentMin, currentMax);
}
but i don't get why Chart.setRange(,)
doesn't seem to access the same _myMin
/ _myMax
as setMax()
/ getMax()
inherited by the Controller class...
Thanks for the example. Fixed in dev-2.2.7 branch
is there no way to retrieve the current range, to update it according to new maximum values?