Charts

ChartControl

Show trends, shares, rankings and flows with 35+ chart types drawn as SVG from C#.

Overview

ChartControl is a Blazor chart that turns your series into any of 35+ chart types, from bars and lines to heatmaps and funnels. Use it for dashboards and reports: change one Type to show the same data another way, and every bar, slice and point shows a tooltip card on hover. Rendering is SVG built in C#, with no npm package or third-party JavaScript.

Examples

#Tooltips: default card, format pattern, template

Hover any shape for the default card, then compare a TooltipFormat pattern, a TooltipTemplate and the PointHover event, whose context is printed under the tiles.

Default card
0100200300400 MonTueWedThuFriSat
Loaves
Pastries
TooltipFormat
Blue
Green
Red
Purple
Yellow
TooltipTemplate
020405979 Week 1Week 2Week 3Week 4Week 5Week 6
Sunflower
Runner bean

PointHover: nothing under the pointer.

Documentation

One control, one data shape. Type picks the renderer; Series carries the data as ChartSeries of ChartDataPoint, whose Value2 to Value5 mean different things per type; XAxis, YAxis and Legend hold the optional axis and legend settings. Every SVG type draws on a fixed canvas (600 by 300 units for most types) scaled to fit the width it is given, and its label text is a fixed size in that drawing, so a chart in a narrow tile has small labels and a wide one has large labels. Each row below says which types read the setting; a row marked never read is declared in the library but has no effect yet.

ParameterTypeDefaultDescription
TypeChartTypeChartType.BarSelects the SVG renderer. HorizontalBar, GroupedBar, StackedBar, StackedBar100, Pareto, ComboBarLine and Treemap and Surface (which have no case of their own) all go to the bar renderer, and HorizontalBar still draws vertical bars. Not consulted in legacy mode: with Series null and Bars or DataSource set, the control renders HTML bars whatever Type says.
SeriesList<ChartSeries>?nullData for every SVG type. A non-null value, even an empty list, puts the control in SVG mode and makes it ignore Bars and DataSource; null with neither of those set is SVG mode too, and only KpiCard and the gauge types render without data (everything else shows No data). Most single-series types read only Series[0]; ComboBarLine draws Series[1] as its line and Heatmap uses one series per row.
DataSourceSystem.Collections.IEnumerable?nullLegacy multi-row mode: when Series is null and Bars is null or empty, each item becomes one HTML row of grouped vertical bars. Needs ValueFields with at least one name, otherwise nothing is resolved and the tile shows No data. Values are read by reflection on each item's runtime type.
LabelFieldstring?nullLegacy multi-row mode only: property name whose ToString() becomes the row label; null or a missing property gives an empty label.
ValueFieldsIList<string>?nullLegacy multi-row mode only: property names read from each DataSource item, in order, one bar per name. Each value goes through Convert.ToDouble; a missing property, null or unconvertible value becomes 0. Bars are scaled against the largest value across all rows.
ValueLabelsIList<string>?nullLegacy multi-row mode only: per-column captions used in each bar's hover tooltip and, while ShowAxisLabels is true, as the bottom axis ticks (the axis is skipped entirely when this is null or empty). Columns beyond the list get an empty tooltip caption.
BarsIList<ChartBar>?nullLegacy single-series mode: when Series is null and this has at least one entry, each ChartBar becomes one HTML row with a horizontal bar sized as a percentage of the largest value (clamped 0 to 100; a non-positive maximum counts as 1). A non-empty Bars wins over DataSource; an empty list falls through to it. ChartBar.Color overrides BarColor per row.
RowTypeType?nullDeclared, but ChartControl never reads it. Legacy mode reflects on each item's runtime type instead.
Titlestring?nullRendered as a fx-chart-title div above the chart in both modes when not empty. Sunburst also uses it as the name of the root node (Total when empty).
Widthstring?nullWritten as width on the root fx-chart div when not empty; the scoped CSS otherwise makes the root 100% wide. The svg inside is always 100% of that width.
Heightstring?"300px"CSS height of the svg only: every SVG type draws on a fixed viewBox (600×300 for most types; 300×300 for Pie, Donut, Radar and the round gauges; 400×300 Funnel; 200×40 Sparkline) scaled with xMidYMid meet, so a narrow tile shows the drawing centered between blank bands. Not read in legacy HTML bar mode or by KpiCard, and Sunburst hands it to SunburstChartControl, which never reads it. An explicit null selects a per-type fallback (40px Sparkline, 260px gauges, 320px financial, 340px Sankey, 60px per point for Bullet, else 300px).
CssClassstring?nullAppended to the root fx-chart div's class list in both modes.
ColorPalettestring[]?nullReplaces the eight built-in colors that GetSeriesColor and GetPointColor cycle through; ChartSeries.Color and ChartDataPoint.Color still win, and entry 0 also colors the gauge arc. The types with colors of their own read single entries, without cycling, and keep their own color where the palette has no such entry: entry 0 is the bar of RangeBar, RangeColumn and RangeArea, the line of HighLow, the actual bar of Bullet, the source nodes and ribbons of Sankey, and the top of the Heatmap ramp when it is a hex color; entry 1 is the Pareto line, the Bullet target line and the Sankey target nodes. Waterfall, Candlestick and Ohlc color by direction instead (UpColor, DownColor). Not read in legacy mode (see BarColor).
UpColorstring?nullRising candles and Ohlc bars (close at or above open) and positive Waterfall steps. Unset, a candle has a #22c55e body with a #16a34a wick and outline, and the other two use #16a34a; set, the body, wick and outline all take it. A Waterfall point's Color still wins.
DownColorstring?nullFalling candles and Ohlc bars and negative Waterfall steps. Unset, a candle has a #ef4444 body with a #dc2626 wick and outline, and the other two use #dc2626; set, all of them take it. A Waterfall point's Color still wins.
AnimateboolfalseDeclared, but ChartControl never reads it; no renderer emits an animation and the only transitions are the fixed CSS ones on the legacy bars. ChartSvg.Markup passes it as false.
InnerRadiusdouble?nullDonut only: inner radius as a fraction of the outer one, 0.6 when null; the value is not clamped. Pie always uses 0 and no other type reads it.
LabelStylestring?"min-width:160px;"Legacy HTML bar mode only: inline style on the row label cell of both the Bars and the DataSource layouts, applied only while ShowLabels is true. The multi-row bottom axis keeps its own fixed 160px spacer in CSS, so a different width here misaligns the axis ticks. Never read by the SVG types.
BarColorstring?"#2563eb"Legacy HTML bar mode only: fill of every bar, with ChartBar.Color overriding it per row in Bars mode (the multi-row layout has no per-bar override); null falls back to the same blue. Never read by the SVG types, which use ColorPalette.
XAxisChartAxis?nullOnly XAxis.Title is read, drawn under the plot by the bar family and the line/area family. Min, Max, Format, ShowGridLines and TickCount of the X axis are never read; no type offers an X scale override.
YAxisChartAxis?nullMin/Max replace the padded data range in the bar family, the line/area family, Waterfall, BoxPlot and Histogram (a maximum not above the minimum is pushed to minimum + 1); TickCount (5 when unset, the number of labeled grid lines) is honored by the bar and line/area families only; Title is drawn rotated at the left edge by those same two families. Format and ShowGridLines are never read: tick labels always use F0 and the dashed grid is always drawn.
LegendChartLegend?nullLegend.Visible (true when the object is null) gates the shared legend that SVG mode appends below the drawing when Series has more than one entry; swatches come from GetSeriesColor. Pie and Donut add their own per-slice legend regardless of this setting. Legend.Position is never read; the legend always sits under the chart.
ShowLabelsbooltrueLegacy HTML bar mode only: renders the label cell (styled by LabelStyle) at the start of each Bars row or DataSource row. Never read by the SVG types, which always draw their own category labels.
ShowValuesboolfalseLegacy HTML bar mode only: writes each value, formatted with ValueFormat, beside a Bars bar or above a DataSource bar. Never read by the SVG types, whose values live in hover <title> tooltips.
ShowAxisLabelsbooltrueLegacy DataSource mode only: renders the bottom axis row of ValueLabels captions, and only when that list has entries. Not read in Bars mode or by any SVG type.
ValueFormatstring"N2"Format string for the legacy value captions shown by ShowValues (the hover tooltips there always use N2), and for the value text of Gauge, ArcGauge, RadialGauge and LinearGauge through GaugeVisualControl, where this default overrides that control's own 0.##, so a gauge shows two decimals unless you set it. Not read by any other SVG type.
ShowTooltipsbooltrueShows a card when the pointer is over a bar, slice, point, cell, flow or marker, with the label, the series and the value, and the share of the whole for Pie, Donut, Funnel and Pyramid. Off, the shapes keep their native <title> text. Gauges, KPI cards and sparklines have no card.
TooltipValueFormatstring?null.NET numeric format for the numbers in the default card. Unset, whole numbers print as N0 and the rest as N2.
TooltipFormatstring?nullText pattern that replaces the card's rows: {series} {label} {category} {title} {value} {value2}…{value5} {percent} {open} {high} {low} {close} {min} {max} {size}; a format after a colon applies to numbers ({value:N0}); starts a new row.
TooltipFormatterFunc<ChartTooltipContext, string?>?nullCode-side text for the card's rows, lines separated by ; return null to fall back to TooltipFormat or the default rows.
TooltipTemplateRenderFragment<ChartTooltipContext>?nullReplaces the whole card content; the context is the hovered shape.
PointHoverEventCallback<ChartTooltipContext?>—Raised with the context when the pointer enters a shape and with null when it leaves the shape or the chart.
ReportPlotReportAnalysisDefinition?nullA report's chart definition. When PrintedSummaryPlot supports it (one measure, no series field, a print axis, or summaries as categories) the control draws that plot as a bitmap instead of SVG; otherwise it only lends its RightCategoryLegend to the category-legend scene.
CategoryLegendboolfalseDraws Bar, GroupedBar, StackedBar and StackedBar100 as the classic printed bar scene with a category-key legend, as a bitmap.
ThreeDimensionalboolfalseDraws Bar, GroupedBar, StackedBar and StackedBar100 with perspective faces, as a bitmap.
ColorBarsByCategoryboolfalseSingle-series Bar only: each bar takes its point's color (GetPointColor) instead of the series color.
PrintWidthPoints / PrintHeightPointsdouble0Print size in points. Both set, a Bar draws its SVG at that size instead of 600x300, and Line, Surface, Ohlc, HorizontalBar, Area, Pie, Donut, Radar, Funnel, Gauge, Scatter and Bubble render as the printed stage chart bitmap. The category-legend and 3-D scenes use them when set and 600x300 otherwise.
PrintReportGroupChartboolfalsePrinted stage chart, Line and Area only: the report group chart's layout (tighter margins, larger value labels, black heading).
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.