BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
It is a problem in my app that the legend text color only can be black. It looks like in the xamarin version you can set
ChartLegendLabelStyle text color to what you wish. When will that be possible in the .nat mau version ?
--
Eigil
Hi Eigil,
Yes, it is possible to change the text color of the legend in MAUI by setting the ItemTemplate property of the legend to the desired color.
Here 's an example:
<chart:SfCartesianChart.Resources> <ResourceDictionary> <converter:BrushToColorConverter x:Key="brushToColor" /> <DataTemplate x:Key="legendTemplate"> <Grid ColumnDefinitions="Auto,Auto" ColumnSpacing="5" Margin="5"> <BoxView Grid.Column="0" Color="{Binding IconBrush,Converter={StaticResource brushToColor}}"/> <Label Grid.Column="1" Text="{Binding Item.Label}" TextColor="{Binding IconBrush,Converter={StaticResource brushToColor}}"/> </Grid> </DataTemplate> </ResourceDictionary> </chart:SfCartesianChart.Resources>
<chart:SfCartesianChart.Legend> <chart:ChartLegend ItemTemplate="{StaticResource legendTemplate}"/> </chart:SfCartesianChart.Legend>
<chart:SplineSeries Label="Mobile" ItemsSource="{Binding Data}" XBindingPath="Year" YBindingPath="Mobile"> </chart:SplineSeries>
<chart:SplineSeries Label="Labtop" ItemsSource="{Binding Data}" XBindingPath="Year" YBindingPath="LapTop"> </chart:SplineSeries> |
In below attached the sample for reference. I hope this helps!
Regards,
Sowndharya Selladurai.
Thank you very much !!
--
Eigil