workbook.Chart
Object Description |
A chart definition object. 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 definition is used when you create a workbook. Use workbook.createChart(options) to create this object. |
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Module |
|
Methods and Properties |
|
Since |
2020.2 |
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
});
// View a workbook.Chart
var myWorkbook = workbook.load({
id: myWorkbookId
});
var myChart = myWorkbook.charts[0];
// Note that some Chart properties may be empty/null based on the loaded workbook
log.audit({
title: 'Chart id = ',
details: myChart.id
});
log.audit({
title: 'Chart name = ',
details: myChart.name
});
log.audit({
title: 'Chart title = ',
details: myChart.title
});
log.audit({
title: 'Chart subTitle = ',
details: myChart.subTitle
});
log.audit({
title: 'Chart legend = ',
details: myChart.legend
});
log.audit({
title: 'Chart category = ',
details: myChart.category
});
log.audit({
title: 'Chart series = ',
details: myChart.series
});
log.audit({
title: 'Chart stacking = ',
details: myChart.stacking
});
log.audit({
title: 'Chart filterExpressions = ',
details: myChart.filterExpressions
});
log.audit({
title: 'Chart aggregationFilters = ',
details: myChart.aggregationFilters
});
log.audit({
title: 'Chart dataset = ',
details: myChart.dataset
});
log.audit({
title: 'Chart type = ',
details: myChart.type
});
...
// Add additional code