InetSoft Technology: Executive Dashboard API

Changing Scaling for a VisualFrame

A VisualFrame object contains information about how data values are mapped to physical properties of chart elements. For example, a BrightnessColorFrame contains information about how data values in a field map to the brightness of corresponding chart elements. Mappings of this type require a Scale.

To change the scaling of a VisualFrame object, simply assign a new Scale to the VisualFrame. For example, consider the following chart:

 importPackage(inetsoft.graph)
 importPackage(inetsoft.graph.element)
 importPackage(inetsoft.graph.scale)
 importPackage(inetsoft.graph.aesthetic)
 importPackage(inetsoft.graph.data)
   var arr = [["State","Quantity","Total"],
            ["NJ",200,2500],
            ["NY",300,1500]];
 dataset = new DefaultDataSet(arr);
 graph = new EGraph();
 var elem = new IntervalElement("State", "Quantity");
 var frame = new BrightnessColorFrame();
 frame.setField("Total");
 frame.setColor(java.awt.Color(0xff0000));
 elem.setColorFrame(frame);
 graph.addElement(elem);

Note that in this chart the IntervalElement object implicitly defines a linear Y-axis scale. However, the data values on the chart are widely different in magnitude, which suggests that a log scale might be more appropriate.




BI Demo

Register

Follow these steps:

  1. Define the desired Scale object explicitly. In this case, create a LinearScale based on the 'Total' field.
  2.  var scale = new LinearScale("Total");
     scale.setFields("Total");
  3. Set the minimum and maximum values of the new Scale object.
  4.  scale.setMax(3000);
     scale.setMin(500);
  5. Assign the new scale to the existing VisualFrame object.
  6.  frame.setScale(scale);

The complete script with the new VisualFrame scaling looks like this:

 importPackage(inetsoft.graph)
 importPackage(inetsoft.graph.element)
 importPackage(inetsoft.graph.scale)
 importPackage(inetsoft.graph.aesthetic)
 importPackage(inetsoft.graph.data)
   var arr = [["State","Quantity","Total"],
            ["NJ",200,2500],["NY",300,1500]];
 dataset = new DefaultDataSet(arr);
 graph = new EGraph();
 var elem = new IntervalElement("State", "Quantity");
 var frame = new BrightnessColorFrame();
 frame.setField("Total");
 frame.setColor(java.awt.Color(0xff0000));
 var scale = new LinearScale("Total");
 scale.setFields("Total");
 scale.setMax(3000);
 scale.setMin(500);
 frame.setScale(scale);
 elem.setColorFrame(frame);
 graph.addElement(elem);