DataSet.getColCount()
|
Returns the number of columns in the dataset.
Example
Chart Component Script
// Create a chart with two elements:
dataset = [["State", "Total", "Profit"],["NJ", 200, 25], ["NY", 300, 150]]; (1)
graph = new EGraph();
var elem1 = new IntervalElement("State", "Total");
var elem2 = new IntervalElement("State", "Profit");
var frame = new StaticColorFrame(java.awt.Color.red);
elem2.setColorFrame(frame);
graph.addElement(elem1);
graph.addElement(elem2);
// Loop through the rows and columns, and place labels on the bars.
for (var i=0; i<dataset.getRowCount(); i++) { (2)
for (var j=0; j<dataset.getColCount(); j++) { (3)
var form = new LabelForm();
form.setColor(java.awt.Color.black);
form.setLabel(dataset.getData(j,i));
form.setValues([dataset.getData(0,i),dataset.getData(j,i)-20]);
graph.addForm(form)
}
}
| 1 | See dataset to use a data block instead of an array literal. |
| 2 | Use DataSet.getRowCount() to get the number of rows. |
| 3 | Use getColCount() to get the number of columns. |

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.
|