How to create a mouse click event for an element (point) from a pie chart?

I am creating an ASP.NET/C# website

I used the ASP.NET 4.0 chart control to draw a pie chart.

Is there a way to create an action when the user clicks on an element (point) with the mouse? For example, clicking an item, changing its color, or the user gets the name of the item or ...

Thanks for any help

Is there a way to create a mouse over an event on an element?

0
source share
1 answer

I’m sure that there are several options for interactivity for both ASP.NET and Windows Forms.

here: Interactivity (chart controls)

:

using System.Web.UI.DataVisualization.Charting;
...
// Set the legend cell to an image showing selection cleared
Chart1.Legends[0].CustomItems[0].Cells[0].Image = "./cleared.png";
Chart1.Legends[0].CustomItems[0].Cells[0].PostBackValue = "item 1";
// Add an ImageMapEventHandler to the Chart.Click event
this.Chart1.Click += new ImageMapEventHandler(this.Chart1_Click);
...
// Change the selection image when the user clicks on the legend cell
private void Chart1_Click(object sender, System.Web.UI.WebControls.ImageMapEventArgs e)
{
   if (e.PostBackValue == "item 1")
   {
      LegendCell cell = Chart1.Legends[0].CustomItems[0].Cells[0];
      cell.Image = (cell.Image == "./cleared.png") ? "./selected.png" : "./cleared.png";
   }
}

:

onmouseover=\"DisplayTooltip(' <img src=DetailedChart.aspx />');\"
+1

All Articles