Skip to content

Commit 209ea16

Browse files
committed
Add async methods for chart data management
This commit introduces several asynchronous methods across multiple chart classes, including BarChart, DoughnutChart, LineChart, PieChart, PolarAreaChart, RadarChart, and ScatterChart. Each class now features methods for adding data entries and datasets, initializing the chart with data and options, and updating the chart with new data and options. The methods are well-documented with XML comments detailing their functionality, parameters, and return types. Versioning and description attributes have been added for improved documentation. The `AddDataAsync` method has been enhanced to support both single dataset entries and collections, increasing the flexibility of the chart components. Additionally, the `RadarChart` and `ScatterChart` classes have a previously existing method commented out, suggesting it may no longer be necessary. NOTE: This commit message is auto-generated using GitHub Copilot.
1 parent b39d4f1 commit 209ea16

7 files changed

Lines changed: 359 additions & 4 deletions

File tree

BlazorExpress.ChartJS/ChartComponents/BarChart.razor.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ public BarChart()
1313

1414
#region Methods
1515

16+
/// <summary>
17+
/// Asynchronously adds a new data entry to the specified chart data.
18+
/// </summary>
19+
/// <param name="chartData">The chart data to which the new entry will be added.</param>
20+
/// <param name="dataLabel">The label associated with the new data entry.</param>
21+
/// <param name="data">The dataset containing the data to be added.</param>
22+
/// <returns>A task representing the asynchronous operation, with a result of the updated <see cref="ChartData"/>.</returns>
23+
[AddedVersion("1.0.0")]
24+
[Description("Asynchronously adds a new data entry to the specified chart data.")]
1625
public override async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IChartDatasetData data)
1726
{
1827
if (chartData is null)
@@ -34,6 +43,16 @@ public override async Task<ChartData> AddDataAsync(ChartData chartData, string d
3443
return chartData;
3544
}
3645

46+
/// <summary>
47+
/// Asynchronously adds a new dataset to the specified chart data.
48+
/// </summary>
49+
/// <param name="chartData">The chart data to which the dataset will be added.</param>
50+
/// <param name="dataLabel">The label for the new dataset.</param>
51+
/// <param name="data">A read-only collection of data points to be included in the new dataset.</param>
52+
/// <returns>A task that represents the asynchronous operation. The task result contains the updated chart data with the new
53+
/// dataset added.</returns>
54+
[AddedVersion("1.0.0")]
55+
[Description("Asynchronously adds a new dataset to the specified chart data.")]
3756
public override async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IReadOnlyCollection<IChartDatasetData> data)
3857
{
3958
if (chartData is null)
@@ -79,6 +98,16 @@ public override async Task<ChartData> AddDataAsync(ChartData chartData, string d
7998
return chartData;
8099
}
81100

101+
/// <summary>
102+
/// Asynchronously adds a dataset to the specified chart data.
103+
/// </summary>
104+
/// <param name="chartData">The chart data to which the dataset will be added.</param>
105+
/// <param name="chartDataset">The dataset to add to the chart data.</param>
106+
/// <param name="chartOptions">The options that configure the chart's appearance and behavior.</param>
107+
/// <returns>A task that represents the asynchronous operation. The task result contains the updated chart data with the new
108+
/// dataset added.</returns>
109+
[AddedVersion("1.0.0")]
110+
[Description("Asynchronously adds a dataset to the specified chart data.")]
82111
public override async Task<ChartData> AddDatasetAsync(ChartData chartData, IChartDataset chartDataset, IChartOptions chartOptions)
83112
{
84113
if (chartData is null)
@@ -99,6 +128,18 @@ public override async Task<ChartData> AddDatasetAsync(ChartData chartData, IChar
99128
return chartData;
100129
}
101130

131+
/// <summary>
132+
/// Asynchronously initializes the chart with the specified data and options.
133+
/// </summary>
134+
/// <remarks>This method prepares the chart for rendering by invoking the necessary JavaScript functions
135+
/// to set up the chart with the provided data and options. Ensure that <paramref name="chartData"/> contains valid
136+
/// datasets before calling this method.</remarks>
137+
/// <param name="chartData">The data to be used for the chart. Must contain at least one dataset.</param>
138+
/// <param name="chartOptions">The options to configure the chart's appearance and behavior.</param>
139+
/// <param name="plugins">An optional array of plugin identifiers to enhance the chart's functionality.</param>
140+
/// <returns>A task that represents the asynchronous initialization operation.</returns>
141+
[AddedVersion("1.0.0")]
142+
[Description("Asynchronously initializes the chart with the specified data and options.")]
102143
public override async Task InitializeAsync(ChartData chartData, IChartOptions chartOptions, string[]? plugins = null)
103144
{
104145
if (chartData is not null && chartData.Datasets is not null)
@@ -109,6 +150,16 @@ public override async Task InitializeAsync(ChartData chartData, IChartOptions ch
109150
}
110151
}
111152

153+
/// <summary>
154+
/// Asynchronously updates the chart with the specified data and options.
155+
/// </summary>
156+
/// <remarks>This method updates the chart by invoking a JavaScript function to render the new data and
157+
/// options. Ensure that <paramref name="chartData"/> contains valid datasets to avoid no operation.</remarks>
158+
/// <param name="chartData">The data to be displayed on the chart. Must not be null and must contain at least one dataset.</param>
159+
/// <param name="chartOptions">The options to configure the chart's appearance and behavior.</param>
160+
/// <returns></returns>
161+
[AddedVersion("1.0.0")]
162+
[Description("Asynchronously updates the chart with the specified data and options.")]
112163
public override async Task UpdateAsync(ChartData chartData, IChartOptions chartOptions)
113164
{
114165
if (chartData is not null && chartData.Datasets is not null)

BlazorExpress.ChartJS/ChartComponents/DoughnutChart.razor.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ public DoughnutChart()
1313

1414
#region Methods
1515

16+
/// <summary>
17+
/// Asynchronously adds a new data entry to the specified chart data.
18+
/// </summary>
19+
/// <param name="chartData">The chart data to which the new entry will be added.</param>
20+
/// <param name="dataLabel">The label associated with the new data entry.</param>
21+
/// <param name="data">The dataset containing the data to be added.</param>
22+
/// <returns>A task representing the asynchronous operation, with a result of the updated <see cref="ChartData"/>.</returns>
23+
[AddedVersion("1.0.0")]
24+
[Description("Asynchronously adds a new data entry to the specified chart data.")]
1625
public override async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IChartDatasetData data)
1726
{
1827
if (chartData is null)
@@ -37,6 +46,16 @@ public override async Task<ChartData> AddDataAsync(ChartData chartData, string d
3746
return chartData;
3847
}
3948

49+
/// <summary>
50+
/// Asynchronously adds a new dataset to the specified chart data.
51+
/// </summary>
52+
/// <param name="chartData">The chart data to which the dataset will be added.</param>
53+
/// <param name="dataLabel">The label for the new dataset.</param>
54+
/// <param name="data">A read-only collection of data points to be included in the new dataset.</param>
55+
/// <returns>A task that represents the asynchronous operation. The task result contains the updated chart data with the new
56+
/// dataset added.</returns>
57+
[AddedVersion("1.0.0")]
58+
[Description("Asynchronously adds a new dataset to the specified chart data.")]
4059
public override async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IReadOnlyCollection<IChartDatasetData> data)
4160
{
4261
if (chartData is null)
@@ -85,6 +104,16 @@ public override async Task<ChartData> AddDataAsync(ChartData chartData, string d
85104
return chartData;
86105
}
87106

107+
/// <summary>
108+
/// Asynchronously adds a dataset to the specified chart data.
109+
/// </summary>
110+
/// <param name="chartData">The chart data to which the dataset will be added.</param>
111+
/// <param name="chartDataset">The dataset to add to the chart data.</param>
112+
/// <param name="chartOptions">The options that configure the chart's appearance and behavior.</param>
113+
/// <returns>A task that represents the asynchronous operation. The task result contains the updated chart data with the new
114+
/// dataset added.</returns>
115+
[AddedVersion("1.0.0")]
116+
[Description("Asynchronously adds a dataset to the specified chart data.")]
88117
public override async Task<ChartData> AddDatasetAsync(ChartData chartData, IChartDataset chartDataset, IChartOptions chartOptions)
89118
{
90119
if (chartData is null)
@@ -105,6 +134,18 @@ public override async Task<ChartData> AddDatasetAsync(ChartData chartData, IChar
105134
return chartData;
106135
}
107136

137+
/// <summary>
138+
/// Asynchronously initializes the chart with the specified data and options.
139+
/// </summary>
140+
/// <remarks>This method prepares the chart for rendering by invoking the necessary JavaScript functions
141+
/// to set up the chart with the provided data and options. Ensure that <paramref name="chartData"/> contains valid
142+
/// datasets before calling this method.</remarks>
143+
/// <param name="chartData">The data to be used for the chart. Must contain at least one dataset.</param>
144+
/// <param name="chartOptions">The options to configure the chart's appearance and behavior.</param>
145+
/// <param name="plugins">An optional array of plugin identifiers to enhance the chart's functionality.</param>
146+
/// <returns>A task that represents the asynchronous initialization operation.</returns>
147+
[AddedVersion("1.0.0")]
148+
[Description("Asynchronously initializes the chart with the specified data and options.")]
108149
public override async Task InitializeAsync(ChartData chartData, IChartOptions chartOptions, string[]? plugins = null)
109150
{
110151
if (chartData is not null && chartData.Datasets is not null)
@@ -115,6 +156,16 @@ public override async Task InitializeAsync(ChartData chartData, IChartOptions ch
115156
}
116157
}
117158

159+
/// <summary>
160+
/// Asynchronously updates the chart with the specified data and options.
161+
/// </summary>
162+
/// <remarks>This method updates the chart by invoking a JavaScript function to render the new data and
163+
/// options. Ensure that <paramref name="chartData"/> contains valid datasets to avoid no operation.</remarks>
164+
/// <param name="chartData">The data to be displayed on the chart. Must not be null and must contain at least one dataset.</param>
165+
/// <param name="chartOptions">The options to configure the chart's appearance and behavior.</param>
166+
/// <returns></returns>
167+
[AddedVersion("1.0.0")]
168+
[Description("Asynchronously updates the chart with the specified data and options.")]
118169
public override async Task UpdateAsync(ChartData chartData, IChartOptions chartOptions)
119170
{
120171
if (chartData is not null && chartData.Datasets is not null)

BlazorExpress.ChartJS/ChartComponents/LineChart.razor.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ public LineChart()
1313

1414
#region Methods
1515

16+
/// <summary>
17+
/// Asynchronously adds a new data entry to the specified chart data.
18+
/// </summary>
19+
/// <param name="chartData">The chart data to which the new entry will be added.</param>
20+
/// <param name="dataLabel">The label associated with the new data entry.</param>
21+
/// <param name="data">The dataset containing the data to be added.</param>
22+
/// <returns>A task representing the asynchronous operation, with a result of the updated <see cref="ChartData"/>.</returns>
23+
[AddedVersion("1.0.0")]
24+
[Description("Asynchronously adds a new data entry to the specified chart data.")]
1625
public override async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IChartDatasetData data)
1726
{
1827
if (chartData is null)
@@ -34,6 +43,16 @@ public override async Task<ChartData> AddDataAsync(ChartData chartData, string d
3443
return chartData;
3544
}
3645

46+
/// <summary>
47+
/// Asynchronously adds a new dataset to the specified chart data.
48+
/// </summary>
49+
/// <param name="chartData">The chart data to which the dataset will be added.</param>
50+
/// <param name="dataLabel">The label for the new dataset.</param>
51+
/// <param name="data">A read-only collection of data points to be included in the new dataset.</param>
52+
/// <returns>A task that represents the asynchronous operation. The task result contains the updated chart data with the new
53+
/// dataset added.</returns>
54+
[AddedVersion("1.0.0")]
55+
[Description("Asynchronously adds a new dataset to the specified chart data.")]
3756
public override async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IReadOnlyCollection<IChartDatasetData> data)
3857
{
3958
if (chartData is null)
@@ -79,6 +98,16 @@ public override async Task<ChartData> AddDataAsync(ChartData chartData, string d
7998
return chartData;
8099
}
81100

101+
/// <summary>
102+
/// Asynchronously adds a dataset to the specified chart data.
103+
/// </summary>
104+
/// <param name="chartData">The chart data to which the dataset will be added.</param>
105+
/// <param name="chartDataset">The dataset to add to the chart data.</param>
106+
/// <param name="chartOptions">The options that configure the chart's appearance and behavior.</param>
107+
/// <returns>A task that represents the asynchronous operation. The task result contains the updated chart data with the new
108+
/// dataset added.</returns>
109+
[AddedVersion("1.0.0")]
110+
[Description("Asynchronously adds a dataset to the specified chart data.")]
82111
public override async Task<ChartData> AddDatasetAsync(ChartData chartData, IChartDataset chartDataset, IChartOptions chartOptions)
83112
{
84113
if (chartData is null)
@@ -99,6 +128,18 @@ public override async Task<ChartData> AddDatasetAsync(ChartData chartData, IChar
99128
return chartData;
100129
}
101130

131+
/// <summary>
132+
/// Asynchronously initializes the chart with the specified data and options.
133+
/// </summary>
134+
/// <remarks>This method prepares the chart for rendering by invoking the necessary JavaScript functions
135+
/// to set up the chart with the provided data and options. Ensure that <paramref name="chartData"/> contains valid
136+
/// datasets before calling this method.</remarks>
137+
/// <param name="chartData">The data to be used for the chart. Must contain at least one dataset.</param>
138+
/// <param name="chartOptions">The options to configure the chart's appearance and behavior.</param>
139+
/// <param name="plugins">An optional array of plugin identifiers to enhance the chart's functionality.</param>
140+
/// <returns>A task that represents the asynchronous initialization operation.</returns>
141+
[AddedVersion("1.0.0")]
142+
[Description("Asynchronously initializes the chart with the specified data and options.")]
102143
public override async Task InitializeAsync(ChartData chartData, IChartOptions chartOptions, string[]? plugins = null)
103144
{
104145
if (chartData is null)
@@ -115,6 +156,16 @@ public override async Task InitializeAsync(ChartData chartData, IChartOptions ch
115156
await JSRuntime.InvokeVoidAsync(LineChartInterop.Initialize, Id, GetChartType(), data, (LineChartOptions)chartOptions, plugins);
116157
}
117158

159+
/// <summary>
160+
/// Asynchronously updates the chart with the specified data and options.
161+
/// </summary>
162+
/// <remarks>This method updates the chart by invoking a JavaScript function to render the new data and
163+
/// options. Ensure that <paramref name="chartData"/> contains valid datasets to avoid no operation.</remarks>
164+
/// <param name="chartData">The data to be displayed on the chart. Must not be null and must contain at least one dataset.</param>
165+
/// <param name="chartOptions">The options to configure the chart's appearance and behavior.</param>
166+
/// <returns></returns>
167+
[AddedVersion("1.0.0")]
168+
[Description("Asynchronously updates the chart with the specified data and options.")]
118169
public override async Task UpdateAsync(ChartData chartData, IChartOptions chartOptions)
119170
{
120171
if (chartData is null)

0 commit comments

Comments
 (0)