CategoricalLineFrame

The CategoricalLineFrame object contains a unique line style for each discrete value. To create a CategoricalLineFrame object, call the CategoricalLineFrame constructor.

var frame = new CategoricalLineFrame('Quantity');

You can pass the name of a field (e.g., ‘Quantity’) to the constructor, or specify this later using the inherited VisualFrame.setField(field) property. You can also assign a LineFrame using the bindingInfo.lineFrame property in onRefresh script. See Example 2 below.

CategoricalLineFrame provides the special CategoricalLineFrame.setLine(val,line) method.

Example 1

Chart Component Script
dataset = [["State", "Quantity"],["NJ",300],["NY",200],["PA",100]]; (1)
graph = new EGraph();
var elem = new IntervalElement("State", "Quantity");
var frame = new CategoricalLineFrame(); (2)
frame.setField("State"); (3)
elem.setLineFrame(frame); (4)
graph.addElement(elem);
1 See dataset to use a data block instead of an array literal.
2 Create the LineFrame object.
3 Use setField to specify the field for the CategoricalLineFrame.
4 Use GraphElement.setLineFrame(frame) to add the LineFrame to the IntervalElement.

CategoricalLineFrame2

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:

var elem = graph.getElement(0); (1)
var frame = new CategoricalLineFrame();
frame.setField("State");
elem.setLineFrame(frame);

Example 2

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

  1. 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 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. Add the following script in the onRefresh handler. (See Add Dashboard Script.)

    onRefresh Script
    Chart1.bindingInfo.setShapeField("Employee",Chart.STRING);
    Chart1.bindingInfo.lineFrame = new CategoricalLineFrame;
    Chart1.bindingInfo.lineFrame.setLine('Robert', GLine.LARGE_DASH);
    Chart1.bindingInfo.lineFrame.setLine('Eric', GLine.LARGE_DASH);
    Chart1.bindingInfo.lineFrame.setLine('Sue',GLine.DOT_LINE);
    Chart1.bindingInfo.lineFrame.setLine('Annie', GLine.DOT_LINE);

    CategoricalLineFrame

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