Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
390
How to select a datapoint?
posted

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?

Parents
  • 1134
    posted

    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

Reply Children