From 2050a21908ca46168eebe0fe0c4d2da9fb62a0c8 Mon Sep 17 00:00:00 2001 From: "jan-ole.schuemann@alstomgroup.com" Date: Fri, 9 Feb 2024 12:50:09 +0700 Subject: [PATCH 1/3] test --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index f3e6a8fb..79c8594b 100644 --- a/README.md +++ b/README.md @@ -91,4 +91,3 @@ Credits to [@thirstyape](https://github.com/thirstyape) for making production re [![Stargazers repo roster for @apexcharts/Blazor-ApexCharts](https://reporoster.com/stars/dark/apexcharts/Blazor-ApexCharts)](https://github.com/apexcharts/Blazor-ApexCharts/stargazers) - From b6b037479719094b8a84b56540890773a96d14ba Mon Sep 17 00:00:00 2001 From: "jan-ole.schuemann@alstomgroup.com" Date: Fri, 9 Feb 2024 13:05:25 +0700 Subject: [PATCH 2/3] add AppendDataBySeriesNameAsync() by name method --- src/Blazor-ApexCharts/ApexChart.razor.cs | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/Blazor-ApexCharts/ApexChart.razor.cs b/src/Blazor-ApexCharts/ApexChart.razor.cs index be6b8433..98b09d52 100644 --- a/src/Blazor-ApexCharts/ApexChart.razor.cs +++ b/src/Blazor-ApexCharts/ApexChart.razor.cs @@ -711,6 +711,45 @@ public virtual async Task AppendDataAsync(IEnumerable items) await InvokeVoidJsAsync("blazor_apexchart.appendData", Options.Chart.Id, json); } + /// + /// This method allows you to append new data to the series arrays, referencing each series by name + /// + /// The dictinoary with the data array to append the existing series datasets, using the key as the series name. + /// + /// Links: + /// + /// Blazor Example, + /// JavaScript Documentation + /// + public virtual async Task AppendDataBySeriesNameAsync(Dictionary> items) + { + if (IsNoAxisChart) + { + throw new Exception($"{typeof(ApexChart)}.{nameof(AppendDataBySeriesNameAsync)}: Operation not valid for no axis charts."); + } + + var seriesList = new List>(); + + foreach (var apxSeries in Options.Series) + { + if(items.ContainsKey(apxSeries.Name)) + { + var data = apxSeries.ApexSeries.GenerateDataPoints(items[apxSeries.Name]); + var updatedData = apxSeries.Data.ToList(); + updatedData.AddRange(data); + apxSeries.Data = updatedData; + + seriesList.Add(new AppendData + { + Data = data + }); ; + } + } + + var json = Serialize(seriesList); + await InvokeVoidJsAsync("blazor_apexchart.appendData", Options.Chart.Id, json); + } + /// /// Manually zoom into the chart with the start and end X values. /// From 47c77ff032e2afdb56962829bab3bd86526f82ff Mon Sep 17 00:00:00 2001 From: "jan-ole.schuemann@alstomgroup.com" Date: Fri, 9 Feb 2024 13:06:46 +0700 Subject: [PATCH 3/3] revert --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 79c8594b..f3e6a8fb 100644 --- a/README.md +++ b/README.md @@ -91,3 +91,4 @@ Credits to [@thirstyape](https://github.com/thirstyape) for making production re [![Stargazers repo roster for @apexcharts/Blazor-ApexCharts](https://reporoster.com/stars/dark/apexcharts/Blazor-ApexCharts)](https://github.com/apexcharts/Blazor-ApexCharts/stargazers) +