StaticColorFrame.setNegativeColor(value)

Specifies the static color to be used for negative field values . If a value is specified by setNegativeColor(), then StaticColorFrame.setColor(value) defines the color of positive values, and setNegativeColor() defines the color of negative values. In this case, the inherited VisualFrame.setField(field) value is not used. You can also set this using the bindingInfo.colorFrame.color property syntax in onRefresh script . See Example 2 below. The corresponding “getter” function is getNegativeColor().

Paramater (Function Syntax)

value

a java.awt.Color object

Value (Property Syntax)

number (hex)          Example: 0xFF0000
string (color name)   Example: 'red'
array [r,g,b]         Example: [255,0,0]
JSON {r:_,g:_,b:_}    Example: {r:255,g:0,b:0}
java.awt.Color        Example: java.awt.Color.BLUE (BLACK, CYAN, DARK_GRAY,
                               GRAY, GREEN, LIGHT_GRAY, MAGENTA, ORANGE,
                               PINK, RED, WHITE, YELLOW)

Example 1

Chart Component Script
dataset = [["State", "Quantity"], ["NJ",200], ["NY",-300]];graph = new EGraph(); (1)
var elem = new IntervalElement("State", "Quantity");
var frame = new StaticColorFrame(); (2)
frame.setField("Quantity");
frame.setColor(java.awt.Color(0x00ff00));
frame.setNegativeColor(java.awt.Color(0xff0000)); (3)
elem.setColorFrame(frame); (4)
graph.addElement(elem);
1 See dataset to use a data block instead of an array literal.
2 Create the StaticColorFrame object.
3 Use setNegativeColor to specify the negative color for the StaticColorFrame.
4 Use GraphElement.setColorFrame(frame) to add the ColorFrame to the Chart.

StaticColorFrameNegative2

Script that modifies the graph or dataset properties should be placed on the Chart component itself. See Add Component Script for more information. This script has access to the Chart data and Chart API methods. Scripted Charts are not good candidates for user-modification, so you should deselect ‘Enable Ad Hoc Editing’ in the Chart Properties dialog box.

To change the property on a Chart that was previously created with the Chart Editor, use “getter” methods such as EGraph.getElement(index) ① and GraphElement.getColorFrame() ② to obtain a handle to the desired GraphElement and ColorFrame objects. For example:

var elem = graph.getElement(0);  (1)
var frame = elem.getColorFrame(); (2)
// Compact syntax: var frame = graph.getElement(0).getColorFrame();

frame.setColor(java.awt.Color(0x00ff00));
frame.setNegativeColor(java.awt.Color(0xff0000));

Example 2

This example illustrates how to use bindingInfo properties to control the ColorFrame.

  1. Bind a Bar Chart to the sample ‘All Sales’ Data Worksheet.

    The ‘All Sales’ Data Worksheet can be found in the Data Worksheet  Sample Queries folder. You may need to download the examples.zip file from GitHub into your environment. (This requires access to Enterprise Manager.) See Import and Export Assets for instructions on how to import.
  2. Place ‘Order Date’ on the X-axis. Press the ‘Edit Dimension’ button dimension setting next to the ‘X’ region and set ‘Level’ to ‘Quarter’. Press the ‘Apply’ button submit.

  3. Place ‘Total’ on the Y-axis. Press the ‘Edit Measure’ button measure setting next to the ‘Y’ region and select ‘Change from Previous’ from the ‘Trend and Comparison’ menu. Press the ‘Apply’ button submit.

  4. Place ‘Total’ also in the ‘Color’ region. Press the ‘Edit Measure’ button measure setting next to the ‘Color’ region, and select ‘Change from Previous’ from the ‘Trend and Comparison’ menu. Press the ‘Apply’ button submit.

  5. Add the following script in the onRefresh handler. (See Add Dashboard Script.)

    onRefresh Script
    Chart1.bindingInfo.colorFrame = new StaticColorFrame;
    Chart1.bindingInfo.colorFrame.color = 0x00FF00;
    Chart1.bindingInfo.colorFrame.negativeColor = 0xFF0000;

    StaticColorFrameNegative3

    Dashboard script that modifies bindingInfo should generally be placed in the onRefresh handler. See Add Dashboard Script.