Working on Entando / Pentaho integration, one of the customer request was :
"I needed to be able to change the minimum and maximum Y-axis at run time."
- Below the solution I've used:
- create reports
- insert the chart
- open the properties window
- in the scripting language choose BeanShell
- insert the following script
"
import org.jfree.chart.*;
import org.jfree.chart.axis.NumberAxis;
import java.lang.Double;
data = runtime.getData();
minVal =999999.0;
maxVal = 0.0;
for (int i=0;i latteProd = data.getValueAt(i,2);
if(latteProd < minVal){
minVal = latteProd;
}
if(latteProd > maxVal){
maxVal = latteProd;
}
}
xyPlot = chart.getPlot();
NumberAxis domain = (NumberAxis) xyPlot.getRangeAxis();
domain.setRange((minVal - (minVal*.10)), (maxVal+ (maxVal*.10)));
"