File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -711,6 +711,45 @@ public virtual async Task AppendDataAsync(IEnumerable<TItem> items)
711
711
await InvokeVoidJsAsync ( "blazor_apexchart.appendData" , Options . Chart . Id , json ) ;
712
712
}
713
713
714
+ /// <summary>
715
+ /// This method allows you to append new data to the series arrays, referencing each series by name
716
+ /// </summary>
717
+ /// <param name="items">The dictinoary with the data array to append the existing series datasets, using the key as the series name.</param>
718
+ /// <remarks>
719
+ /// Links:
720
+ ///
721
+ /// <see href="https://apexcharts.github.io/Blazor-ApexCharts/methods/append-data">Blazor Example</see>,
722
+ /// <see href="https://apexcharts.com/docs/methods/#appendData">JavaScript Documentation</see>
723
+ /// </remarks>
724
+ public virtual async Task AppendDataBySeriesNameAsync ( Dictionary < string , IEnumerable < TItem > > items )
725
+ {
726
+ if ( IsNoAxisChart )
727
+ {
728
+ throw new Exception ( $ "{ typeof ( ApexChart < TItem > ) } .{ nameof ( AppendDataBySeriesNameAsync ) } : Operation not valid for no axis charts.") ;
729
+ }
730
+
731
+ var seriesList = new List < AppendData < TItem > > ( ) ;
732
+
733
+ foreach ( var apxSeries in Options . Series )
734
+ {
735
+ if ( items . ContainsKey ( apxSeries . Name ) )
736
+ {
737
+ var data = apxSeries . ApexSeries . GenerateDataPoints ( items [ apxSeries . Name ] ) ;
738
+ var updatedData = apxSeries . Data . ToList ( ) ;
739
+ updatedData . AddRange ( data ) ;
740
+ apxSeries . Data = updatedData ;
741
+
742
+ seriesList . Add ( new AppendData < TItem >
743
+ {
744
+ Data = data
745
+ } ) ; ;
746
+ }
747
+ }
748
+
749
+ var json = Serialize ( seriesList ) ;
750
+ await InvokeVoidJsAsync ( "blazor_apexchart.appendData" , Options . Chart . Id , json ) ;
751
+ }
752
+
714
753
/// <summary>
715
754
/// Manually zoom into the chart with the start and end X values.
716
755
/// </summary>
You can’t perform that action at this time.
0 commit comments