# BlazorExpress.ChartJS > BlazorExpress.ChartJS is an open-source (Apache-2.0) Blazor component library for Chart.js 4.6. Each chart type (bar, bubble, doughnut, line, pie, polar area, radar, scatter) is a Razor component whose data, datasets, options and plugins are typed C# classes. It runs in Blazor WebAssembly, Blazor Web Apps (Server and Auto render modes) and .NET MAUI Blazor Hybrid, on .NET 8, 9, 10 and 11. The current version is 2.0.0. This documentation site (https://chartjs.blazorexpress.com) is a Blazor WebAssembly app: its pages need JavaScript to render. For plain text, use this file and the raw GitHub files linked below. Key facts: - Install: `dotnet add package BlazorExpress.ChartJS --version 2.0.0`, then `@using BlazorExpress.ChartJS` in `_Imports.razor`. - Scripts, at the end of `` and in this order: Chart.js 4.6.1 (`https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.6.1/chart.umd.js`), chartjs-plugin-datalabels 2.2.0 only if you use data labels, then `_content/BlazorExpress.ChartJS/blazorexpress.chartjs.js`. They go in `wwwroot/index.html` (WebAssembly, MAUI) or `Components/App.razor` (Blazor Web App). - A chart is drawn by `InitializeAsync(chartData, options)` in `OnAfterRenderAsync`, because Chart.js needs the rendered canvas. In a Blazor Web App the page needs an interactive render mode. Change data with `UpdateAsync`, `AddDataAsync` and `AddDatasetAsync`. - Time axes (`time`, `timeseries`) need no date-adapter script: the library registers its own. Use `ChartData.TimeLabels`, `TimeData` and `ChartTimeValue` (`DateOnly`, `DateTime`, `DateTimeOffset`). Do not add `chartjs-adapter-date-fns` or luxon. - Options that Chart.js takes as a JavaScript function: register the function in your own script loaded after `blazorexpress.chartjs.js` with `blazorexpress.chartjs.registerFunction('name', fn)`, then reference it from C# with `new ChartFunction("name")`. Names are looked up only in that registry, never evaluated as code. - Chart titles, subtitles and axis titles (`ChartPluginsTitle`, `ChartPluginsSubtitle`, `ChartAxesTitle`) send black text by default. On a page with a dark theme, set `Color = null` so Chart.js uses its theme-aware default text colour. - Every chart should have `role="img"` and an `aria-label` that says what it shows; the component passes extra attributes to the canvas. - 2.0.0 changes some defaults compared with 1.x (radar and bubble axes start at zero, data-label styles, hidden datasets stay hidden after `UpdateAsync`, animated updates, the built-in date adapter replaces third-party adapters, `AddDataAsync` label handling on doughnut, pie, polar area, radar, scatter and bubble, and the removed JavaScript `updateDataValues`). Read the breaking changes before upgrading. ## Quick start The same code as the README quick start: ```razor @code { private BarChart barChart = default!; protected override async Task OnAfterRenderAsync(bool firstRender) { if (!firstRender) return; var data = new ChartData { Labels = new List { "January", "February", "March", "April" }, Datasets = new List { new BarChartDataset { Label = "Units sold", Data = new List { 120, 150, 180, 140 }, BackgroundColor = new List { "rgb(81, 43, 212)" }, }, }, }; await barChart.InitializeAsync(data, new BarChartOptions { Responsive = true }); } } ``` ## Docs - [Getting started](https://chartjs.blazorexpress.com/docs/getting-started/introduction): install, scripts, a first chart, supported versions, time axes and JavaScript functions - [Blazor WebAssembly setup](https://chartjs.blazorexpress.com/docs/getting-started/blazor-webassembly-net-8): step-by-step guide - [Blazor Web App (Server) setup](https://chartjs.blazorexpress.com/docs/getting-started/blazor-webapp-server-global-net-8): step-by-step guide - [Accessible charts](https://chartjs.blazorexpress.com/docs/accessibility): role="img" and aria-label on every chart, a long description with aria-describedby and a data table, and colour contrast - [Bar chart API](https://chartjs.blazorexpress.com/docs/bar-chart): parameters, events, methods, data and options classes - [Bubble chart API](https://chartjs.blazorexpress.com/docs/bubble-chart) - [Doughnut chart API](https://chartjs.blazorexpress.com/docs/doughnut-chart) - [Line chart API](https://chartjs.blazorexpress.com/docs/line-chart) - [Pie chart API](https://chartjs.blazorexpress.com/docs/pie-chart) - [Polar area chart API](https://chartjs.blazorexpress.com/docs/polar-area-chart) - [Radar chart API](https://chartjs.blazorexpress.com/docs/radar-chart) - [Scatter chart API](https://chartjs.blazorexpress.com/docs/scatter-chart) ## Examples - [Samples gallery](https://chartjs.blazorexpress.com/demos/samples): every sample, searchable by chart, category and tag, each with copyable source - [Bar chart examples](https://chartjs.blazorexpress.com/demos/bar-chart) - [Bubble chart examples](https://chartjs.blazorexpress.com/demos/bubble-chart) - [Doughnut chart examples](https://chartjs.blazorexpress.com/demos/doughnut-chart) - [Line chart examples](https://chartjs.blazorexpress.com/demos/line-chart) - [Pie chart examples](https://chartjs.blazorexpress.com/demos/pie-chart) - [Polar area chart examples](https://chartjs.blazorexpress.com/demos/polar-area-chart) - [Radar chart examples](https://chartjs.blazorexpress.com/demos/radar-chart) - [Scatter chart examples](https://chartjs.blazorexpress.com/demos/scatter-chart) - [Scenarios](https://chartjs.blazorexpress.com/demos/samples?category=scenarios): real-world tasks developers asked about, each with copyable source: - [Load from an API](https://chartjs.blazorexpress.com/demos/bar-chart/load-from-an-api): `HttpClient` data with loading, empty and error states - [Live streaming](https://chartjs.blazorexpress.com/demos/line-chart/time-live-streaming): a timer (or a SignalR handler) adds readings and drops the oldest - [Charts from a list](https://chartjs.blazorexpress.com/demos/bar-chart/charts-from-a-list): one chart per item with `@foreach` and `@key` - [Charts in tabs and a dialog](https://chartjs.blazorexpress.com/demos/line-chart/charts-in-tabs-and-a-dialog): charts in hidden containers draw at full size when shown - [Drill down on click](https://chartjs.blazorexpress.com/demos/bar-chart/drill-down-on-click): `OnClick` swaps totals for detail, with keyboard buttons - [Colour bars by value](https://chartjs.blazorexpress.com/demos/bar-chart/colour-bars-by-value): per-bar colours from the values - [Dark theme colours](https://chartjs.blazorexpress.com/demos/line-chart/dark-theme-colours): tick, grid, title and legend colours that follow the page theme - [Fixed-height container](https://chartjs.blazorexpress.com/demos/line-chart/fixed-height-container): `MaintainAspectRatio = false` in a container with a height - [Many points](https://chartjs.blazorexpress.com/demos/line-chart/many-points): 5,000 points kept fast - [Demo source on GitHub](https://github.com/BlazorExpress/BlazorExpress.ChartJS/tree/main/BlazorExpress.ChartJS.Demo.RCL/Pages/Demos): the Razor source of every example ## Release notes - [All releases](https://chartjs.blazorexpress.com/blog/releases): every release, newest first, each linking to its release notes - [2.0.0 release notes](https://chartjs.blazorexpress.com/blog/releases/2-0-0): breaking changes, what's new, what's changed and fixes - [Upgrading to 2.0.0](https://chartjs.blazorexpress.com/blog/releases/2-0-0-breaking-changes): each 2.0.0 breaking change with the 1.2.4 code and the 2.0.0 code - [1.2.4 release notes](https://chartjs.blazorexpress.com/blog/releases/1-2-4): chart item click events (`OnClick`) - [1.2.3 release notes](https://chartjs.blazorexpress.com/blog/releases/1-2-3): dataset `Stack` for grouped stacked bars - [1.2.2 release notes](https://chartjs.blazorexpress.com/blog/releases/1-2-2): combo bar and line charts - [1.2.1 release notes](https://chartjs.blazorexpress.com/blog/releases/1-2-1): .NET 9 and .NET 10 targets - [1.2.0 release notes](https://chartjs.blazorexpress.com/blog/releases/1-2-0): bar border radius, animation delays, line interpolation modes - [1.1.0 release notes](https://chartjs.blazorexpress.com/blog/releases/1-1-0): bubble, polar area, radar and scatter charts - [1.0.0 release notes](https://chartjs.blazorexpress.com/blog/releases/1-0-0): first stable release: bar, doughnut, line and pie charts - [1.0.0-preview1 release notes](https://chartjs.blazorexpress.com/blog/releases/1-0-0-preview1): first preview - [CHANGELOG.md (plain text)](https://raw.githubusercontent.com/BlazorExpress/BlazorExpress.ChartJS/main/CHANGELOG.md): the canonical release notes, newest first ## Optional - [README (plain text)](https://raw.githubusercontent.com/BlazorExpress/BlazorExpress.ChartJS/main/README.md): overview, install and supported versions - [Library source](https://github.com/BlazorExpress/BlazorExpress.ChartJS/tree/main/BlazorExpress.ChartJS): components, models and `wwwroot/blazorexpress.chartjs.js`, with XML docs on every public member - [NuGet package](https://www.nuget.org/packages/BlazorExpress.ChartJS) - [Color utility](https://chartjs.blazorexpress.com/demos/utils/color-utility): the categorical colour palettes in `ColorUtility` - [Blog](https://chartjs.blazorexpress.com/blog/home)