Skip to content

Charts

NaviusChart is a lookless Grid that wraps LiveChartsCore.SkiaSharpView.WPF (LiveCharts2), the engine ADR-0004 picked over ScottPlot.WPF for its settable per-series Fill/Stroke SolidColorPaint properties, a direct, no-extra-machinery re-theme path (reassign the paints, let the control redraw), and LineSeries/ColumnSeries/PieSeries types that map close to 1:1 onto the family’s line/bar/area/pie surface. Consumers set Kind, Series, and, for the cartesian kinds, Categories; the wrapper always derives series color from the current Navius tokens rather than letting the consumer pick one, mirroring the shape (not the exact API) of the web Zits.Ui chart family referenced by ADR-0004 (ZitsChart.cs / ZitsLineChart.razor / ZitsPieChart.razor, a Key -> ChartSeries { Label, Color } config plus row data). EscapeHatch exposes the underlying LiveCharts CartesianChart or PieChart for anything the wrapper does not cover.

Theme integration is push-based and, since the shipped code, automatic: NaviusChart resolves its palette from Navius.Wpf.Primitives.Theming.ThemeManager’s current token dictionary (NaviusChartTheme.Resolve, a DynamicResource lookup for Navius.Primary, Navius.MutedForeground, Navius.Muted, Navius.Destructive, Navius.Border, and Navius.Background) and subscribes to ThemeManager.ThemeChanged while loaded (unhooked on Unloaded), rebuilding on every theme swap. ADR-0004 describes re-theming as a manual RefreshTheme() call the consumer must trigger themselves because, at the time it was written, ThemeManager had “no theme-changed event”; the shipped ThemeManager.cs already exposes a ThemeChanged event, and NaviusChart already wires itself to it, so the ADR’s premise is stale even though its underlying decision (LiveCharts2, push re-theming) still holds. RefreshTheme() remains public for a consumer that wants to force a rebuild outside a theme change.

xmlns:charts="clr-namespace:Navius.Wpf.Charts;assembly=Navius.Wpf.Charts"
<charts:NaviusChart x:Name="RevenueChart"
Kind="Line"
Width="420" Height="220" />

Series (IReadOnlyList<NaviusChartSeries>) and Categories (IReadOnlyList<string>) are plain CLR/DP values with no XAML markup extension for populating them inline, so they are set from code-behind or a binding, matching how the Gallery’s ChartsPage builds its demos:

RevenueChart.Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun" };
RevenueChart.Series = new[]
{
new NaviusChartSeries { Key = "desktop", Label = "Desktop", Values = [186, 305, 237, 173, 209, 260] },
new NaviusChartSeries { Key = "mobile", Label = "Mobile", Values = [80, 200, 120, 190, 130, 140] },
};

Kind="Bar" with mixed-sign Values on a series automatically recolors the negative points with the Navius.Destructive token instead of the series color. Categories is ignored for Kind="Pie", where each series contributes one slice sized by its first Values entry.

Property Type Default From Description
Kind NaviusChartKind Line NaviusChart Which shape to render: Line, Bar, Area, or Pie. Changing it rebuilds the inner LiveCharts control.
Series IReadOnlyList<NaviusChartSeries> [] (empty array) NaviusChart The series to plot. One point per Categories entry for the cartesian kinds; only the first value is used for Pie. No Color property exists on NaviusChartSeries, color always comes from the current Navius tokens.
Categories IReadOnlyList<string> [] (empty array) NaviusChart X-axis category labels for Line/Bar/Area. Ignored for Pie.
EscapeHatch FrameworkElement? null NaviusChart Read-only. The underlying LiveCharts control (CartesianChart for the cartesian kinds, PieChart for Pie) for anything the wrapper does not expose; a new instance replaces it on every rebuild.
Method Description
RefreshTheme() Re-resolves the Navius tokens from the control’s resource scope and rebuilds the chart’s series and axis paints with the refreshed palette. Called automatically once on Loaded and automatically on every ThemeManager.ThemeChanged while the chart is loaded; a consumer can also call it directly to force a rebuild.

NaviusChart derives from Grid and ships no custom AutomationPeer override in this project (no NaviusChartAutomationPeer class exists, unlike NaviusDialogAutomationPeer for the Dialog family). WPF Panel-derived elements do not override OnCreateAutomationPeer by default, so a plain Grid supplies no automation peer of its own; UI Automation instead sees whatever peer the embedded LiveCharts control (CartesianChart or PieChart, reachable via EscapeHatch) provides for itself, which lives in a third-party package and is not verified by this codebase’s tests. The unit suite (NaviusChartTests) exercises rebuild behavior on Kind/Series changes, RefreshTheme(), and the EscapeHatch type, but does not exercise automation-peer behavior for this family.

  • webEquivalent is null: there is no docs/parity/<slug>.md for Charts and no docs.naviusui.dev manifest to map to. ADR-0004 references the web Zits.Ui chart family (ZitsChart.cs / ZitsLineChart.razor / ZitsPieChart.razor) only for its config shape (Key -> ChartSeries plus row data), so this is documented against its own ADR rather than a parity doc.
  • The web ChartSeries shape includes a per-series Color; NaviusChartSeries has no Color property at all. A consumer never picks a chart color: NaviusChartPalette.Derive always leads with the Navius.Primary (“ink”) token for the first series, then shades Navius.MutedForeground at decreasing opacity (steps 1.0, 0.7, 0.5, 0.35, 0.25, cycling) for every series after it.
  • Negative-value bar/column emphasis (Navius.Destructive) is implemented by NaviusChartSeriesMapper.BuildBarSeries splitting one series with mixed-sign values into two ColumnSeries<double?> (a positive-only and a negative-only series, each with the other half masked to null so a category shows exactly one colored bar). ADR-0004 describes this mechanism as LiveCharts2’s per-point OnPointMeasured callback; no OnPointMeasured call exists anywhere in the shipped Navius.Wpf.Charts source, so the ADR’s stated mechanism does not match the implementation, though the resulting behavior (mixed-sign bars recolor by sign) is accurate.
  • Known residual: the CLI registry (registry/registry.json) has no entry for Navius.Wpf.Charts or NaviusChart, so there is no navius add-style vendoring path for this family; a consumer can only reach it via the Navius.Wpf.Charts NuGet package reference, not the CLI registry flow the other families use.

The Charts Gallery page rendered at the pinned commit, in each theme.

Charts Gallery page in the light theme

Charts Gallery page in the dark theme

Charts Gallery page in the high contrast theme