Charts
Charts render 12 native pure-Dart vector chart types from one canonical scene graph across the Flutter editor, PDF export, SVG, and lossless OOXML DOCX (word/charts/chartN.xml) — with zero charting library dependencies.
- Included in:
documentConfiguration(or addChart.element+ChartDocumentExtensionto any configuration) - Pure-Dart import:
package:vyuh_document_elements/chart.dartorpackage:vyuh_document_elements/vyuh_document_elements.dart - Flutter extension:
ChartDocumentExtension(dataResolver:, chartBuilder:, asyncDataGate:) - Action namespace:
ChartActions(ChartActions.insert)
Quick example
dart
import 'package:vyuh_document/vyuh_document.dart';
import 'package:vyuh_document_elements/vyuh_document_elements.dart';
final doc = Document.of(documentConfiguration, [
Chart(
kind: ChartKind.bar,
title: 'Revenue vs Target',
categories: const ['Q1', 'Q2', 'Q3', 'Q4'],
series: [
ChartSeries(name: 'Actual', values: const [42, 58, 65, 81]),
// Mix series kinds on one vertical Cartesian chart for a compound/combo chart
ChartSeries(
name: 'Target',
values: const [45, 55, 70, 78],
kind: ChartKind.line,
),
],
style: ChartStyle(
barCornerRadius: 4,
barGroupWidth: 0.72,
lineStrokeWidth: 2.5,
smoothCurves: true,
markerShape: ChartMarkerShape.diamond,
),
),
]);All 12 supported chart kinds (ChartKind)
| Family | Chart kinds |
|---|---|
| Vertical Cartesian (combo-capable) | bar, line, area, scatter |
| Horizontal Cartesian | horizontalBar (with full X & Y axis titles) |
| Radial (unified slice engine) | pie, doughnut, gauge |
| Multi-axis & relational | radar, funnel, sankey, treemap |
ChartKind.pie and ChartKind.doughnut stay distinct in the document model and OOXML (<c:pieChart> vs <c:doughnutChart>) while sharing one unified radial slice geometry engine.
What you can configure
Chart-type-specific options (ChartStyle)
Exposed contextually in the Chart tab of the Properties panel (<ChartKind> options) and round-tripped through JSON and OOXML:
| Property | Type / Range | Applies to |
|---|---|---|
doughnutHoleSize | double (0.15–0.85) | doughnut, gauge (inner ring hole ratio; OOXML <c:holeSize>) |
pieSliceGap | double (0–8 pt) | pie, doughnut, funnel, treemap (gap between slices/stages/tiles) |
pieStartAngle | double (0–360°) | pie, doughnut (first-slice rotation; OOXML <c:firstSliceAng>) |
showCenterTotal | bool | doughnut (displays total sum inside the ring center) |
lineStrokeWidth | double (1–6 pt) | line, area, radar |
smoothCurves | bool | line, area (Catmull-Rom cubic curves; OOXML <c:smooth val="1"/>) |
areaOpacity | double (0.05–0.85) | area, radar, sankey (fill / ribbon opacity) |
showMarkers | bool | line, area, radar (toggle data point markers) |
markerShape | ChartMarkerShape (circle, square, diamond, triangle, none) | line, area, scatter, radar (OOXML <c:marker><c:symbol/>) |
markerSize | double (2–8 pt) | line, area, scatter, radar (OOXML <c:marker><c:size/>) |
barCornerRadius | double (0–10 pt) | bar, horizontalBar, treemap |
barGroupWidth | double (0.35–0.95) | bar, horizontalBar (category bar width share; OOXML <c:gapWidth>) |
Compound / combo charts (ChartSeries.kind)
On any vertical Cartesian chart (bar, line, area, scatter), each ChartSeries accepts an optional ChartKind? kind override (exposed as Plot as in the Series tab). Series render in deterministic z-order (Area → Bar → Line → Scatter), hit-test accurately per series, and export as standard OOXML multi-plot combo charts (<c:barChart> + <c:lineChart> sharing <c:catAx> and <c:valAx>).
Data, axes, formatting & frame
| Area | Properties |
|---|---|
| Inline spreadsheet | Live spreadsheet editor in the Data tab with pure-Dart numeric & date cell input validation (isValidChartNumericInput, ChartCategoryFormatKind.allowsInput) |
| External live data | ChartExternalSource (endpoint URL, refresh metadata) resolved lazily via ChartDocumentExtension(dataResolver:) and DocumentAsyncDataGate (auto-cancels off-screen loads) |
| Axes & formatting | showGrid, showLegend, xAxisTitle, yAxisTitle, valueFormat (number, currency, percent, compact), categoryFormat (text, date, quarter, year), showValueLabels |
| Frame & placement | width, height, GraphicFrameStyle (padding, background color, border color/width/style), inline or floating text-wrap placement |
| Custom renderer | Pass chartBuilder: on ChartDocumentExtension to replace the built-in vector painter on screen while keeping canonical data, Properties UI, and PDF/DOCX export |
Actions & commands
- Action:
ChartActions.insert - Typed commands:
SetChartKind,UpdateChartData - Direct part clicking: Clicking the chart title, legend, axes, or any bar/slice/line selects that exact sub-tab in the Properties inspector.
Restricting usage
- Remove charts:
documentConfiguration.withoutElements([Chart.element]) - Offline-only charts (no external endpoints): Omit
dataResolveronChartDocumentExtensionso only inline spreadsheet data is active. - Read-only dashboard charts: Set
controller.setMode(DocumentInteractionMode.readOnly)or gateChartActions.insertinDocumentPolicy.
Format parity
| DOCX | HTML | Markdown | |
|---|---|---|---|
Native OOXML word/charts/chartN.xml including hole size, start angle, smooth curves, marker shapes, and multi-plot combo charts | Crisp vector PDF marks & aligned labels from the exact same ChartScene | <figure data-vyuh-chart> with embedded vector SVG | Fenced chart block with full JSON data round-trip |