Kebechet.Blazor.ChartJS 4.3.0-preview1

Prefix Reserved
This is a prerelease version of Kebechet.Blazor.ChartJS.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Kebechet.Blazor.ChartJS --version 4.3.0-preview1                
NuGet\Install-Package Kebechet.Blazor.ChartJS -Version 4.3.0-preview1                
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="Kebechet.Blazor.ChartJS" Version="4.3.0-preview1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kebechet.Blazor.ChartJS --version 4.3.0-preview1                
#r "nuget: Kebechet.Blazor.ChartJS, 4.3.0-preview1"                
#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.
// Install Kebechet.Blazor.ChartJS as a Cake Addin
#addin nuget:?package=Kebechet.Blazor.ChartJS&version=4.3.0-preview1&prerelease

// Install Kebechet.Blazor.ChartJS as a Cake Tool
#tool nuget:?package=Kebechet.Blazor.ChartJS&version=4.3.0-preview1&prerelease                

Blazor.ChartJS

This repo contains lean wrapper around Chart.js for Blazor.

Motivation:

Repository ChartJs.Blazor is not longer maintained and also it is stuck at old version chart.js@2.9.4. The lack of maintainers is quite often problem. Thats why I have created the leanest wrapper possible. This should be quite future proof and if needed also a beginner should be able to bump chart.js to newer version or fix potential bug in the wrapper.

Usage example

  • our wrapper contains methods: createChart, getChart, updateChart, destroyChart
  • all data and configurations are provided as anonymous objects. Thats why it should be 1:1 with chart.js docs

Index.razor

@using Blazor.ChartJS

<Chart Config="_config" />

Index.razor.cs

using Blazor.ChartJS;

namespace BlazorChartTest.Pages;

public partial class Index
{
    private Chart? _chart { get; set; }

    private readonly dynamic _config = new
    {
        Type = "line",
        Data = new
        {
            Labels = new[] { "Red", "Blue", "Yellow", "Green", "Purple", "Orange" },
            Datasets = new[]
            {
                new
                {
                    Label = "# of Votes",
                    Data = new[] { 12, 19, 3, 5, 2, 3 },
                    BorderWidth = 1
                },
                new
                {
                    Label = "# of Votes",
                    Data = new[] { 12, 19, 3, 5, 2, 3 },
                    BorderWidth = 1
                }
            }
        },
    };

    public async Task Rerender()
    {
        await _chart!.Rerender();
    }

    public async Task Update()
    {
        var data = new
        {
            Labels = new[] { "faast", "Blue", "Yellow", "Green", "Purple", "Orange" },
            Datasets = new[]
            {
                new
                {
                    Label = "# of Votes",
                    Data = new[] { 55, 19, 3, 5, 2, 3 },
                    BorderWidth = 1
                },
                new
                {
                    Label = "# of Votes",
                    Data = new[] { 12, 19, 3, 5, 2, 3 },
                    BorderWidth = 1
                }
            }
        };

        await _chart!.Update(data, true);
    }
}

Contribution is welcome BUT:

  • only to improve basic functionality of the wrapper. Purpose of this wrapper is to be as simple as possible.
  • to fix bugs
  • to automate overall workflow

Versioning

  • chart.js version is part of the package version.
  • examples:
    • package version 4.3.0.0 means that chart.js version used is 4.3.0
    • package version 4.3.0.2 means that chart.js version used is 4.3.0 and we did 2 bugfixes/improvements in the wrapper

TODO

  • add examples
  • automate ChartJS version bump
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.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
4.3.0.8 950 6/23/2024
4.3.0.7 317 5/31/2024
4.3.0.6 567 3/5/2024
4.3.0.5 122 3/4/2024
4.3.0.4 1,147 7/20/2023
4.3.0.3 222 7/5/2023
4.3.0.2 156 7/4/2023
4.3.0.1 124 7/4/2023
4.3.0-preview1 113 7/4/2023

First release of the package