Scripting Scorecard Measures in a Chart

InetSoft's reporting solution can be controlled programmatically. The JavaScript-like API permits developers to embed reporting instructions into whatever application they wish. In this example of representing multiple measures on a single chart, simply define a GraphElement object for each measure, and add the GraphElement to the Chart.

Request a Demo
Register for Pricing
#1 Ranking: Read how InetSoft was rated #1 for user adoption in G2's user survey-based index Read More

Consider the following script (Note: Report script that modifies 'graph' should be placed at the element level. See Adding Element-Level Script):

importPackage(inetsoft.graph)
importPackage(inetsoft.graph.element)
importPackage(inetsoft.graph.scale)
importPackage(inetsoft.graph.aesthetic)
importPackage(inetsoft.graph.coord)
importPackage(inetsoft.graph.data)
 
var arr = [["State", "Quantity 1", "Quantity 2"],
      ["NJ",200,500], ["NY",300,1000],
      ["PA",370,440], ["CT",75,20]];
dataset = new DefaultDataSet(arr);
graph = new EGraph();
var elem1 = new IntervalElement("State", "Quantity 1");
graph.addElement(elem1);

This creates a basic bar chart displaying the dimensions 'State' and 'Quantity 1'. To add the measure 'Quantity 2' to the chart as line element, follow the steps below:

  1. Create a new LineElement to represent the graph of 'Quantity 2' vs. 'State'.
var elem2 = new LineElement("State", "Quantity 2");
  1. Assign this new element to the main Chart object.
graph.addElement(elem2);

A legend is created automatically. To modify the legend, make changes to the VisualFrame's LegendSpec property. See Changing Legend Properties.

Previous: Multidimensional Chart