MatPlotLibNet.Blazor 1.17.1

dotnet add package MatPlotLibNet.Blazor --version 1.17.1
                    
NuGet\Install-Package MatPlotLibNet.Blazor -Version 1.17.1
                    
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="MatPlotLibNet.Blazor" Version="1.17.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MatPlotLibNet.Blazor" Version="1.17.1" />
                    
Directory.Packages.props
<PackageReference Include="MatPlotLibNet.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 MatPlotLibNet.Blazor --version 1.17.1
                    
#r "nuget: MatPlotLibNet.Blazor, 1.17.1"
                    
#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 MatPlotLibNet.Blazor@1.17.1
                    
#: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=MatPlotLibNet.Blazor&version=1.17.1
                    
Install as a Cake Addin
#tool nuget:?package=MatPlotLibNet.Blazor&version=1.17.1
                    
Install as a Cake Tool

MatPlotLibNet.Blazor

Blazor components for the MatPlotLibNet charting library. They render charts as inline SVG, with optional real-time server push. Since v1.2.0 the interaction also runs in both directions: zoom, pan, reset and legend-toggle events travel from the browser back to the .NET server. The server updates the authoritative Figure and streams the new SVG back.

Installation

dotnet add package MatPlotLibNet.Blazor

Components

MplChart — static chart

@using MatPlotLibNet
@using MatPlotLibNet.Blazor

<MplChart Figure="@_figure" CssClass="my-chart" />

@code {
    private Figure _figure = Plt.Create()
        .WithTitle("Sales")
        .Bar(["Q1", "Q2", "Q3"], [100, 200, 150])
        .Build();
}

MplLiveChart — one-way server push via SignalR

<MplLiveChart ChartId="dashboard-1"
              HubUrl="/charts-hub"
              CssClass="live-chart" />

The component connects to a ChartHub endpoint. It updates automatically when the server calls IChartPublisher.PublishSvgAsync for this chart id.

Bidirectional interaction (v1.2.0)

Add .WithServerInteraction(...) on the figure builder to send browser interaction to the server. The dispatcher script embedded in the SVG invokes the hub's OnZoom, OnPan, OnReset and OnLegendToggle methods. The server then updates the registered figure and publishes the new SVG through the same fan-out path that MplLiveChart already listens on.

For client-side-only interaction (no server round-trip), use .WithBrowserInteraction() instead. It switches on pan and zoom, legend toggle (click) and legend drag (press-and-hold to reposition; v1.7.2), treemap drilldown, sankey hover, 3D rotation, rich tooltips, highlight and brush selection, all automatically. The library detects which scripts are relevant per chart and emits only those.

@page "/interactive"
@using MatPlotLibNet.AspNetCore
@using MatPlotLibNet.Rendering.Svg
@using MatPlotLibNet.Transforms
@inject FigureRegistry Registry
@implements IDisposable

<div id="host">@((MarkupString)_svg)</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/8.0.0/signalr.min.js"></script>
<script>
    (function () {
        var conn = new signalR.HubConnectionBuilder()
            .withUrl('/charts-hub').withAutomaticReconnect().build();
        window.__mpl_signalr_connection = conn;
        conn.on('UpdateChartSvg', function (id, svg) {
            if (id === 'blazor-interactive') document.getElementById('host').innerHTML = svg;
        });
        conn.start().then(function () { return conn.invoke('Subscribe', 'blazor-interactive'); });
    })();
</script>

@code {
    private string _svg = string.Empty;

    protected override void OnInitialized()
    {
        var figure = Plt.Create()
            .WithTitle("Damped sine — server-authoritative")
            .Plot(xs, ys)
            .WithServerInteraction("blazor-interactive", i => i.All())
            .Build();

        figure.SubPlots[0].XAxis.Min = xs[0];
        figure.SubPlots[0].XAxis.Max = xs[^1];

        Registry.Register("blazor-interactive", figure);
        _svg = new SvgTransform().Render(figure);
    }

    public void Dispose() => _ = Registry.UnregisterAsync("blazor-interactive");
}

The dispatcher script looks up window.__mpl_signalr_connection, so the <script> block above only needs to run once per page. There is no per-chart wiring. FigureRegistry.Register installs a background reader task for each chart, so the hub method returns in microseconds and the rendering happens asynchronously, off the request thread.

A runnable version ships in Samples/MatPlotLibNet.Samples.Blazor/Components/Pages/Interactive.razor, on route /interactive.

Extension method

@((MarkupString)figure.ToMarkupString())

ToMarkupString() converts a Figure to an SVG MarkupString for direct rendering.

Dependencies

  • MatPlotLibNet (core)
  • MatPlotLibNet.AspNetCore (for the bidirectional path; it needs FigureRegistry and ChartHub)
  • Microsoft.AspNetCore.SignalR.Client

License

MIT — Copyright (c) 2026 H.P. Gansevoort

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  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 is compatible.  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.17.1 83 9/13/2026
1.17.0 91 9/12/2026
1.16.0 84 9/12/2026
1.15.1 84 9/12/2026
1.15.0 85 9/11/2026
1.14.4 85 9/11/2026
1.14.3 97 8/30/2026
1.14.2 119 8/17/2026
1.14.1 104 8/15/2026
1.14.0 112 7/12/2026
1.13.0 112 7/4/2026
1.12.0 110 6/30/2026
1.11.2 118 5/16/2026
1.11.1 112 5/16/2026
1.10.0 106 5/4/2026
1.9.0 124 4/23/2026
1.8.0 118 4/22/2026
1.7.3 118 4/21/2026
1.7.2 117 4/18/2026
1.7.1 113 4/18/2026
Loading failed

MatPlotLibNet 1.17.1. What changed in this release, and in every release before it, is written out in the changelog: https://github.com/xkqg/MatPlotLibNet/blob/main/CHANGELOG.md#1171