https://github.com/syncfusionexamples/how-to-collapse-the-visibility-of-specific-data-label-in-.net-maui-cartesian-chart
This article in the Syncfusion Knowledge Base explains how to collapse the visibility of specific data label in .NET MAUI Cartesian chart
https://github.com/syncfusionexamples/how-to-collapse-the-visibility-of-specific-data-label-in-.net-maui-cartesian-chart
charting-library charts column-chart data-label data-label-customization data-label-visibility data-visualization hide-data-label maui-charts
Last synced: about 2 months ago
JSON representation
This article in the Syncfusion Knowledge Base explains how to collapse the visibility of specific data label in .NET MAUI Cartesian chart
- Host: GitHub
- URL: https://github.com/syncfusionexamples/how-to-collapse-the-visibility-of-specific-data-label-in-.net-maui-cartesian-chart
- Owner: SyncfusionExamples
- Created: 2024-04-26T11:24:12.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-14T05:34:18.000Z (about 1 year ago)
- Last Synced: 2025-02-08T20:47:54.001Z (3 months ago)
- Topics: charting-library, charts, column-chart, data-label, data-label-customization, data-label-visibility, data-visualization, hide-data-label, maui-charts
- Language: C#
- Homepage:
- Size: 234 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# How-to-collapse-the-visibility-of-specific-data-label-in-.NET-MAUI-Cartesian-chart
This article in the Syncfusion Knowledge Base explains how to collapse the visibility of specific data label in .NET MAUI Cartesian chartCollapsing the visibility of specific data labels in [Cartesian charts](https://www.syncfusion.com/maui-controls/maui-cartesian-charts) can be a useful way to improve your visualisation and focus on the most important data points.
This article will explain the step to hide or collapse specific data labels in a Cartesian chart.**Step 1:** Define a data label template for the series.
**[XAML]**
```
```
**Step 2:** Create a value to visibility converter to control the visibility of the data label based on the Y-value. For example, in the following converter, we have collapsed the visibility of the data label for values less than 50.**[C#]**
```
public class VisibilityConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (!(value is double labelValue))
return null;if (labelValue < 50)
return false;
return true;
}public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
return value;
}
}
```
**Step 3:** To control the visibility, bind the converter to the DataTemplate layout IsVisible property**[XAML]**
```
```
**Step 4:** Set the defined DataTemplate to the [LabelTemplate](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartSeries.html#Syncfusion_Maui_Charts_ChartSeries_LabelTemplate) property of [ColumnSeries](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ColumnSeries.html).**[XAML]**
```. . .
```
**Output**
