Chart Script Tutorial
The following sections explain how to use the Chart Script API to modify and create Charts.
Why Use Chart Script?
|
In most cases, you should create Charts using the Chart Editor, as described in Create a Chart. The Chart Editor is very easy to use, and yet provides a rich feature set to design a wide variety of Charts.
In cases where you cannot create the desired Chart using the Chart Editor, you can use Chart Script to gain deeper control over Chart object model. This is typically useful for special-purpose or industry-specific Charts that have non-standard axis layouts or unusual mixtures of text and graphics.
The Chart object model is illustrated in Object Hierarchy. You can use the object model and associated methods in two ways:
-
Existing Chart: Get a handle to Chart objects for a Chart that you already created with the Chart Editor, and modify those objects using API script. This is generally the easier and recommended approach, and requires only basic knowledge of JavaScript.
-
New Chart: Create a Chart from scratch using Chart API commands. This approach requires more code, but provides the most flexibility. It is recommended only for users with programming skills.
The following sections provide examples of both approaches.
Overview
This tutorial provides a set of Chart examples to illustrate some common chart scripting tasks, such as color-coding data, changing labels and axes, and positioning chart annotations.
-
Modify Chart Properties: Use simple script commands to modify a Chart.
-
Modify Chart Data Binding: Use Chart script to change the data fields displayed on a Chart.
-
Modify Chart Element: Use Chart script to change the color, shape, or size representation of data on a Chart.
-
Create a Chart with API: Use Chart script to create a Chart from scratch without using the Chart Editor.
-
Bind Data to Chart in Script: Use Chart script to select the data that should appear on Chart.
-
Access Chart Data: Use Chart script to read the data that is displayed on the Chart.
-
Change Chart Coordinates: Use Chart script to switch between rectangular, polar, and parallel coordinates, and set a coordinate background.
-
Change Chart Labels: Use Chart script to modify Chart labels.
-
Change Chart Scaling: Use Chart script to switch between linear and log scales and set axis minimums and maximums.
-
Change Chart Element Appearance: Use Chart script to change the appearance of element, such as color, shape, size.
-
Change Axis Properties: Use Chart script to change the appearance of Chart axes, such as color, thickness, style, etc.
-
Change Legend Properties: Use Chart script to change the properties of a Chart legend, such as color, font, border, etc.
-
Represent Data with Shape, Color, Size: Use Chart script to choose how data should be mapped to Chart elements, for example, by using the size, color, or shape of Chart elements.
-
Represent Multiple Measure: Use Chart script to add additional measures onto a Chart.
-
Add Chart Decoration: Use Chart script to add custom labeling to a Chart.