Hi All,
I am using DataItemMouseLeftButtonDown event for capturing the click on the data point. My code as follows,
private void Chart_DataItemMouseLeftButtonDown(object sender, Infragistics.Silverlight.Chart.DataItemMouseEventArgs e){DataPointTemplate shape = e.Element as DataPointTemplate;//Check to see if cast was successfulif (shape != null){//Try to cast the DataPointTemplate object to DataPoint DataPoint point = shape.DataPoint;}}
This code works fine for Bar charts and Column charts. But in Line chart, the Shape returned is Ellipse, and in Doughnut chart it is Path. So the conversion to Datapointtemplate fails. I am unable to get the data point value, where I clicked. Kindly help me on this. Thanks.
private void XamWebChart_DataItemMouseLeftButtonDown(object sender, Infragistics.Silverlight.Chart.DataItemMouseEventArgs e) { DataPointTemplate shape = e.Element as DataPointTemplate; if (shape != null) { DataPoint point = shape.DataPoint; MessageBox.Show(point.Value.ToString()); } }
This work for you?
-Graham
How i can do the same for the column type chart. casting it to shape is returning a null.
Excellent Graham. It solves my problem. Thanks a lot.
for comparison, here is the handler for a doughnut chart:
private void theChart_DataItemMouseLeftButtonDown(object sender, Infragistics.Silverlight.Chart.DataItemMouseEventArgs e)
{
Shape s = e.Element as Shape;
if (s != null && s.Tag != null && s.Tag is Dictionary<Type, object>)
Dictionary<Type, object> dict = (Dictionary<Type, object>)s.Tag;
MessageBox.Show(((DataPoint)dict[typeof(DataPoint)]).Label);
}
If you have use cases for more simply obtaining the clicked datapoint on this type of chart you can make a feature request here: https://ko.infragistics.com/community/ideas