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.

StyleBI offers a JavaScript API for developers to embed dashboard charts into their apps.

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);

More Articles About Charting

Business Intelligence Vision - Once that is done the next step is still not technological. The next step is coming up with a business intelligence vision. Business intelligence is never a tactical project, never a tactical implementation. It is always a road map. It is typically takes no less than 2 or 3 years to implement the comprehensive enterprise wide, business intelligence environment. So it has to be vision. There has to be a strategy, a vision of the ultimate target state and a very clearly defined set of steps or phases with dependencies on how to get there. Once that is defined at that point, I say now you are ready to start evaluating the business intelligence tools because now you have a very clear set of steps and a clear set of requirements...

Calibration Completion Time - Reducing downtime and preserving operational continuity need efficient calibration procedures. One important indicator of how fast instruments are calibrated after the procedure is started is the calibration completion time. Organizations may find bottlenecks in the calibration procedure and put in place steps to increase efficiency by analyzing this KPI. Reduced operational interruptions and higher output are often the results of quicker calibration completion times...

Choosing the Right Workflow Dashboard - When selecting a workflow dashboard, it's essential to consider your specific needs and requirements. There are numerous choices on the market, each with specific characteristics and capabilities. Some popular workflow dashboard tools include: Trello Asana Monday.com Jira Basecamp Before making a decision, evaluate each tool's features, integrations, user interface, and pricing plans. To make an informed decision that fits your workflow and business goals, look for reviews and suggestions from reliable sources...

How to Make a Radar Chart - To create a radar chart in InetSoft, drag a Chart component from the Toolbox panel into a dashboard in Visual Composer, and then press the Edit button to open the Chart Editor. create radar chart step 1 Press the 'Select Chart Style' button. Choose the Radar or Filled Radar style and press 'Apply'...

Previous: Free Chart Tools