Skip to content

DrawnLabelVisual lacks public access to Text, TextSize, Paint, and Padding properties #2124

@Evan260

Description

@Evan260

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:

  1. 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.

  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions