InetSoft BI Software: Making Charts in JavaScript

Looking for free graphing tools? InetSoft provides both free and commercial graphing tools. View a demo and try them out for free.

Visualize Free is a free visual analysis application. No software to install, just upload your spreadsheet.

Style Scope Agile Edition is a free chart product to download and use for your organizational chart needs.

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

Sample JavaScript Code for Making Chart Using Style Intelligence's API

Style Intelligence is InetSoft's commercial charting solution which includes a drag and drop chart designer as well as a JavaScript API for embedding charts in other web-based applications. Below is an excerpt from the API documentation.

RectCoord

The RectCoord object contains rectangular coordinates against which data can be represented. To create a RectCoord object, pass a pair of Scale objects to the RectCoord constructor:

var rect = new RectCoord(xscale,yscale);

You can pass a set of Scale objects (e.g., 'xscale', 'yscale', etc.) to the constructor, or specify this later using the RectCoord.setXScale(scale) and RectCoord.setYScale(scale) properties.

Example (Report or Viewsheet)
 importPackage(inetsoft.graph)
 importPackage(inetsoft.graph.data)
 importPackage(inetsoft.graph.scale)
 importPackage(inetsoft.graph.aesthetic)
 importPackage(inetsoft.graph.element)
 importPackage(inetsoft.graph.coord)
 
 var arr = [["State","Quantity"], ["NJ",200], ["NY",300]];
 dataset = new DefaultDataSet(arr);
 graph = new EGraph();
 var elem = new IntervalElement("State", "Quantity");
 var sscale = new CategoricalScale("State");
 var qscale = new LinearScale("Quantity");
 var coord = new RectCoord(sscale,qscale);
 graph.setCoordinate(coord);
 graph.addElement(elem);
view demo icon
View a 2-minute demonstration of InetSoft's easy, agile, and robust BI software.

RectCoord.setXScale(scale)

Specifies the scale for the X-axis. This can also be specified as an argument to the constructor.

Type
 scale
 a Scale object
Example (Report or Viewsheet)
 importPackage(inetsoft.graph)
 importPackage(inetsoft.graph.data)
 importPackage(inetsoft.graph.scale)
 importPackage(inetsoft.graph.aesthetic)
 importPackage(inetsoft.graph.element)
 importPackage(inetsoft.graph.coord)
 
 var arr = [["State","Quantity"], ["NJ",200], ["NY",300]];
 dataset = new DefaultDataSet(arr);
 graph = new EGraph();
 var elem = new IntervalElement("State", "Quantity");
 var sscale = new CategoricalScale("State");
 var qscale = new LinearScale("Quantity");
 var coord = new RectCoord();
 coord.setXScale(sscale);
 coord.setYScale(qscale);
 graph.setCoordinate(coord);
 graph.addElement(elem);
view gallery
View live interactive examples in InetSoft's dashboard and visualization gallery.

RectCoord.setYScale(scale)

Specifies the scale for the Y-axis. This can also be specified as an argument to the constructor.

Type
 scale
 a Scale object
Example (Report or Viewsheet)
 importPackage(inetsoft.graph)
 importPackage(inetsoft.graph.data)
 importPackage(inetsoft.graph.scale)
 importPackage(inetsoft.graph.aesthetic)
 importPackage(inetsoft.graph.element)
 importPackage(inetsoft.graph.coord)
 
 var arr = [["State","Quantity"], ["NJ",200], ["NY",300]];
 dataset = new DefaultDataSet(arr);
 graph = new EGraph();
 var elem = new IntervalElement("State", "Quantity");
 var sscale = new CategoricalScale("State");
 var qscale = new LinearScale("Quantity");
 var coord = new RectCoord();
 coord.setXScale(sscale);
 coord.setYScale(qscale);
 graph.setCoordinate(coord);
 graph.addElement(elem);
Learn how InetSoft's data intelligence technology is central to delivering efficient business intelligence.

RectCoord.setYScale2(scale)

Specifies the scale for the secondary (right-side) Y-axis.

Type
 scale
 a Scale object
Example (Report or Viewsheet)
 importPackage(inetsoft.graph)
 importPackage(inetsoft.graph.data)
 importPackage(inetsoft.graph.scale)
 importPackage(inetsoft.graph.aesthetic)
 importPackage(inetsoft.graph.element)
 importPackage(inetsoft.graph.coord)
 
 var arr = [["State","Quantity","Total"], ["NJ",200,10000],
            ["NY",300,8000]];
 dataset = new DefaultDataSet(arr);
 graph = new EGraph();
 var elem = new PointElement("State", "Quantity");
 var elem2 = new PointElement("State", "Total");
 elem2.setColorFrame(new
    StaticColorFrame(java.awt.Color.red));
 var sscale = new CategoricalScale("State");
 var qscale = new LinearScale("Quantity");
 var qscale2 = new LinearScale("Total");
 var coord = new RectCoord();
 coord.setXScale(sscale);
 coord.setYScale(qscale);
 coord.setYScale2(qscale2);
 graph.setCoordinate(coord);
 graph.addElement(elem);
 graph.addElement(elem2);
Previous: Free Chart Tools