hi,
it may be arguable if this is a legitimate bug or just bad inputs, but I am using the below as a work-around for a graph that may be missing a few piece of data here and there but still needs to use ScaleProvider = AutoScaler.
Effectively, it just does a few extra null checks.
it will be excellent if this can be incorporated in a future release.
thanks
Code:
public class ChartModel2 extends ChartModel{
private static final long serialVersionUID = 2901294110823219742L;
public ChartModel2() {
super();
}
public ChartModel2(String titleText, String style) {
super(titleText, style);
}
public ChartModel2(String titleText) {
super(titleText);
}
@Override
public void updateYScale() {
ScaleProvider scaleProvider = this.getScaleProvider();
if (scaleProvider != null) {
Double max = null;
Double min = null;
for (ChartConfig config : getChartConfigs()) {
DataProvider provider = config.getDataProvider();
if (provider != null) {
try{
double maxYValue = provider.getMaxYValue();
max = max == null ? maxYValue : Math.max(max, maxYValue);
}catch(Exception e){}
try{
double minYValue = provider.getMinYValue();
min = min == null ? minYValue : Math.min(min, minYValue);
}catch(Exception e){}
provider.maxYValue = null;
provider.minYValue = null;
}
}
if (min==null || max==null) {
return ; //no need to auto-scale anything
}
Scale scale = scaleProvider.calcScale(min, max);
YAxis yAxis = getYAxis();
if (yAxis == null) {
yAxis = new YAxis();
setYAxis(yAxis);
}
yAxis.setMin(scale.getMin());
yAxis.setMax(scale.getMax());
yAxis.setSteps(scale.getInterval());
}
}
}