Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Change size of Legend
posted

Hi,

I'm developing an app with xamarin.forms and I use the XamPieChart control to display some data.

The problem I have is with the legend. This will only show when there is enough space. So I wanted to change the size of the legend (font) but I can't seemed to find out how you change this.

I tried FormatLegendLabel event, but this does not include things to change the size.

Is there anybody that knows how to do this?

i'm using version 17.2.1051

<ig:XamPieChart Grid.Row="0"
                            Margin="0,10,0,0"
                            ItemsSource="{Binding Delays}"
                            ValueMemberPath="Value"
                            LabelMemberPath="Value"
                            LabelInnerColor="White"
                            LabelOuterColor="black"
                            LabelsPosition="BestFit"
                            Legend="{x:Reference legend1}"
                            LegendLabelMemberPath="Name"
                            AllowSliceExplosion="True"
                            AllowSliceSelection="True"
                            SliceClick="XamPieChart_SliceClick"
                            SelectedItem="{Binding SelectedItem}"
                            BackgroundColor="Transparent"
                            FontAttributes="Bold"
                            FormatLabel="XamPieChart_FormatLabel"
                            >
                <ig:XamPieChart.Brushes>
                    <igf:BrushCollection>
                        <igf:SolidColorBrush Color="{StaticResource JdnPink}" />
                        <igf:SolidColorBrush Color="{StaticResource JdnYellow}" />
                        <igf:SolidColorBrush Color="{StaticResource JdnGreen}" />
                        <igf:SolidColorBrush Color="{StaticResource JdnBlue}" />
                    </igf:BrushCollection>
                </ig:XamPieChart.Brushes>
                <ig:XamPieChart.Behaviors>
                    <b:EventToCommandBehavior Command="{Binding SliceClickCommand}" EventName="SliceClick" />
                </ig:XamPieChart.Behaviors>
            </ig:XamPieChart>
            <ig:ItemLegend x:Name="legend1" 
                           Grid.Row="2" 
                           Margin="0,10,10,0"
                           BackgroundColor="Transparent"
                           />
  • 34810
    Offline posted

    Hello Sebastian,

    I have been investigating into the ability to set the FontSize of the ItemLegend for the XamPieChart, and it does not appear that at the moment, any of the Font-related properties are exposed at a Xamarin.Forms portable level, and I am unable to see a way to set them.

    The only way that I can see at the moment to set these properties is to write the XamPieChart natively in the Xamarin.Android and Xamarin.iOS projects, as this will expose the native ItemLegend element where the various font-related properties are exposed. It may also be possible to do this with a custom PageRenderer, which you can read about here, but I am unsure how this could be achieved at the moment.

    The fact that these properties are not exposed at a Xamarin.Forms level is a bug in the ItemLegend and other legend-related controls. As such, I have asked our engineering staff to examine it further. To ensure that it receives attention, I have logged this behavior in our internal tracking systems with a development ID of 257809 and have created you a private support case that I will link to this issue so that you can be notified when a fix becomes available. This private case has an ID of CAS-198073-W8D7M6 and you can access it here.

    Please let me know if you have any other questions or concerns on this matter.