Unplanned
Last Updated: 14 Feb 2024 06:09 by ADMIN
Arif
Created on: 13 Feb 2024 11:48
Category: Chart
Type: Bug Report
0
Chart: [WinUI] Labels in bar series are cut, due to the VerticalAligment

Labels in bar series are cut, when setting the labels VerticalAligment to Top:

2 comments
ADMIN
Didi
Posted on: 14 Feb 2024 06:09

In general, the labels are cut in cases when 

1) Vertical alignment of the labels is top
the bar series that are almost on the top of the vertical axis

2) Vertical alignment of the labels is center

for bar series that have minimal value, text is cut:

 

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

ADMIN
Didi
Posted on: 13 Feb 2024 11:55

Solution:

The only option I can suggest is setting the vertical alignment to center using the native chart:

Subscribe to handler changed and set the vertical alignment to center:

    private void barChart_HandlerChanged(object sender, EventArgs e)
    {
        var platformView = this.barChart.Handler.PlatformView;
#if WINDOWS
        var platformChart = (Telerik.UI.Xaml.Controls.Chart.RadCartesianChart)platformView;
        var series = (Telerik.UI.Xaml.Controls.Chart.BarSeries)platformChart.Series[0];
       
        var labelDefinition = series.LabelDefinitions.FirstOrDefault();
        if (labelDefinition != null)
        {
            labelDefinition.HorizontalAlignment = Microsoft.UI.Xaml.HorizontalAlignment.Center;
            labelDefinition.VerticalAlignment = Microsoft.UI.Xaml.VerticalAlignment.Center;
        }
#endif
    }

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.