ChartsKit.Blazor 1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package ChartsKit.Blazor --version 1.0.4
                    
NuGet\Install-Package ChartsKit.Blazor -Version 1.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ChartsKit.Blazor" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ChartsKit.Blazor" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="ChartsKit.Blazor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ChartsKit.Blazor --version 1.0.4
                    
#r "nuget: ChartsKit.Blazor, 1.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ChartsKit.Blazor@1.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ChartsKit.Blazor&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=ChartsKit.Blazor&version=1.0.4
                    
Install as a Cake Tool

ChartsKit Version: 1.0.4 Author: Shimon Hirari

ChartsKit is a reusable .NET 9 charting library designed to simplify the creation of beautiful, data-driven charts in Blazor applications. It provides a set of strongly-typed C# "Builders" that abstract away the complexity of ECharts JSON configuration, allowing developers to generate a wide variety of charts quickly and safely using familiar C# models.

This library is designed to be extensible, themeable, and easy to integrate into any Blazor Server project.

Features 20+ Chart Types: Includes Bar, Line, Pie, Scatter, Gauge, Funnel, Radar, BoxPlot, Treemap, Candlestick, Heatmap, and many more.

Fluent Builder API: A simple, intuitive C# API for configuring charts without writing complex JSON.

Theming Support: Easily switch between "light" and "dark" modes.

Image Export: Export any chart to PNG or SVG with a single method call.

Strongly-Typed Models: Reduce errors with C# data models for all chart types, enabling compile-time safety.

Offline First: All required JavaScript assets are bundled with the library, requiring no external CDN links for core functionality.

Installation and Setup Follow these three steps to get ChartsKit running in your Blazor application.

  1. Install NuGet Package Install the ChartsKit.Blazor package from NuGet into your Blazor Server application.

dotnet add package ChartsKit.Blazor

  1. Register Services In your Program.cs file, register the necessary services for ChartsKit.

// In Program.cs builder.Services.AddChartsKit();

  1. Include JavaScript Assets In your application's main layout file (usually App.razor or _Layout.cshtml), include the required JavaScript files. Place these <script> tags at the end of the <body> section in the following order:

<script src="_content/ChartsKit.Blazor/js/echarts.min.js"></script> <script src="_content/ChartsKit.Blazor/js/world.js"></script> <script src="_content/ChartsKit.Blazor/js/interop.js"></script>

Quick Start: Your First Chart Here is a complete example of how to create a simple bar chart. You can copy and paste this code into a new Razor component.

@page "/my-first-chart" @rendermode InteractiveServer

@using ChartsKit.Blazor @using ChartsKit.Core.Builders @using ChartsKit.Core.Models

<h3>My First Bar Chart</h3>

<div style="height: 400px; width: 100%;"> <ChartView Options="@_chartOptions" /> </div>

@code { private object? _chartOptions;

protected override void OnInitialized()
{
    // 1. Instantiate the builder for the chart you want.
    var barChartBuilder = new BarChartBuilder();

    // 2. Create the data using the correct C# model.
    var myData = new CategoryData[]
    {
        new("Apples", 50),
        new("Oranges", 75),
        new("Bananas", 120)
    };

    // 3. Call the builder to generate the chart options.
    _chartOptions = barChartBuilder.Build(myData, seriesName: "Fruit Sales");
}

}

Advanced Usage Theming You can apply a theme by setting the Theme parameter on the <ChartView> component. The built-in options are light (default) and dark.

<ChartView @ref="_chartView" Options="@_chartOptions" Theme="dark" />

Exporting to Image You can export a chart to a PNG file by getting a reference to the ChartView component and calling its ExportAsync method.

@page "/advanced-example" @rendermode InteractiveServer

@using ChartsKit.Blazor @inject IJSRuntime JSRuntime

<h3>Advanced Chart</h3>

<div style="height: 500px; width: 100%;"> <ChartView @ref="_chartView" Options="@_chartOptions" /> </div>

<button class="btn btn-primary mt-2" @onclick="ExportChart">Export as PNG</button>

@code { // 1. Create a reference variable for the component private ChartView? _chartView; private object? _chartOptions;

// (Add your chart generation logic in OnInitialized here)

// 2. Create a method to call the component's export function
private async Task ExportChart()
{
    if (_chartView != null)
    {
        var dataUrl = await _chartView.ExportAsync("png");
        if (!string.IsNullOrEmpty(dataUrl))
        {
            // This JS interop call triggers a file download in the browser
            await JSRuntime.InvokeVoidAsync("eval", $"let a = document.createElement('a'); a.href = '{dataUrl}'; a.download = 'chart.png'; a.click();");
        }
    }
}

}

Chart Reference & Data Models Here is a reference for all available charts, their required data models, and a basic usage example.

Area / Line / Bar / Horizontal Bar Builder: AreaChartBuilder, LineChartBuilder, BarChartBuilder, HorizontalBarBuilder

Data Model: IEnumerable<CategoryData>

Example:

var myData = new CategoryData[] { new("Mon", 120), new("Tue", 200), new("Wed", 150) }; _chartOptions = new BarChartBuilder().Build(myData, seriesName: "Daily Sales");

BoxPlot Builder: BoxPlotChartBuilder

Data Model: IEnumerable<BoxPlotData>

Example:

var myData = new BoxPlotData[] { new("Experiment 1", new List<double> { 850, 740, 900, 1070, 930, 850, 950, 980, 980, 880 }), new("Experiment 2", new List<double> { 920, 880, 910, 1000, 950, 920, 960, 990, 995, 890 }) }; _chartOptions = new BoxPlotChartBuilder().Build(myData);

Calendar Heatmap Builder: CalendarHeatBuilder

Data Model: CalendarHeatData

Example:

var myData = new CalendarHeatData( Year: "2024", Data: new List<Tuple<string, int>> { new Tuple<string, int>("2024-01-22", 125), new Tuple<string, int>("2024-03-15", 450) } ); _chartOptions = new CalendarHeatBuilder().Build(myData);

Candlestick Builder: CandlestickChartBuilder

Data Model: IEnumerable<CandlestickData>

Example:

var myData = new CandlestickData[] { new("2024-01-01", 20, 34, 10, 38), new("2024-01-02", 34, 35, 30, 40), new("2024-01-03", 35, 45, 32, 48) }; _chartOptions = new CandlestickChartBuilder().Build(myData);

Funnel Builder: FunnelChartBuilder

Data Model: IEnumerable<FunnelData>

Example:

var myData = new FunnelData[] { new("Impressions", 100), new("Clicks", 80), new("Visits", 60), new("Inquiries", 40), new("Orders", 20) }; _chartOptions = new FunnelChartBuilder().Build(myData);

Gantt (Simulated) Builder: GanttChartBuilder

Data Model: IEnumerable<GanttTask>

Example:

var myData = new GanttTask[] { new("Task 1", new DateTime(2024, 1, 1), new DateTime(2024, 1, 5)), new("Task 2", new DateTime(2024, 1, 3), new DateTime(2024, 1, 8)), new("Task 3", new DateTime(2024, 1, 6), new DateTime(2024, 1, 12)) }; _chartOptions = new GanttChartBuilder().Build(myData, "Project Timeline");

Gauge Builder: GaugeChartBuilder

Data Model: GaugeData

Example:

var myData = new GaugeData("Completion", 75.5); _chartOptions = new GaugeChartBuilder().Build(myData);

Heatmap Builder: HeatmapChartBuilder

Data Model: HeatmapData

Example:

var myData = new HeatmapData( XLabels: new[] { "12a", "1a", "2a" }, YLabels: new[] { "Mon", "Tue", "Wed" }, Data: new List<List<object>> { new List<object> { 0, 0, 5 }, // [x, y, value] for Mon new List<object> { 1, 1, 8 }, // [x, y, value] for Tue new List<object> { 2, 2, 3 } // [x, y, value] for Wed } ); _chartOptions = new HeatmapChartBuilder().Build(myData);

Map Builder: MapChartBuilder

Data Model: IEnumerable<MapData>

Example:

var myData = new MapData[] { new("Brazil", 100), new("United States", 200) }; _chartOptions = new MapChartBuilder().Build(myData, "Sales by Country");

Multi-Line Builder: MultiLineChartBuilder

Data Model: MultiLineData

Example:

var myData = new MultiLineData( Labels: new[] { "Jan", "Feb", "Mar" }, Series: new List<ChartSeries> { new("Product A", new double[] { 120, 132, 101 }), new("Product B", new double[] { 220, 182, 191 }) } ); _chartOptions = new MultiLineChartBuilder().Build(myData);

Parallel Builder: ParallelChartBuilder

Data Model: ParallelData

Example:

var myData = new ParallelData( Schema: new List<ParallelSchema> { new("Price", 0), new("Sales", 1), new("Rating", 2) }, Data: new List<List<object>> { new List<object> { 12.99, 100, 4.5 }, new List<object> { 25.50, 80, 4.8 } } ); _chartOptions = new ParallelChartBuilder().Build(myData);

Pie / Doughnut Builder: PieChartBuilder

Data Model: IEnumerable<PieData>

Example:

var myData = new PieData[] { new("Direct", 335), new("Email", 310), new("Ad", 234) }; // For a Doughnut chart, set isDoughnut: true _chartOptions = new PieChartBuilder().Build(myData, isDoughnut: false);

Radar Builder: RadarChartBuilder

Data Models: List<RadarIndicator>, List<RadarSeriesData>

Example:

var indicators = new List<RadarIndicator> { new("Sales", 6500), new("Admin", 16000), new("Tech", 30000) }; var seriesData = new List<RadarSeriesData> { new("Budget", new double[] { 4200, 3000, 20000 }), new("Spending", new double[] { 5000, 14000, 28000 }) }; _chartOptions = new RadarChartBuilder().Build(indicators, seriesData);

Sankey Builder: SankeyChartBuilder

Data Model: SankeyData

Example:

var myData = new SankeyData( Nodes: new List<SankeyNode> { new("a"), new("b"), new("c") }, Links: new List<SankeyLink> { new("a", "b", 5), new("a", "c", 3) } ); _chartOptions = new SankeyChartBuilder().Build(myData);

Scatter Builder: ScatterChartBuilder

Data Model: IEnumerable<ScatterData>

Example:

var myData = new ScatterData[] { new(10, 8.04), new(8, 6.95), new(13, 7.58) }; _chartOptions = new ScatterChartBuilder().Build(myData, "Data Points");

Sunburst Builder: SunburstChartBuilder

Data Model: List<SunburstNode>

Example:

var myData = new List<SunburstNode> { new("Grandpa", new List<SunburstNode> { new("Uncle", new List<SunburstNode> { new("Cousin A", null), new("Cousin B", null) }), new("Father", new List<SunburstNode> { new("Me", null), new("Brother", null) }) }) }; _chartOptions = new SunburstChartBuilder().Build(myData);

Tree Builder: TreeChartBuilder

Data Model: List<TreeNode>

Example:

var myData = new List<TreeNode> { new("Node A", new List<TreeNode> { new("Node A1", null), new("Node A2", new List<TreeNode> { new("Node A2a", null) }) }) }; _chartOptions = new TreeChartBuilder().Build(myData);

Treemap Builder: TreemapChartBuilder

Data Model: List<TreemapNode>

Example:

var myData = new List<TreemapNode> { new("Node A", 10, new List<TreemapNode> { new("Node A1", 4, null) }), new("Node B", 20, new List<TreemapNode> { new("Node B1", 10, null), new("Node B2", 5, null) }) }; _chartOptions = new TreemapChartBuilder().Build(myData);

Contributing Contributions are welcome! If you have a suggestion or find a bug, please open an issue on the repository.

License This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.8 291 7/2/2025
1.0.7 240 7/1/2025
1.0.6 229 7/1/2025
1.0.5 233 7/1/2025
1.0.4 250 7/1/2025
1.0.3 241 6/30/2025
1.0.2 227 6/30/2025
1.0.1 223 6/30/2025
1.0.0 223 6/30/2025