workbook.createChart(options)
Method Description |
Creates a chart , A chart is a workbook component that enables you to visualize your dataset query results using predefined chart and graph types, such as line graphs and bar charts. A chart is built from an underlying dataset and can also include a category, a legend, series, a type, expressions, filters, stacking behavior indicators, along with an ID, a name, a title, and a subtitle. For more information about charts in SuiteAnalytics, see Workbook Charts. |
Returns |
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Sibling Module Members |
|
Since |
2020.2 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
optional |
The set of conditional filters or limiting filters that are applied to the chart. When multiple filters are defined, they are aggregated together to form a single compounded filter. |
|
|
required |
The category of the chart. |
|
|
required |
The underlying dataset that the chart is based on. A chart can include only the data (fields) that are included in the dataset. |
|
|
required |
The datasetLink on which the chart is based |
|
|
optional |
The simple, non-aggregated value-based filters for the chart. |
|
|
string |
required |
The ID of the chart. |
|
required |
The legend for the chart. |
|
|
string |
required |
The name of the chart. |
|
string | workbook.Expression |
required |
The name of the portlet for the chart. |
|
required |
The set of series for the chart. Each series includes information about how each data point is calculated. For example, a series can represent the sum of transaction amounts for a customer in a particular month. |
|
|
optional |
The stacking type that describes how the chart data is stacked. |
|
|
string | workbook.Expression |
optional |
The subtitle of the chart. |
|
string | workbook.Expression |
optional |
The title of the chart. |
|
required |
The type of the chart. |
Errors
Error Code |
Thrown If |
---|---|
|
The value specified for the |
|
The value specified for the |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/workbook Module Script Samples. Also see Full scripts in the Tutorial: Creating a Workbook Using the Workbook API topic.
// Add additional code
...
// Create a basic Chart
var myChart = workbook.createChart({
name: 'myChart',
id: '_myChart',
type: workbook.ChartType.BAR,
category: myCategory,
legend: myLegend,
series: [mySeries],
dataset: myDataset
});
// Create a comprehensive Chart
var myChart = workbook.createChart({
name: 'myChart',
title: 'My Chart Title',
subTitle: 'My Chart Subtitle',
id: '_myChart',
type: workbook.ChartType.BAR,
stacking: workbook.Stacking.PERCENT,
category: myCategory,
legend: myLegend,
series: [mySeries],
filterExpressions: [myExpression],
aggregationFilters: [myLimitingFilter],
dataset: myDataset,
datasetLink: myDatasetLink,
portletName: myPortlet
});
...
// Add additional code