[PR #2086] [MERGED] [FEAT] - Add Fill property to RadzenSeriesDataLabels for customizing text color, default behavior is preserved when Fill is not specified. #3066

Closed
opened 2026-01-29 18:21:46 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/radzenhq/radzen-blazor/pull/2086
Author: @pedro-cons
Created: 4/11/2025
Status: Merged
Merged: 4/11/2025
Merged by: @akorchev

Base: masterHead: feature/add-fill-datalabel


📝 Commits (1)

  • f367c6d [FEAT] - Add Fill property to RadzenSeriesDataLabels for customizing text color, default behavior is preserved when Fill is not specified.

📊 Changes

4 files changed (+18 additions, -3 deletions)

View changed files

📝 Radzen.Blazor/RadzenSeriesDataLabels.razor (+1 -1)
📝 Radzen.Blazor/RadzenSeriesDataLabels.razor.cs (+11 -0)
📝 Radzen.Blazor/Rendering/ChartDataLabel.cs (+5 -1)
📝 RadzenBlazorDemos/Pages/StackedAreaChartConfig.razor (+1 -1)

📄 Description

This PR introduces support for a Fill property in RadzenSeriesDataLabels, similar to what was done in #1789 for RadzenSeriesAnnotation.

What's new
Allows setting a custom text color for data labels using Fill="{color}"

This PR addresses issue #2056, which requests support for customizing the text color of data labels in charts.

I’ve added the Fill support with this snippet:

<RadzenSeriesDataLabels Visible="@showDataLabels" Fill="white" />

<Text @key="@($"{label.Position}-{Chart.Series.IndexOf(series)}")"
      Value="@label.Text" Position="@label.Position" Fill="@Fill"
      TextAnchor="@label.TextAnchor" class="@GetSeriesDataLabelClass()" />

public string GetSeriesDataLabelClass() =>
    string.IsNullOrWhiteSpace(Fill) ? "rz-series-data-label" : "rz-series-data-label-fill";

https://github.com/user-attachments/assets/819b9e12-9add-470f-8a7a-1d13b4c8c6ec

Preserves existing styling when Fill is not set

Added logic in rendering to apply a new CSS class when Fill is used

Tested
Verified the rendering of different text colors with the new Fill attribute

Confirmed no impact on existing behavior when Fill is not specified

Let me know if you’d like me to include additional tests or documentation.

Thanks!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/radzenhq/radzen-blazor/pull/2086 **Author:** [@pedro-cons](https://github.com/pedro-cons) **Created:** 4/11/2025 **Status:** ✅ Merged **Merged:** 4/11/2025 **Merged by:** [@akorchev](https://github.com/akorchev) **Base:** `master` ← **Head:** `feature/add-fill-datalabel` --- ### 📝 Commits (1) - [`f367c6d`](https://github.com/radzenhq/radzen-blazor/commit/f367c6d123539b32d1fdd426b1a6876eb4005c38) [FEAT] - Add Fill property to RadzenSeriesDataLabels for customizing text color, default behavior is preserved when Fill is not specified. ### 📊 Changes **4 files changed** (+18 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `Radzen.Blazor/RadzenSeriesDataLabels.razor` (+1 -1) 📝 `Radzen.Blazor/RadzenSeriesDataLabels.razor.cs` (+11 -0) 📝 `Radzen.Blazor/Rendering/ChartDataLabel.cs` (+5 -1) 📝 `RadzenBlazorDemos/Pages/StackedAreaChartConfig.razor` (+1 -1) </details> ### 📄 Description ### This PR introduces support for a Fill property in RadzenSeriesDataLabels, similar to what was done in #1789 for RadzenSeriesAnnotation. **What's new** Allows setting a custom text color for data labels using Fill="{color}" This PR addresses [issue #2056](https://github.com/radzenhq/radzen-blazor/issues/2056), which requests support for customizing the text color of data labels in charts. I’ve added the Fill support with this snippet: ``` <RadzenSeriesDataLabels Visible="@showDataLabels" Fill="white" /> <Text @key="@($"{label.Position}-{Chart.Series.IndexOf(series)}")" Value="@label.Text" Position="@label.Position" Fill="@Fill" TextAnchor="@label.TextAnchor" class="@GetSeriesDataLabelClass()" /> public string GetSeriesDataLabelClass() => string.IsNullOrWhiteSpace(Fill) ? "rz-series-data-label" : "rz-series-data-label-fill"; ``` https://github.com/user-attachments/assets/819b9e12-9add-470f-8a7a-1d13b4c8c6ec Preserves existing styling when Fill is not set Added logic in rendering to apply a new CSS class when Fill is used **Tested** Verified the rendering of different text colors with the new Fill attribute Confirmed no impact on existing behavior when Fill is not specified Let me know if you’d like me to include additional tests or documentation. Thanks! --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 18:21:46 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#3066