Skip to main content

Blazor Charts with BlazorExpress.ChartJS

Chart components are no longer included in the BlazorBootstrap package. They are developed and released separately as BlazorExpress.ChartJS, a dedicated Blazor component library built on Chart.js.

Breaking change

When upgrading from a BlazorBootstrap version that included charts, add the BlazorExpress.ChartJS package and namespace, add its browser scripts, and update chart code to the dedicated package API. Remove references to the former BlazorBootstrap chart types and window.blazorChart interop.

Install the package​

dotnet add package BlazorExpress.ChartJS --version 2.0.0

Add the namespace to the _Imports.razor used by your chart pages:

@using BlazorExpress.ChartJS

Add browser scripts​

Load these scripts from the host page (wwwroot/index.html for Blazor WebAssembly, Components/App.razor for a Blazor Web App) after the Blazor framework script and in the order shown. BlazorExpress.ChartJS 2.0.0 is built for Chart.js 4.6.1. The data-labels plugin is needed only by charts that use data labels, and time axes need no extra date-adapter script.

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.6.1/chart.umd.js" integrity="sha512-Vj/VnWZpOof68AJOIBxA90+7KQccA7eISngKbl18q5MQO3KnvO1a0z76Q+7hj8+iDIwETpKUBPN+cLy7PxvTEQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.2.0/chartjs-plugin-datalabels.min.js" integrity="sha512-JPcRR8yFa8mmCsfrw4TNte1ZvF1e3+1SdGMslZvmrzDYxS69J7J49vkFL8u6u8PlPJK+H3voElBtUCzaXj+6ig==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="_content/BlazorExpress.ChartJS/blazorexpress.chartjs.js"></script>
BlazorExpress.ChartJS.NETChart.jschartjs-plugin-datalabels
2.0.08, 9, 10, 114.6.12.2.0
1.2.2 to 1.2.48, 9, 104.4.12.2.0
Upgrading from 1.x

BlazorExpress.ChartJS 2.0.0 changes some defaults and behaviour, such as radar and bubble axes starting at zero, hidden datasets staying hidden after UpdateAsync, and a built-in date adapter that replaces third-party adapters. Read the 2.0.0 breaking changes before you update.

Documentation and original demos​

Use the dedicated project as the source of truth for current chart APIs and examples:

We recommend checking the original demos before adapting advanced examples.

Click events​

BlazorExpress.ChartJS 1.2.4 added chart item click callbacks for every supported chart family. Set the package-provided OnClick callback to receive ChartClickEventArgs, which includes the selected dataset index and label, data-item index and label, and raw selected value.

Use the official documentation and original demos below for the current click-event examples and API details.

Chart types​

ChartOfficial documentationOriginal demo
BarDocumentationDemo
BubbleDocumentationDemo
DoughnutDocumentationDemo
LineDocumentationDemo
PieDocumentationDemo
Polar AreaDocumentationDemo
RadarDocumentationDemo
ScatterDocumentationDemo

More libraries from the team

Free, open-source .NET libraries built by the same team.

UnlimitedPDF

A pure .NET library to create, merge and split PDFs, and convert HTML to PDF.

BlazorExpress.ChartJS

Chart.js charts for Blazor, configured in C#.

BlazorExpress.Bulma

Enterprise-class Blazor components built on the Bulma CSS framework.