Chart class Charts

A chart anchored to a worksheet cell, authored over data ranges.

Add one with Sheet.addChart. On save the chart is written as xl/charts/chartN.xml, drawn through the sheet's drawing part.

sheet.addChart(Chart.column(
  anchor: CellIndex.indexByString('E2'),
  title: 'Quarterly sales',
  categories: 'A2:A5',
  series: [
    ChartSeries(name: 'Q1', values: 'B2:B5'),
    ChartSeries(name: 'Q2', values: 'C2:C5'),
  ],
));

Constructors

Chart({required ChartType type, required CellIndex anchor, required List<ChartSeries> series, String? title, String? categories, ChartGrouping grouping = ChartGrouping.clustered, LegendPosition legend = LegendPosition.right, int width = 480, int height = 288, String? xAxisTitle, String? yAxisTitle, bool plotVisibleOnly = true, CellIndex? anchorTo})
Creates a chart of the given type; prefer the named factories (Chart.column, Chart.line, Chart.pie, ...) for the common kinds.
Chart.area({required CellIndex anchor, required List<ChartSeries> series, String? categories, String? title, ChartGrouping grouping = ChartGrouping.standard, LegendPosition legend = LegendPosition.right, int width = 480, int height = 288, String? xAxisTitle, String? yAxisTitle, bool plotVisibleOnly = true, CellIndex? anchorTo})
An area chart.
factory
Chart.bar({required CellIndex anchor, required List<ChartSeries> series, String? categories, String? title, ChartGrouping grouping = ChartGrouping.clustered, LegendPosition legend = LegendPosition.right, int width = 480, int height = 288, String? xAxisTitle, String? yAxisTitle, bool plotVisibleOnly = true, CellIndex? anchorTo})
A horizontal bar chart.
factory
Chart.column({required CellIndex anchor, required List<ChartSeries> series, String? categories, String? title, ChartGrouping grouping = ChartGrouping.clustered, LegendPosition legend = LegendPosition.right, int width = 480, int height = 288, String? xAxisTitle, String? yAxisTitle, bool plotVisibleOnly = true, CellIndex? anchorTo})
A vertical bar (column) chart.
factory
Chart.doughnut({required CellIndex anchor, required ChartSeries series, String? categories, String? title, LegendPosition legend = LegendPosition.right, int width = 480, int height = 288, bool plotVisibleOnly = true, CellIndex? anchorTo})
A doughnut chart (uses the first series only).
factory
Chart.line({required CellIndex anchor, required List<ChartSeries> series, String? categories, String? title, ChartGrouping grouping = ChartGrouping.standard, LegendPosition legend = LegendPosition.right, int width = 480, int height = 288, String? xAxisTitle, String? yAxisTitle, bool plotVisibleOnly = true, CellIndex? anchorTo})
A line chart.
factory
Chart.pie({required CellIndex anchor, required ChartSeries series, String? categories, String? title, LegendPosition legend = LegendPosition.right, int width = 480, int height = 288, bool plotVisibleOnly = true, CellIndex? anchorTo})
A pie chart (uses the first series only).
factory
Chart.scatter({required CellIndex anchor, required List<ChartSeries> series, String? title, LegendPosition legend = LegendPosition.right, int width = 480, int height = 288, String? xAxisTitle, String? yAxisTitle, bool plotVisibleOnly = true, CellIndex? anchorTo})
A scatter (XY) chart. Each series needs both ChartSeries.xValues and ChartSeries.values.
factory

Properties

anchor CellIndex
Top-left cell the chart's frame is anchored to.
final
anchorTo CellIndex?
Bottom-right cell the chart's frame extends to (its top-left corner). When set, the chart spans the cell range anchor..anchorTo and is sized by those cells (a two-cell anchor), so its edges line up with the grid and it resizes with the columns/rows; width/height then act only as a fallback size. When null, the chart floats at a fixed width×height pixels from anchor (a one-cell anchor).
final
categories String?
Category-axis range (the x labels), A1-style. Not used by scatter charts.
final
grouping ChartGrouping
How series combine (bar/column/line/area only).
final
hashCode int
The hash code for this object.
no setterinherited
height int
Frame height in pixels.
final
legend LegendPosition
Legend placement.
final
plotVisibleOnly bool
Whether the chart plots only data in visible cells. When false, the chart also plots cells in hidden rows and columns (Excel's "show data in hidden rows and columns" option), useful when the source data is kept off-screen. Defaults to true.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
series List<ChartSeries>
The data series. Pie and doughnut charts use only the first series.
final
title String?
Chart title, or null for none.
final
type ChartType
The chart kind.
final
width int
Frame width in pixels.
final
xAxisTitle String?
Category (x) axis title, or null.
final
yAxisTitle String?
Value (y) axis title, or null.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited