Pie Chart initial selection

2 posts, 0 answers
  1. Roland
    Roland avatar
    10 posts
    Member since:
    Jul 2011

    Posted 04 Dec 2012 Link to this post


    I have a data bound Pie Chart with single selection enabled.  What I want to do is after the ItemsSource has been loaded (asynchronously) is to have the first item in the chart selected.  How can I do this?

    I've tried calling ChartArea.SelectItem(index) right after the data has been loaded, but the chart series and items are still not created at that point.  Also tried calling SelectItem on various events (ItemDataBound, DataBound, Loaded), but to no avail.
  2. Missing user
    Missing user avatar

    Posted 07 Dec 2012 Link to this post

    Hi Roland,

    The reason why the pie chart cannot select a default item is because interactivity settings are meant to be used with a mouse and the selection fails when the chart hasn't been rendered yet.

    You can, however, use the following workaround involving a combination of the DataBound and LayoutUpdated events:
    void RadChart1_DataBound(object sender, Telerik.Windows.Controls.Charting.ChartDataBoundEventArgs e)
        if (!this.TrySelectItem())
            this.RadChart1.LayoutUpdated += this.RadChart1_LayoutUpdated;
    void RadChart1_LayoutUpdated(object sender, EventArgs e)
        if (this.TrySelectItem())
            this.RadChart1.LayoutUpdated -= this.RadChart1_LayoutUpdated;
    private bool TrySelectItem()
        return this.RadChart1.DefaultView.ChartArea.SelectedItems.Count != 0;

    Kind regards,
    Ivan N.
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top