ChartsKit.Blazor
1.0.3
See the version list below for details.
dotnet add package ChartsKit.Blazor --version 1.0.3
NuGet\Install-Package ChartsKit.Blazor -Version 1.0.3
<PackageReference Include="ChartsKit.Blazor" Version="1.0.3" />
<PackageVersion Include="ChartsKit.Blazor" Version="1.0.3" />
<PackageReference Include="ChartsKit.Blazor" />
paket add ChartsKit.Blazor --version 1.0.3
#r "nuget: ChartsKit.Blazor, 1.0.3"
#:package ChartsKit.Blazor@1.0.3
#addin nuget:?package=ChartsKit.Blazor&version=1.0.3
#tool nuget:?package=ChartsKit.Blazor&version=1.0.3
Version: 1.0.3 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, Doughnut, Scatter, Gauge, Funnel, Radar, BoxPlot, Treemap, Candlestick, Heatmap, Sankey, Tree, Sunburst, Parallel, Calendar Heatmap, Gantt, Area, and Map charts.
- Fluent Builder API: A simple, intuitive C# API for configuring charts without writing complex JSON.
- Theming Support: Easily switch between "light" and "dark" modes, or create your own custom themes.
- 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.
How to Use
1. Install NuGet Package
Install the ChartsKit.Blazor package from NuGet:
dotnet add package ChartsKit.Blazor
2. Include JavaScript Files
In your application's root component (e.g., App.razor), you must include the required JavaScript files in the following order, typically at the end of the <body> tag:
HTML
<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>
3. Use the ChartView Component
In any Razor component, use the <ChartView> component to display a chart.
Example: Bar Chart
HTML
@using ChartsKit.Blazor
@using ChartsKit.Core.Builders
@using ChartsKit.Core.Models
<h3>My Bar Chart</h3>
<div style="height: 400px; width: 100%;">
<ChartView Options="@_chartOptions" />
</div>
@code {
private object? _chartOptions;
protected override void OnInitialized()
{
var barChartBuilder = new BarChartBuilder();
var myData = new CategoryData[]
{
new("Apples", 50),
new("Oranges", 75),
new("Bananas", 120)
};
_chartOptions = barChartBuilder.Build(myData, seriesName: "Fruit Sales");
}
}
4. Using Themes and Exporting
You can easily apply a theme and export a chart.
HTML
@using ChartsKit.Blazor
@inject IJSRuntime JSRuntime
<div style="height: 500px; width: 100%;">
<ChartView @ref="_chartView" Options="@_chartOptions" Theme="dark" />
</div>
<button @onclick="ExportChart">Export as PNG</button>
@code {
private ChartView? _chartView;
private object? _chartOptions;
// (Chart generation logic...)
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();");
}
}
}
}
| Product | Versions 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. |
-
net9.0
- ChartsKit.Core (>= 1.0.3)
- Microsoft.AspNetCore.Components.Web (>= 9.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.