Compare commits

...

4 Commits

Author SHA1 Message Date
Argo Zhang
d06670cb6f feat(Chart): add AddDataset method (#7354)
* doc: 更新示例

* feat(Chart): add AddDataset method
2025-12-17 13:54:12 +08:00
Argo Zhang
3aba824723 feat(Chart): add more Colors (#7353) 2025-12-17 12:59:52 +08:00
Argo Zhang
0d0bf5c3ed feat(Chart): support custome BackgroundColor (#7352)
* feat(Chart): add Hidden parameter on ChartDataset

* chore: update documentation

* feat(Chart): support custome BackgroundColor
2025-12-17 12:38:03 +08:00
Argo Zhang
264b9d6f5a feat(Chart): add Hidden parameter on ChartDataset (#7351) 2025-12-17 10:44:07 +08:00
4 changed files with 31 additions and 7 deletions

View File

@@ -29,7 +29,7 @@
<PackageReference Include="BootstrapBlazor.BarCode" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.BarcodeGenerator" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.BootstrapIcon" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.Chart" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.Chart" Version="10.0.1" />
<PackageReference Include="BootstrapBlazor.ChatBot" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.CherryMarkdown" Version="10.0.1" />
<PackageReference Include="BootstrapBlazor.CodeEditor" Version="10.0.0" />

View File

@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
@@ -67,7 +67,11 @@ public partial class Bar
ds.Labels = Enumerable.Range(1, _barDataCount).Select(i => i.ToString());
for (var index = 0; index < _barDatasetCount; index++)
{
ds.Data.Add(new ChartDataset() { Label = $"Set {index}", Data = Enumerable.Range(1, _barDataCount).Select(i => Random.Shared.Next(20, 37) / 10.0f).Cast<object>() });
ds.Data.Add(new ChartDataset()
{
Label = $"Set {index}",
Data = Enumerable.Range(1, _barDataCount).Select(i => Random.Shared.Next(20, 37) / 10.0f).Cast<object>()
});
}
return Task.FromResult(ds);

View File

@@ -1,4 +1,4 @@
@page "/chart/line"
@page "/chart/line"
@inject IStringLocalizer<Line> Localizer
@inject CodeSnippetService CodeSnippetService
@inherits WebSiteModuleComponentBase
@@ -11,8 +11,8 @@
<div class="btn-group">
<button class="btn btn-primary" @onclick="e => Utility.RandomData(_lineChart)"><i class="fa-solid fa-chart-line"></i><span>@Localizer["LineOnInitRandomData"]</span></button>
<button class="btn btn-primary" @onclick="OnReloadChart"><i class="fa-solid fa-chart-column"></i><span>@Localizer["LineOnInitReload"]</span></button>
<button class="btn btn-primary" @onclick="e => Utility.AddDataSet(_lineChart, ref _lineDatasetCount)"><i class="fa-solid fa-circle-plus"></i><span>@Localizer["LineOnInitAddDataset"]</span></button>
<button class="btn btn-primary" @onclick="e => Utility.RemoveDataSet(_lineChart, ref _lineDatasetCount)"><i class="fa-solid fa-circle-minus"></i><span>@Localizer["LineOnInitRemoveDataset"]</span></button>
<button class="btn btn-primary" @onclick="AddDataset"><i class="fa-solid fa-circle-plus"></i><span>@Localizer["LineOnInitAddDataset"]</span></button>
<button class="btn btn-primary" @onclick="RemoveDataset"><i class="fa-solid fa-circle-minus"></i><span>@Localizer["LineOnInitRemoveDataset"]</span></button>
<button class="btn btn-primary" @onclick="e => Utility.AddData(_lineChart, ref _lineDataCount)"><i class="fa-solid fa-plus"></i><span>@Localizer["LineOnInitAddingData"]</span></button>
<button class="btn btn-primary" @onclick="e => Utility.RemoveData(_lineChart, ref _lineDataCount)"><i class="fa-solid fa-minus"></i><span>@Localizer["LineOnInitRemoveData"]</span></button>
</div>

View File

@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
@@ -85,6 +85,26 @@ public partial class Line : IDisposable
}
}
private async Task AddDataset()
{
var dataset = new ChartDataset()
{
BorderWidth = _randomer.Next(1, 5),
Label = $"Set {DateTime.Now:mmss}",
Data = Enumerable.Range(1, _lineDataCount).Select((i, index) => (object)_randomer.Next(20, 37)),
ShowPointStyle = true,
PointStyle = chartPointStyles[_randomer.Next(0, 9)],
PointRadius = 5,
PointHoverRadius = 10
};
await _lineChart.AddDataset(dataset, 0);
}
private async Task RemoveDataset()
{
await _lineChart.RemoveDatasetAt(0);
}
/// <summary>
/// <inheritdoc/>
/// </summary>