Skip to content

Pie chart what slice was clicked

New Discussion
Darin Horton
Darin Horton asked on Jun 24, 2026 7:59 PM

I am using the ultradatapiechart and i am trapping a mouse click on it. I need to know what slice was clicked. How would i do that.

Sign In to post a reply

Replies

  • 0
    Bozhidara Pachilova
    Bozhidara Pachilova answered on Jun 25, 2026 9:50 AM

    Hi Darin,

    Thank you for posting to Infragistics Community!

    Most straightforward would be to handle the SelectedItemChanged event itself, i.e.:

    private void PieChart_SelectedItemChanged(object sender, SelectedItemChangedEventArgs e )
            {
                var item = e.NewItem as DataItem;
                if (item != null)
                {
                    MessageBox.Show($"You clicked on: {item.Label} with value: {item.Value}");
                }
            }

    If this must be done in the click event of the pie chart, though, a workaround might be needed. For example, I tested wrapping the selected item retrieval within a BeginInvoke action  to execute it asynchronously on the same thread. Testing on my side proves that in this way the selection is retrieved after the click has been registered and the newly selected item has been assigned. Without the action, the selection would be persisted after the click handler has been executed. Please, find attached a small sample demonstrating this.

    private void PieChart_Click(object sender, EventArgs e)
    {
        this.BeginInvoke(new Action(() =>
        {
            var selectedItem = pieChart.SelectedItem as DataItem;
            if (selectedItem != null)
            {
                MessageBox.Show($"You clicked on: {selectedItem.Label} with value: {selectedItem.Value}");
            }
        }));
    }

    In conclusion, ideally the first approach would be preferred. If going down the second route, please, make sure to fully test the implementation to ensure that everything would be working as expected.

    Best regards,
    Bozhidara Pachilova
    Software Developer

    Attachments:
  • 0
    Darin Horton
    Darin Horton answered on Jun 25, 2026 10:27 AM

    Thank you for this information.

    I was able to get it to work using:

    AddHandler piechart.SeriesClick, AddressOf Pie_SeriesClick

  • 0
    Anna Smith
    Anna Smith answered on Jul 3, 2026 12:28 PM

    To detect which slice of an UltraDataPieChart was clicked, you need to use the chart’s event arguments. The click event provides details about the mouse position and the slice index. Typically, you can access the ItemIndex or SeriesPoint from the event arguments, which corresponds to the slice that was clicked. This lets you identify the exact data point and take action based on it.

    nicview

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Darin Horton
Favorites
0
Replies
3
Created On
Jun 24, 2026
Last Post
2 months ago

Suggested Discussions

Tags

No tags

Created by

Created on

Jun 24, 2026 7:59 PM

Last activity on

Jun 24, 2026 7:59 PM