Dynamic Meter Intervals
From version 7.2 onwards, intervals within a meter can be dynamically determined based on the minimum and maximum values retrieved from a table. To implement this function, create a data table and a meter. Right click on the meter, select Properties to access the Edit Content dialog box. Click on Next until you come to the Meter section and click on the Script tab.
Key in the following code, making modifications to it based on your requirements accordingly:
importClass(Packages.org.jfree.chart.plot.MeterInterval);
importClass(Packages.org.jfree.data.Range);
println("A");
if (cxt!=null)
{
println("B");
var ds = cxt.getDataSource();
println(ds);
println(ds.getRecordCount());
if (ds.getRecordCount()>0)
{
println("Got record");
var rec = ds.getRecord(0);
var min = rec.getData(ds.getColumnIndex("Min"));
var max = rec.getData(ds.getColumnIndex("Max"));
var name = rec.getData(ds.getColumnIndex("Person"));
var range = new Range(min,max);
plot.setRange(range);
plot.addInterval(new MeterInterval(name,range));
}
}
--
AdrianSong? - 26 Mar 2008