[Meter Chart] Change Needle Color Based On Value Example 2

This recipe shows how to change needle color based on Value Example 2.

Major steps include the following:

  1. Create a blank report template (hosts.rml) using the datasource (cpu.ds).
  2. Add a Meter Half Chord chart in the blank area under “Section Header”.
  3. Enter the following script in the “Script” tab page:if (cxt!=null)
    {
    var Data = cxt.getData();
    var value = Data.getMax(“Value”).getValueOverGroup();
    var str2 = Data.getMax(“STR2”).getValueOverGroup();
    if (value>str2) plot.setNeedlePaint(java.awt.Color.red);
    else plot.setNeedlePaint(java.awt.Color.blue);
    }

MeterChart-ChangeNeedleColorBasedOnValueEg2

To download the necessary files for this recipe, refer to the attached ZIP package.
ChangeNeedleColorBasedOnValueEg2.zip (4.6 KB)