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
close icon

Different mouse events for each chart collumn?

Hi,
I need to click on a collumn, in a bar chart, and get a specific event. I know its possible to launch an event when cliking a series on the chart. My problem is, i need to get a different result for each collumn, and the event seems to be relative to the whole series.

Is there any way to do this, or at least to know in which collumn i have clicked?

It's really important for me to get this done, any help would be very appreciated.
Thanks.


1 Reply

AD Administrator Syncfusion Team May 12, 2008 04:43 AM UTC

Hi Tiago,

Thanks for your interest in Syncfusion products. ChartSeries click event does not return the column on which it was clicked, but using the MouseEventArgs of the event we can get the column of the chartseries.

The following lines of code can be used to get the chart point on which click was made.

C# Code:

Point pt = e.GetPosition((UIElement)sender);

//get the x axis value based on the clicked co - ordinates
double Xvalue = area.PointToValue(area.PrimaryAxis, pt);

//get the Y axis value based on the clicked co - ordinates
double Yvalue = area.PointToValue(area.SecondaryAxis, pt);


The following lines of code can be used to get the column on which click was made.

C# Code:

void ChartSeries1_Click(object sender, MouseEventArgs e)
{
ChartSeries series = (ChartSeries)sender;
HitTestResult hr = VisualTreeHelper.HitTest(this, e.GetPosition((UIElement)chart1.Areas[0]));

}

By using the VisualHit property of the HitTestResult, each chart column of the chart can be obtained.

Let me know if you have any queries.

Thanks for your interests Syncfusion products.

Regards,
Athaur




Loader.
Live Chat Icon For mobile
Up arrow icon