Hi,
I have a column chart. When I click on a column in the chart, I want that the selected column chart shows a selected style and I know which column is selected. Is there properties like "SelectedItem" or "IsSelected" for XamWebChart?
Hi jifangeva,
You can hook up the DataItemMouseLeftButtonDown event on your XamWebChart and use that to figure out what element you're clicking on. If the element is a ColumnChartDataPointTemplate, you can get that element and set the style as necessary. Here's what I did:
private void Chart1_DataItemMouseLeftButtonDown(object sender, DataItemMouseEventArgs e) { if (e.Element as ColumnChartDataPointTemplate != null) { ColumnChartDataPointTemplate dataPointTemplate = (ColumnChartDataPointTemplate)e.Element; dataPointTemplate.Fill = new SolidColorBrush(Colors.Green); } }
Hope this helps!
Marisa
Hallo Marisa and amitatsodel,
Thank you for your replies! It helps.
When I click on one datapoint, I want to change this datapoint into a selection style and clear the selection style of other datapoints.
And when I set the DataSource of the XamWebChart to an object, new ObservableCollection<DataPointData>(), then each datapoint is corresponding to a DataPointData. When I click on one datapoint, I want to get this DataPointData for the datapoint.
Sure these can be implemented, but it would be very nice that XamWebChart contains such methods or properties to get the source of the datapoint directly and implements the datapoint selection functionality.
Fang