Chart API Example: Creating a Pie Chart

To create a pie chart from this data, just convert the chart to a stacked bar, and then convert to polar coordinates. Follow the steps below:

  1. Instead of using different X-axis positions to distinguish the 'State' data, distinguish the states using a ColorFrame object. (Note that a 'null' value is assigned for the (unused) X-dimension when creating the IntervalElement and RectCoord objects)
 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", "Revenue"], ["CA", 200],
            ["NY",300],["PA",150]]; dataset = new DefaultDataSet(arr);
 graph = new EGraph(); var elem = new IntervalElement(null,"Revenue");
 var xscale = new CategoricalScale("State") var yscale = new LinearScale("Revenue");
 var rect = new RectCoord(null, yscale);
 var cframe = new CategoricalColorFrame("State");
 elem.setColorFrame(cframe);
 graph.setCoordinate(rect);
 graph.addElement(elem);
  1. Convert the chart into a stacked bar chart with just one bar by using the GraphElement's collisionModifier property. Create a StackRange object to make sure there is enough room for the stacked elements.
elem.setCollisionModifier(GraphElement.STACK_SYMMETRIC); yscale.setScaleRange(new StackRange());
  1. Create polar coordinates from the existing rectangular coordinates. By default, this maps the non-null coordinate (Y-axis) to the polar coordinate's magnitude dimension. Specify that it should be mapped to the angle dimension instead.
var polar = new PolarCoord(rect);

polar.setType(PolarCoord.THETA);
  1. Use the Chart's setCoordinate() method to apply the new polar coordinates.
graph.setCoordinate(polar);
  1. Remove the axis lines and labels. To do this, create an AxisSpec object, and assign it to the Scale.
var yspec = new AxisSpec();
yspec.setLabelVisible(false);
yspec.setLineVisible(false);
yspec.setTickVisible(false);
yscale.setAxisSpec(yspec);
  1. Add the state names to the individual slices and hide the legend. To do this, create a new TextFrame object based on the State field, and assign it to the GraphElement. To hide the legend, create a new LegendSpec object, and assign it to the ColorFrame.
var tframe = new DefaultTextFrame("State");
elem.setTextFrame(tframe);
var legend = new LegendSpec();
legend.setVisible(false);
cframe.setLegendSpec(legend);
  1. Explode the slices for better appearance.
elem.setHint(GraphElement.HINT_EXPLODED,'true');

The final script for the pie chart is shown 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", "Revenue"], ["CA", 200],
           ["NY",300],["PA",150]];
dataset = new DefaultDataSet(arr);
graph = new EGraph();
var elem = new IntervalElement(null,"Revenue");
var xscale = new CategoricalScale("State")
var yscale = new LinearScale("Revenue");
var rect = new RectCoord(null, yscale);
var cframe = new CategoricalColorFrame("State");
elem.setColorFrame(cframe);
elem.setCollisionModifier(GraphElement.STACK_SYMMETRIC);
yscale.setScaleRange(new StackRange());
var polar = new PolarCoord(rect);
polar.setType(PolarCoord.THETA);
var yspec = new AxisSpec();
yspec.setLabelVisible(false);
yspec.setLineVisible(false);
yspec.setTickVisible(false);
yscale.setAxisSpec(yspec);
var tframe = new DefaultTextFrame("State");
elem.setTextFrame(tframe);
var legend = new LegendSpec();
legend.setVisible(false);
cframe.setLegendSpec(legend);
elem.setHint(GraphElement.HINT_EXPLODED,'true');
graph.setCoordinate(polar);
graph.addElement(elem);

12 InetSoft Articles About API

  1. View A Demo And Try Interactive Examples

    The page highlights a reporting product that supports connections to external web services and live data feeds. It shows interactive examples that demonstrate how embedded reports can pull data from modern sources and render them for end users. The content emphasizes practical demo material and sample dashboards that help evaluators understand integration points. There is guidance for how embedding works and what to expect from an evaluation copy. The overall tone is focused on showing capabilities through hands-on examples rather than deep API reference.

  2. Try The Two Minute Product Demonstration

    This page presents the dashboarding product with short demo videos and interactive samples to illustrate embedding options. It demonstrates how dashboards can be populated from remote services and refreshed for interactive user experiences. The examples emphasize UI embedding and programmatic control of dashboard elements for richer integration. Instructions for requesting demos and exploring live samples are provided for prospective integrators. The narrative frames dashboarding as an embeddable UI layer that developers can hook into existing applications.

  3. Integrate Reporting Into Existing Web Portals

    The article explains how the product’s API enables embedding reporting and visualization into third-party web applications and corporate portals. It outlines common integration scenarios such as OEM embedding, white-label dashboards, and custom web interfaces driven by programmatic calls. Emphasis is placed on the flexibility to match a customer’s look-and-feel and to deliver reports inside existing workflows. The page includes pointers about automation, distribution, and how APIs streamline report delivery. The messaging targets developers and ISVs looking to incorporate reporting without rebuilding visualization layers.

  4. Java Toolset For Building Embedded Reports

    The page describes a Java-oriented toolkit designed to speed development of embedded reporting functionality in enterprise Java environments. It covers how the API family supports programmatic report generation, formatting, and integration with Java web applications. Information covers practical tooling for developers who need tight control over report lifecycle and rendering. The content highlights examples of using the API to produce production-quality reports and to automate report workflows. Guidance is oriented toward teams embedding reporting in server-side Java projects.

  5. Control Nearly Every Aspect Of Visualizations Programmatically

    This documentation-style article showcases the visualization API that exposes many visualization internals to developer control. It describes object models and methods for adjusting visual elements, annotations, and mapping data to visual channels. The goal is to explain how to script complex visual behaviors that go beyond drag-and-drop authoring. Examples illustrate programmatic modification of chart properties and interaction responses. The content clearly targets developers who need granular, scriptable control of charts and dashboards.

  6. Explore The Object Structure Behind Charts

    This technical reference lays out the object hierarchy used by the charting API so developers can understand relationships between elements. It explains objects like graph elements, visual frames, scales, and forms and how they combine to render a chart. The page includes examples of getter/setter patterns and how to manipulate chart properties via script. Readers are guided through the conceptual model so custom chart construction and deep customization become feasible. The emphasis is on how the API maps conceptual chart constructs to programmable objects.

  7. View Reports From Any Browser Using Server Endpoints

    This article describes the server-side reporting API that enables distributed report access and browser-based viewing. It covers how reports authored on the server can be exposed, secured, and consumed across web clients. The server API is framed as a bridge between backend data processing and front-end rendering, handling multi-user access in enterprise deployments. Technical notes point to the object-oriented design that supports scalable report delivery. The tone is instructional for architects designing a centralized reporting service.

  8. Change Dashboard Behavior With Scripted Examples

    Example code and sample scripts show how programmatic calls can alter dashboard scaling, filters, and visual elements on the fly. The page contains pragmatic snippets demonstrating how to customize dashboard interactions for executive-level presentations. It highlights how scriptable elements enable dynamic dashboards that adjust to user input or programmatic events. The samples provide a quick path for developers to reproduce typical use cases and to extend them for specific enterprise workflows. The material is practice-focused, with small code fragments to try in an evaluation environment.

  9. Programmatic Control Over Chart Presentation Options

    This piece explains how chart styling and presentation settings can be controlled via the API rather than only through GUI designers. It outlines style classes, programmable attributes, and how developers can apply consistent visual themes programmatically. The content is targeted at embedding scenarios where charts must follow a branded style or adhere to accessibility constraints automatically. It also covers how style defaults can be overridden through API calls for specific reports. The practical focus helps teams maintain uniform visual standards across many embedded charts.

  10. Flexibility For Building Custom Reporting Interfaces

    This article argues the API’s value proposition as an enabler for custom web reporting interfaces and OEM integrations. It discusses use cases in which developers build bespoke front ends while relying on the platform for robust reporting logic. The page highlights benefits such as faster time-to-market, reduced maintenance, and a simple path for embedding analytics into existing products. It includes business-oriented messaging about how APIs reduce the need for duplicated reporting features. The intended audience is product managers and technical leads planning embedded analytics.

  11. Understand Layout Models And API Conventions

    The documentation summarizes the reporting layout models — tabular and flow — and how those models shape API usage for composing reports. It explains the conventions developers should follow when programmatically assembling report elements and binding data. The content helps developers choose the appropriate model for their reporting scenario and how to implement each approach using the API. Practical notes include how cell-based layouts differ from continuous flow and the implications for rendering and pagination. This is useful reference material when designing automated report generation pipelines.

  12. Generate Visual Reports Programmatically With JavaScript-Like Calls

    This page introduces a JavaScript-style visual reporting API for generating charts and visual reports without using the GUI designer. It provides examples of building visual reports programmatically and points to the tradeoffs between scripted creation and drag-and-drop composition. The material explains scenarios where automated report creation is preferred, such as batch report generation or dynamic dashboards driven by runtime conditions. Developers are shown how to produce visual outputs directly via script, enabling integration into headless workflows. The guidance includes example outputs and references for getting started.

Previous: Charting API
Next: Graph API
We will help you get started Contact us