Skip to content

mr-azazael/LightweightCharts.Blazor

Repository files navigation

LightweightCharts for Blazor

A blazor wrapper for TradingView's Lightweight Charts javascript library.

Installing

Install the package via the NuGet package manager.
Add the script imports to your root html file (index.html or _Layout.cshtml).

<script src="_content/LightweightCharts.Blazor/lightweight-charts.scripts.js"></script>
<script src="_content/LightweightCharts.Blazor/lightweight-charts.standalone.js"></script>

How to use it

Add the chart component to your razor file.

@using LightweightCharts.Blazor.Charts
<ChartComponent @ref="Chart" />

Wait for the chart component to finish its initialization, then use the exposed api methods to add data series to it.

await Chart.InitializationCompleted;
var series = await Chart.AddLineSeriesAsync();

The Github repository contains a demo project with several examples (all available series, custom options, multiple series in a chart, multiple charts, etc.).

Limitations

Synchronous methods can't be forwarded to c# code. Because of this, some options can be set only from javascript. The demo project contains an example that offers a workaround. Known options not available in c# wrappers are:

  • TimeScale options tickMarkFormatter;
  • Series options autoscaleInfoProvider;

Debugging

Clone the LightweightCharts.Blazor project and add a project reference to it in your blazor client.
The contents of 'lightweight-charts.standalone.js' can be replaced with the development version to debug the javascript library.

About

A blazor wrapper for TradingView's Lightweight Charts javascript library.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published