CT.7.2 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:

Note: Script that modifies 'graph' should be placed at the element level. See Adding Element-Level Script in Report Scripting and Adding Component Script in Dashboard Scripting for more information.

var dataset = [["State","Quantity","Total"],["NJ",200,2500],["NY",300,1500]];

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 a linear scale is defined implicitly by the BrightnessColorFrame object. The legend indicates that this default scale runs from 1400 to 2600. To change the scaling to run from 500 to 3000 instead, you must explicitly define a new Scale object.

Follow these steps:

1. Define the desired Scale object explicitly. In this case, create a LinearScale based on the 'Total' field.

var scale = new LinearScale("Total");

scale.setFields("Total");

2. Set the minimum and maximum values of the new Scale object.

scale.setMax(3000);

scale.setMin(500);

3. Assign the new scale to the existing VisualFrame object.

frame.setScale(scale);

 

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

dataset = [["State","Quantity","Total"], ["NJ",200,2500],["NY",300,1500]];

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);

<< CT.7.1 Changing Scaling for Chart Axes © 1996-2013 InetSoft Technology Corporation (v11.5) CT.8 Changing the Appearance of Chart Elements >>