How to programmically update chart inside HubSection?

2 posts, 0 answers
  1. Melicaster
    Melicaster avatar
    3 posts
    Member since:
    Jun 2014

    Posted 17 Jan 2015 Link to this post

    I has been reading http://www.telerik.com/help/windows-8-xaml/radchart-series-doughnutseries.html and has successfully created the scenario based on the tutorial.

    However, I need the chart to work inside HubSection. The snippet of the my XAML as below:
    <HubSection Header="HubSection 2">
                    <DataTemplate>
                        <Grid>
                            <telerik:RadPieChart  x:Name="mychart" Width="300" Height="300" ClipToBounds="False" PaletteName="DefaultDark">
                                <telerik:DoughnutSeries ShowLabels="True">
                                    <telerik:DoughnutSeries.ValueBinding>
                                        <telerik:PropertyNameDataPointBinding PropertyName="Value"/>
                                    </telerik:DoughnutSeries.ValueBinding>
                                </telerik:DoughnutSeries>
                            </telerik:RadPieChart>
                        </Grid>
                    </DataTemplate>
                </HubSection>

    I need to periodically update the chart. So I couldn't use loaded. I only can search the control manually using VisualTreeHelper. How do I create the Donut Chart control manually? I know that we can create an control using below snippet:
    private TextBlock NoArticlesTextBlock;

    I search the child using snippet like below:
    static DependencyObject FindChildByName(DependencyObject from, string name)
            {
                int count = VisualTreeHelper.GetChildrenCount(from);
     
                for (int i = 0; i < count; i++)
                {
                    var child = VisualTreeHelper.GetChild(from, i);
                    if (child is FrameworkElement && ((FrameworkElement)child).Name == name)
                        return child;
     
                    var result = FindChildByName(child, name);
                    if (result != null)
                        return result;
                }
     
                return null;
            }

    Please advise. Thank you.
  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 21 Jan 2015 Link to this post

    Hi,

    This question is valid for any control and it is not specific for our chart. You already have one solution and an alternative would be to wrap the chart within a user control, where you will have access to the chart.

    Best regards,
    Ves
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top