dataset
|
Bind Data to Chart in Script for various approaches to binding data to a chart. |
The dataset object allows you to set the values to be displayed on the graph. It has the form of a two-dimensional array, where each column represents a distinct measure, and offers the following methods:
You can specify the dataset by one of the following methods:
-
Set the Chart binding using the Chart Editor.
-
In script, assign a JavaScript array to the
datasetproperty.dataset = [["State", "Quantity"],["NJ", 200],["NY", 300],["PA", 370],["CT", 75]]; -
In script, assign a Data Worksheet result (e.g., ‘AllSales’) to the dataset property.
dataset = runQuery("ws:global:Examples/AllSales");See Run a Query from Script and Create a Chart with API for details about using runQuery.
The dataset object is also accessible for reading. See the DataSet.getData(column,row) method for more information. However, in many cases, the data property provides more convenient access to Chart data.
Example
dataset = [["State","Quantity"], ["CA",200], ["NY",3000]];
graph = new EGraph();
var elem = new IntervalElement("State", "Quantity");
graph.addElement(elem);
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.
|