Description
After upgrading to LiveCharts2 2.0.0, LabelVisual is marked obsolete with the message "Use DrawnLabelVisual instead." However, DrawnLabelVisual is not a compatible replacement — it lacks public access to the Text, TextSize, Paint, and Padding properties that LabelVisual exposes via BaseLabelVisual.
The problem
LabelVisual inherits from BaseLabelVisual<LabelGeometry>, which exposes Text, TextSize, Paint, Padding, etc. as public properties.
DrawnLabelVisual inherits from Visual, which only exposes Easing, AnimationSpeed, Tag, and IsVisible. The underlying LabelGeometry (which has all the needed properties) is stored in a private field _drawnElement and the DrawnElement property is not publicly accessible.
This means:
-
Creating a DrawnLabelVisual is possible via the constructor: new DrawnLabelVisual(new LabelGeometry { Text = "Title", TextSize = 16, Paint = paint }) — but the caller must keep their own reference to the LabelGeometry to read values back later.
-
Reading properties back from an existing DrawnLabelVisual (e.g., from chart.Title) is impossible without reflection, since there is no public API to access the inner geometry.
Use case
A common pattern is setting a chart title and later reading it back:
// Setting a title (works with both old and new API)
chart.Title = new LabelVisual { Text = "Revenue", TextSize = 16, Paint = paint };
// Later, reading the title text back (e.g., for export, expanded view, accessibility)
if (chart.Title is LabelVisual label)
return label.Text; // ✅ Works with LabelVisual
// ❌ No equivalent with DrawnLabelVisual
Suggestion
Either:
- Make
DrawnElement (or a typed property like Geometry) public on DrawnLabelVisual so consumers can access Text, TextSize, etc.
- Or add convenience properties on
DrawnLabelVisual that delegate to the inner geometry.
Environment
- LiveChartsCore.SkiaSharpView 2.0.0
- LiveChartsCore.SkiaSharpView.Avalonia 2.0.0
- .NET 10
Description
After upgrading to LiveCharts2 2.0.0,
LabelVisualis marked obsolete with the message "Use DrawnLabelVisual instead." However,DrawnLabelVisualis not a compatible replacement — it lacks public access to theText,TextSize,Paint, andPaddingproperties thatLabelVisualexposes viaBaseLabelVisual.The problem
LabelVisualinherits fromBaseLabelVisual<LabelGeometry>, which exposesText,TextSize,Paint,Padding, etc. as public properties.DrawnLabelVisualinherits fromVisual, which only exposesEasing,AnimationSpeed,Tag, andIsVisible. The underlyingLabelGeometry(which has all the needed properties) is stored in a private field_drawnElementand theDrawnElementproperty is not publicly accessible.This means:
Creating a
DrawnLabelVisualis possible via the constructor:new DrawnLabelVisual(new LabelGeometry { Text = "Title", TextSize = 16, Paint = paint })— but the caller must keep their own reference to theLabelGeometryto read values back later.Reading properties back from an existing
DrawnLabelVisual(e.g., fromchart.Title) is impossible without reflection, since there is no public API to access the inner geometry.Use case
A common pattern is setting a chart title and later reading it back:
Suggestion
Either:
DrawnElement(or a typed property likeGeometry) public onDrawnLabelVisualso consumers can accessText,TextSize, etc.DrawnLabelVisualthat delegate to the inner geometry.Environment