ChartModel class

An observable data model for driving chart widget rebuilds.

ChartModel extends ChangeNotifier so it can be used with ListenableBuilder, ChartBuilder, or any listener-based subscription pattern.

final model = ChartModel(
  type: ChartType.line,
  values: [10, 20, 15, 30, 25],
  showGrid: true,
);

// Later, update the data:
model.values = [12, 22, 18, 35, 28]; // notifies listeners
Inheritance

Constructors

ChartModel({ChartType type = ChartType.line, List<double> values = const [], List<ChartSeries> series = const [], List<List<double>> grid = const [], bool showGrid = false, bool showMarkers = true, bool showAxis = true, bool donut = false, double innerRadiusRatio = 0.45, bool normalizeTotals = true, ChartRamp? ramp, UvStyle? lineStyle, UvStyle? barStyle, UvStyle? gridStyle, UvStyle? labelStyle, List<UvStyle>? sliceStyles, List<String>? xLabels, List<String>? yLabels, String? title})
Creates a ChartModel with the given configuration.

Properties

barStyle UvStyle?
Style for bar chart elements.
getter/setter pair
donut bool
Whether to render a donut hole (pie charts).
getter/setter pair
grid List<List<double>>
2D grid data for ChartType.heatmap.
getter/setter pair
gridStyle UvStyle?
Style for grid lines.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
innerRadiusRatio double
Inner radius ratio for donut charts.
getter/setter pair
labelStyle UvStyle?
Style for axis labels.
getter/setter pair
lineStyle UvStyle?
Style for line/sparkline chart elements.
getter/setter pair
normalizeTotals bool
Whether ribbon charts normalize each column to 100%.
getter/setter pair
ramp ChartRamp?
Colour ramp for heatmap rendering.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
series List<ChartSeries>
Named data series for multi-series charts like ChartType.ribbon.
getter/setter pair
showAxis bool
Whether to draw the axis line (bar charts).
getter/setter pair
showGrid bool
Whether to draw background grid lines.
getter/setter pair
showMarkers bool
Whether to draw markers at data points (line charts).
getter/setter pair
sliceStyles List<UvStyle>?
Per-slice/per-series styles for pie and ribbon charts.
getter/setter pair
title String?
An optional title displayed above the chart.
getter/setter pair
type ChartType
The type of chart to render.
getter/setter pair
values List<double>
The primary data values for single-series charts.
getter/setter pair
xLabels List<String>?
Labels for the X axis.
getter/setter pair
yLabels List<String>?
Labels for the Y axis.
getter/setter pair

Methods

addListener(void listener()) → void
Register listener to be called when the object notifies.
inherited
dispose() → void
Releases all listeners. After this call the notifier should not be used.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Notify all registered listeners.
inherited
removeListener(void listener()) → void
Remove a previously registered listener.
inherited
throwIfDisposed() → void
Throws StateError if this notifier has already been disposed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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