Blazor-ApexCharts icon indicating copy to clipboard operation
Blazor-ApexCharts copied to clipboard

add wrapper code for appendSeries

Open technyon opened this issue 9 months ago • 4 comments

Expose apex charts appendSeries method in C# code

technyon avatar May 08 '24 05:05 technyon

Hi,

Thank you

Do you have a description of this pull request? No sure how the changes to the realtime sample connects to the append series.

joadan avatar May 08 '24 05:05 joadan

I've added a description.

RealTime.razor was just VS formatting things it shoudn't.

technyon avatar May 08 '24 06:05 technyon

Sorry if I'm missing something here but adding series dynamically should be preformed using the razor syntax, like example https://apexcharts.github.io/Blazor-ApexCharts/features/dynamic-series

By adding it in code there is a mismatch between the two.

joadan avatar May 08 '24 06:05 joadan

I believe in that example it works because after adding the series you call

await chart?.UpdateSeriesAsync(true);

In this chart it's ok because it's static data. In a realtime line chart, calling UpdateSeriesAsync will cause animations to trigger and the data to be reset. I'm honestly just trying to figure out how things are supposed to be done, because they are documented for specific cases only.

I need:

  • a realtime chart
  • with zoom, panning and so on
  • and the ability to add series dynamically

So far it works, but I have a feeling apex charts isn't made for realtime data. Still many quirk when it comes to dynamic data, unfortunately I didn't find a better alternative so far.

technyon avatar May 08 '24 06:05 technyon

Yeah one thing that found in realtime charts is that you can not use the toolbar, which means you can no do interactive zooming and panning. I don't know if there is any plan around this thing because that will be super useful.

aoun-muhammad avatar May 09 '24 10:05 aoun-muhammad

You can actually, but it's tricky. Instead of setting the range, every time after appending data to the chart you call c. Then detect via OnZoomed and OnScrolled events if the user is zooming or panning, and suppress calls to ZoomXAsync during this time.

I have actually opened an issue about this at apex charts, all of this should be handled internally by the chart:

https://github.com/apexcharts/apexcharts.js/issues/4423

I'm not too optimistic anything will happen there soon though.

technyon avatar May 10 '24 00:05 technyon

@technyon, Thank you I now understand the issue. I'll merge this.

joadan avatar May 13 '24 19:05 joadan