Charts
Lagoon does not provide a native chart component. To integrate charts into a Lagoon application, use a third-party Blazor package based on Chart.js and keep the integration separate from Lg* components.
Recommended package
The recommended package is Kebechet.Blazor.ChartJS:
- NuGet: https://www.nuget.org/packages/Kebechet.Blazor.ChartJS
- JavaScript engine: Chart.js
warning
Do not use ChartJs.Blazor anymore: this package is no longer maintained and includes Newtonsoft.Json.
Installation / integration
- Add the
Kebechet.Blazor.ChartJSNuGet package to your client project. - Follow the package instructions to reference Chart.js and the necessary scripts in your application.
- Create a Blazor component or page dedicated to the chart.
- Use the components and models provided by
Kebechet.Blazor.ChartJS; do not invent a Lagoon API for charts.
Usage example
The old documentation does not provide a complete example. The integration principle remains as follows:
ChartsPage.razor
@inherits LgPage
<LgFrame Title="#ChartsTitle">
<!-- Place here the component provided by Kebechet.Blazor.ChartJS. -->
</LgFrame>
ChartsPage.razor.cs
public partial class ChartsPage : LgPage
{
// Prepares the series and options expected by the chosen charts package.
protected override void OnInitialized()
{
base.OnInitialized();
}
}
Refer to the package documentation for the exact names of components, datasets, and options.