CategoricalColorFrame.getColor(val)
Returns the color assigned to the specified value, val. The corresponding “setter” function is CategoricalColorFrame.setColor(val,color).
Example 1
Chart Component Script
dataset = [["State","Quantity"],["NJ",200],["NY",300]]; (1)
graph = new EGraph();
var elem = new IntervalElement("State", "Quantity");
frame = new CategoricalColorFrame(); (2)
frame.setField("State");
frame.setColor('NJ',java.awt.Color(0xff0000));
var NJcolor = frame.getColor('NJ'); (3)
frame.setColor('NY',NJcolor); (4)
elem.setColorFrame(frame); (5)
graph.addElement(elem);
| 1 | See dataset to use a data block instead of an array literal. |
| 2 | Create the ColorFrame object. |
| 3 | Use getColor to obtain the color for ‘NJ’. |
| 4 | Use setColor to assign the ‘NJ’ color to ‘NY’. |
| 5 | Use GraphElement.setColorFrame(frame) to add the ColorFrame to the Chart. |

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) ① to obtain a handle to the desired GraphElement object. For example:
|
Example 2
This example illustrates how to use bindingInfo properties to control the ColorFrame.
-
Bind a Bar Chart to the sample ‘All Sales’ Data Worksheet, with ‘Company’ (top 5) on the X-axis, and Sum(Total) on the Y-axis.
The ‘All Sales’ Data Worksheet can be found in the 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. -
Add the following script in the onRefresh handler. (See Add Dashboard Script.)
onRefresh ScriptChart1.bindingInfo.setColorField("Employee",Chart.STRING); Chart1.bindingInfo.colorFrame = new CategoricalColorFrame; Chart1.bindingInfo.colorFrame.setColor("Robert",java.awt.Color.lightGray); var robColor = Chart1.bindingInfo.colorFrame.getColor("Robert"); Chart1.bindingInfo.colorFrame.setColor("Sue",robColor);
Dashboard script that modifies bindingInfoshould generally be placed in the onRefresh handler. See Add Dashboard Script.