r1 - 26 Mar 2008 - 03:08:38 - AdrianSong?You are here: TWiki >  Main Web  >  ElixirReport > ElixirReportCookbook > DynamicMeterIntervals

Dynamic Meter Intervals

fig2.15.png

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
Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback