Using InetSoft's API to Draw a Graph

The FacetCoord object contains a set of inner and outer coordinates on which multidimensional data can be represented as nested charts. To create a FacetCoord object, pass a pair of RectCoord objects to the FacetCoord constructor:

var rect = new FacetCoord(outerCoord,innerCoord);
#1 Ranking: Read how InetSoft was rated #1 for user adoption in G2's user survey-based index Read More

To understand facet coordinates, consider the following data set.

State Product Name Priority
NJ P1 Joe 2
NJ P2 Sam 3
NY P1 Jane 4
NJ P1 Sam 1
NJ P2 Joe 10
NY P1 Sam 10

Because there are four different dimensions, there are several ways to look at the data. For example, you may want to plot 'Priority' vs. 'Name', and also break this down by 'Product' and 'State'. To construct a facet chart to do this, follow the steps below:

  1. Define the data and the Chart objects, and create a new IntervalElement (bar chart).
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", "Product", "Name", "Priority"],
   ["NJ", "P1", "Joe", 2],
   ["NJ", "P2", "Sam", 3],
   ["NY", "P1", "Jane", 4],
   ["NJ", "P1", "Sam", 1],
   ["NJ", "P2", "Joe", 10],
   ["NY", "P1", "Sam", 10]];
dataset = new DefaultDataSet(arr);
graph = new EGraph();
var elem = new IntervalElement("Name", "Priority");
  1. Create a Scale for each of the dimensions. All dimensions are categorical except for 'Priority'.
var state = new CategoricalScale("State");
var name = new CategoricalScale("Name");
var product = new CategoricalScale("Product");
var priority = new LinearScale("Priority");
  1. Define two sets of rectangular coordinates, one for the outer coordinates ('Product' vs. 'State') and one for the inner coordinates ('Priority' vs. 'Name').
var inner = new RectCoord(name, priority);
var outer = new RectCoord(state, product);
  1. Create the facet coordinates based on the outer and inner rectangular coordinates defined above.
var coord = new FacetCoord(outer,inner);
  1. Assign the coordinates and the bar elements to the chart.
graph.setCoordinate(coord);
graph.addElement(elem);

The resulting chart displays an outer grid based on the outer coordinates ('State' and 'Product'). Within each cell of the outer grid, the chart displays the corresponding inner coordinates ('Name' and 'Priority').

dashboard demo
View a 2-minute demonstration of InetSoft's easy, agile, and robust BI software.

The complete script is provided below.

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", "Product", "Name", "Priority"],
   ["NJ", "P1", "Joe", 2],
   ["NJ", "P2", "Sam", 3],
   ["NY", "P1", "Jane", 4],
   ["NJ", "P1", "Sam", 1],
   ["NJ", "P2", "Joe", 10],
   ["NY", "P1", "Sam", 10]];
dataset = new DefaultDataSet(arr);
graph = new EGraph();
var elem = new IntervalElement("Name", "Priority");
var state = new CategoricalScale("State");
var name = new CategoricalScale("Name");
var product = new CategoricalScale("Product");
var priority = new LinearScale("Priority");
var inner = new RectCoord(name, priority);
var outer = new RectCoord(state, product);
var coord = new FacetCoord(outer,inner);
graph.setCoordinate(coord);
graph.addElement(elem);
Read why choosing InetSoft's cloud-flexible BI provides advantages over other BI options.

More Articles About Drawing Graphs

Better Than Panorama Necto - So how does InetSoft's Style Intelligence weigh against Panorama Necto? From the latest G2 crowd ratings, it is pretty impressive. InetSoft has received rave reviews from a majority of its users and beats Necto hands down in 94% of individual ratings. Style Intelligence has been lauded for its robustness and described as a complete and powerful go-to tool for data analysis...

BI Tools for Dashboards and Data Integration - Enhance data utilization and strengthen understanding of your enterprise's business operations with InetSoft's Style Intelligence. InetSoft's flagship software application, Style Intelligence, employs powerful data integration tools that enable otherwise overwhelming amounts of raw data to be used for intuitive analyses, revealing advantageous insights and meaningful information. Style Intelligence's web-based platform maximizes self-service and benefits business users with enhanced functionality of enterprise data, enabling data to be explored wherever a user has access to a web browser...

Comparing InetSoft to the Top 5 Reporting Software Alternatives - There are many sufficient reporting solutions on the market today, but InetSoft Style Intelligence stands out in some very key areas. The five featured vendor comparisons to InetSoft are: Tableau Qlik Cognos Business Objects Domo The main feature that helps InetSoft distinguish itself is the offering of both visual analytics and traditional reporting in one product. While visualization vendors such as Tableau, Domo, and Qlikview do not offer paginated reports, InetSoft's dashboarding capabilities are complemented by the ability to create pixel-perfect reports with impressive charts and graphics. InetSoft's reports can be made to be interactive, allowing users to drill down into raw data, links, and embedded dashboards...

Free Performance Management Software - InetSoft offers Visualize Free as a free cloud-based performance management application for business users. This data visualization tool has built-in interactivity feature to make analysis of performance management easy. It suits enterprises of any scale, being able to track the progress from an individual level to the whole company. With InetSoft's Visualize Free, executives have the guidance and ability to steer their enterprise towards its full potential, without having to invest money in BI software...

Looking for Common BI Tools - Are you looking for common BI tools? You may know these: Tableau Power BI Sisense Domo Qlik iDashboards Datapine Yellowfin Another lesser known one is InetSoft. Founded quite a while ago, InetSoft's pioneering dashboard reporting application produces great-looking web-based dashboards with an easy-to-use drag-and-drop designer. It has been highly rated on G2 for ease of use and successful deployment. End user rave about the responsive customer service. View a demo and try interactive examples...

Predict and Influence Customer Behavior - One of the best examples of companies using business intelligence tools to impact customer behavior is Starbucks. Data is key to the company's success, and job postings it publishes demonstrate how serious these folks are when it comes to data analysis. For example, this Starbucks' data scientist job posting from LinkedIn has a long and impressive list of analytics-related experience requirements, take a look. Machine Learning And Data Product Dev And Deployment Under direction of more senior data scientists, contribute to AI and Machine Learning models in batch, real-time Develop data pipelines and scalable Restful APIs to create and enable analytical applications...

Previous: Charting API