Skip to content

WPF PieChart DataLabels and Colors Disappear after Series Update (via Timer or Refresh) #1934

@e11303

Description

@e11303

When I update my PieChart.Series in WPF (LiveCharts2 v2.0.0, .NET 8.0, OS: Windows 11), either by timer or manually refreshing, the PieChart loses its DataLabels and resets colors to default after the second or subsequent update.
This happens even if I assign a new array of PieSeries, and sometimes the chart only shows the percentage labels on the first render.

XAML:
<lvc:PieChart
x:Name="PieChartControl"
Series="{Binding PieSeries}"
LegendPosition="Bottom"
Height="300" Width="350"/>

C#:
private ISeries[] _pieSeries;
public ISeries[] PieSeries
{
get => _pieSeries;
set { _pieSeries = value; OnPropertyChanged(nameof(PieSeries)); }
}
// Timer every 1 minute:
PieSeries = Array.Empty();
PieSeries = pieData.Select(item => new PieSeries
{
Values = new double[] { item.Percent },
Name = item.Name,
DataLabelsPaint = WhitePaint,
DataLabelsPosition = PolarLabelsPosition.Middle,
DataLabelsFormatter = p => $"{item.Percent:F1}%",
ToolTipLabelFormatter = p => $"{item.Percent:F2}%"
}).ToArray();
OnPropertyChanged(nameof(PieSeries));
PieChartControl?.Invalidate(); // optional, does not fix the problem

I would greatly appreciate any guidance on how to resolve this issue, or if there is an official workaround available. Thank you for your support and for maintaining such an excellent charting library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions