Skip to content

Fix adding chart data label and chart dataset data #1083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions blazorbootstrap/Components/Charts/LineChart.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ public override async Task<ChartData> AddDataAsync(ChartData chartData, string d
throw new ArgumentNullException(nameof(data));

foreach (var dataset in chartData.Datasets)
if (dataset is LineChartDataset lineChartDataset && lineChartDataset.Label == dataLabel)
if (data is LineChartDatasetData lineChartDatasetData)
if (data is LineChartDatasetData lineChartDatasetData)
if (dataset is LineChartDataset lineChartDataset && lineChartDataset.Label == lineChartDatasetData.DatasetLabel)
{
chartData.Labels?.Add(dataLabel);
lineChartDataset.Data?.Add(lineChartDatasetData.Data as double?);
}


await JSRuntime.InvokeVoidAsync("window.blazorChart.line.addDatasetData", Id, dataLabel, data);

Expand Down
6 changes: 6 additions & 0 deletions blazorbootstrap/Models/Charts/ChartOptions/ChartOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,12 @@ private void SetTicksAlignment(TicksAlignment interactionMode) =>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Color { get; set; }

/// <summary>
/// Font of ticks
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartFont? Font { get; set; } = new();

/// <summary>
/// If <see langword="true" />, show tick labels.
/// </summary>
Expand Down