We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Hide AdornmentInfo on SfChart

Hello,
I am currently using SfChart in a UWP application that display data, using a ColumnSerie for each day of the month.
I use ChartAdornmentInfo , to display the current value into the center of the corresponding column, rotated by 90 degrees.
When running on a mobile, it takes about 3 to 5 seconds to refresh the 30 columns, on desktop it runs really fast.
When I remove the AdornmentInfo, it runs faster on Mobile (the delay is acceptable).
So my question is : How can I speed up things? Or is there a way to hide the AdornmentInfo when on mobile (code behind or xaml) ? I tried to set the ShowLabel to false using an adaptive trigger but although the label does not display, it still tales time to render the chart.

Thank you a lot !

Here's the xaml :

  <charts:SfChart Grid.Row="1"
                        Margin="0,10,0,0"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center">

            <charts:SfChart.PrimaryAxis>
                <charts:DateTimeCategoryAxis x:Uid="Day" 
                                                 LabelFormat="dd"
                                             LabelsPosition="Outside"
                                                 Interval="2">
                </charts:DateTimeCategoryAxis>
            </charts:SfChart.PrimaryAxis>

            <charts:SfChart.SecondaryAxis>
                <charts:NumericalAxis Minimum="0"
                                      Header="KW"
                                      TickLineSize="10"/>
            </charts:SfChart.SecondaryAxis>

            <charts:ColumnSeries ItemsSource="{Binding DayPoints}"
                                 Interior="{StaticResource SystemControlBackgroundAccentBrush}"
                                 XBindingPath="Label"
                                 YBindingPath="Value">

                <charts:ColumnSeries.AdornmentsInfo>

                    <charts:ChartAdornmentInfo SegmentLabelContent="YValue"
                                               ShowLabel="True"
                                               HighlightOnSelection="True"
                                               AdornmentsPosition="TopAndBottom" >
                        <charts:ChartAdornmentInfo.LabelTemplate>
                            <DataTemplate>
                                <!--LabelTemplate for Segments.A TextBlock inside each Segments-->
                               <TextBlock Foreground="White" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold" Text="{Binding}" RenderTransformOrigin="0.5,0.5">
                                    <TextBlock.RenderTransform>
                                        <RotateTransform Angle="-90"/>
                                    </TextBlock.RenderTransform>
                                </TextBlock>
                            
                            </DataTemplate>
                        </charts:ChartAdornmentInfo.LabelTemplate>
                    </charts:ChartAdornmentInfo>
                </charts:ColumnSeries.AdornmentsInfo>
            </charts:ColumnSeries>

        </charts:SfChart>

3 Replies

SA Santhiya Arulsamy Syncfusion Team November 13, 2015 12:19 PM UTC

Hi Jean,

Thanks for contacting Syncfusion support.

You can achieve your requirement by creating a separate view “DeviceFamily-Mobile” for mobile. We have prepared the sample for your reference. Please find the sample from the following location.

Sample: ColumnChart

Thanks,

Santhiya A.


JL Jean Lapie November 13, 2015 01:20 PM UTC

Thank you,
I will have a lookt at this. But I'll have to maintain 2 views for nearly the same feature.
Is it possible to have a resource with the AdornmentInfo in xaml, and set it on the SfChart via code behind maybe, when needed ( = when not on mobile) ?
I think it would we easier to maintain only one view.

Best regards,



RA Rachel A Syncfusion Team November 16, 2015 01:08 PM UTC

Hi Jean,

Thanks for the update.

We can define the ChartAdornmentInfo as resource in App.Xaml and set the adornment in code behind if the DeviceFamily is not Mobile as in the below code example.

[XAML]

   <Application.Resources>

        <chart:ChartAdornmentInfo x:Key="adornment" ShowLabel="True"></chart:ChartAdornmentInfo>
    </Application.Resources>

[C#]

if (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily != "Windows.Mobile")
                (chart1.Series[0] as ColumnSeries).AdornmentsInfo = App.Current.Resources["adornment"] as ChartAdornmentInfo;


Regards,
Rachel. A

Loader.
Up arrow icon