The cross-platform plotting library - OxyPlot - is now available for Webassembly using Blazor and SkiaSharp. This project is based on the original source by JensKrumsieck.
dotnet add package OxyPlot.SkiaSharp.Blazor
<PlotView Model=model style="height: 30vh"/>
@code{
private PlotModel model = new PlotModel();
...
protected override async Task OnInitializedAsync()
{
var data = GetSomeDataPoints(); //get datapoint array from somewhere
var spc = new LineSeries()
{
ItemsSource = data,
Title = "UV/Vis Data",
TrackerFormatString = "{0}<br/>{1}: {2:0.00} - {3}: {4:0.00}"
};
model.Series.Add(spc);
}
}
A note on fonts: in order to use a non-default font in WebAssembly, you need to embed it in your app as an embedded resource. Otherwise, OxyPlot.SkiaSharp will not be able to load it. Include all variants you need, like regular, bold, italic, etc.
Requirements:
* .NET 9.0
* SkiaSharp.Views.Blazor v3.116.1
* OxyPlot.SkiaSharp v2.2.0