Charts and Sparklines
A worksheet chart belongs to its worksheet and visualizes a source range or supported explicit series, such as revenue by region. Sparklines show compact trends inside cells. Charts on a dashboard are a different thing: you configure them separately, as widgets.
Create a Chart in Code
The following code writes the revenue of four regions into the first worksheet and adds a column chart next to it. editor is the Spreadsheet of the browser editor:
const sheet = editor.workbook.sheets.at(0);
sheet.range('A1:B5').setValues([
['Region', 'Revenue'], ['North', 42000], ['South', 38500],
['East', 31200], ['West', 44900]
]);
const chart = sheet.charts.add({
type: 'column', dataRange: 'A1:B5', title: 'Revenue by region',
anchor: { cell: 'D2' }, size: { width: 640, height: 360 }
});
editor.ui.selectChart(chart);
The code works as follows:
- Worksheet.range and Range.setValues write the column headings
RegionandRevenueand one row for each region intoA1:B5. - Worksheet.charts returns the ChartCollection of the worksheet. Its add method creates a chart from the cell data: a column chart over
A1:B5with the titleRevenue by region, anchored at cellD2and 640 by 360 pixels in size. - EditorUi.selectChart, reached through
editor.ui, selects the new chart in the editor.
Chart dimensions and offsets are unscaled CSS pixels. Moving or resizing the browser host does not redefine these document coordinates.
Use the chart handle, a ChartHandle, to rename, move, resize, update and remove the chart, for example with its methods moveTo, resize, update and remove. Its lifetime follows the owning worksheet and document.
Create and Edit a Chart in the UI

- Select the category and value range.
- Choose a chart from the Insert tab.
- Review the preview before you confirm.
Right-click a chart to open its context menu. Colors… and Filter Data… open panels beside the chosen command, kept within the browser window. Select Data… opens the chart editor, and the ellipsis beside Axis Titles opens the axis-title dialog.
To edit an existing chart, select it and use Chart Design → Select Data or Change Chart Type:

- Region comparisons. The first column supplies the region labels, and the Revenue column supplies one numeric series.
- Time trends. Choose a line variant and an ordered month series.
Chart Dialogs explains Title, Data Range, Series In and Legend, and how to review a draft without replacing the current chart.
Choose Types and Series
For the actual names of the supported types and styles, use the exported inventories CHART_TYPES and CHART_STYLES and the ChartObjectOptions reference. The series orientation, the headers and the categories must match the layout of the source. Test labels, negative values, empty data and mixed types.
Selecting a chart exposes contextual design and format commands. Give charts meaningful titles and labels, and use colors with sufficient contrast. A visually attractive chart can still be misleading if the source aggregation or the category definition is wrong.
Add Sparklines
Sparklines provide compact trends at the level of a cell. Supported worksheet and workbook APIs create and update sparkline groups from a data range and a destination range: Worksheet.addSparklines and Worksheet.updateSparklineGroup, or Workbook.addSparklines and Workbook.updateSparklineGroup for the active sheet.
In the editor, select the destination cells and choose Insert → Sparklines, then a sparkline type. The Create Sparklines dialog groups its controls into Data & Location, Appearance and Display. Set the source and destination ranges first, then inspect the actual miniature charts in Live Preview. Opening a section closes the previous section; switches for markers, negative points, the axis and shared scaling keep the dialog frame stable.

Choose OK to create the group or Cancel to discard the draft. The preview does not create sparkline groups in the worksheet.
Keep the dimensions of the source and the location compatible. Clear sparklines with Worksheet.clearSparklines without assuming that the underlying source values are deleted.
Save and Export Charts
Charts and sparklines participate in supported XLSX and TXWB persistence and in PDF rendering. Review specialized chart features of imported files with XLSX Compatibility.
Native Chart Presentation
Chart presentation includes transparent surfaces, manual plot and legend placement, independent category and value axes, rotated category captions, numeric axis formats and bar gaps. Value labels on 100% stacked charts display the original series values.
const sheet = book.sheets.at(0);
const chart = sheet.charts.add({
type: 'bar-100', title: 'Event budget',
series: [
{ name: 'Income', values: { values: [1936, 1831] }, categories: { values: ['Estimated', 'Actual'] },
color: '#ff4500', dataLabels: { numberFormatCode: '"$"#,##0', color: '#ffffff', bold: true, position: 'center' } },
{ name: 'Expenses', values: { values: [882, 333] }, categories: { values: ['Estimated', 'Actual'] },
color: '#ffb499', dataLabels: { numberFormatCode: '"$"#,##0', position: 'center' } }
], anchor: { cell: 'E2' }, size: { width: 520, height: 320 }
});
chart.update({
elements: { dataLabels: true, gridlines: false },
presentation: {
backgroundColor: null, borderColor: null,
plotLayout: { x: 0.12, y: 0.24, width: 0.85, height: 0.68 },
categoryAxis: { visible: true, lineVisible: false, labelRotation: -90 },
valueAxis: { visible: false }, gapWidth: 50
}
});
Next Steps
- Chart Dialogs: choose a chart family and variant and set the title, data range, series and legend.
- Widgets: add aggregated charts and interactive filters to a dashboard.
- XLSX Compatibility: check how imported chart features survive the exchange with Excel.