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

Same SelectionChanged event fires for different charts

Hi Syncfusion Team!

We are having a strange issue of Chart selection behavior. Here is what we are encountering:

-We have got two different charts, Doughnut and Line chart on same page, in same StackLayout.
-We have "SfDoughnutChart_OnSelectionChanged" event bound to Doughnut chart and "SfLineChart_OnSelectionChanged" event bound to Line chart.
-The problem is, "SfLineChart_OnSelectionChanged" event is called each time, whether we click on Doughnut chart or Line chart.  SfDoughnutChart_OnSelectionChanged event never fires.
-If we check e.SelectedSeries on selection event, the output is always LineSeries.
-However if we remove "SfLineChart_OnSelectionChanged" event binding from Line chart, then SfDoughnutChart_OnSelectionChanged event starts firing as expected.

Can you please respond as soon as possible. Here is our code:

XAML:

<StackLayout Spacing="0" Padding="0" Orientation="Vertical">
<chart:SfChart HorizontalOptions="FillAndExpand" x:Name="DoughnutChart" VerticalOptions="FillAndExpand" SelectionChanged="SfDoughnutChart_OnSelectionChanged">
                <chart:SfChart.Legend>
                  <chart:ChartLegend DockPosition="Bottom">
                    <chart:ChartLegend.LabelStyle>
                      <chart:ChartLegendLabelStyle Font="7"/>
                    </chart:ChartLegend.LabelStyle>
                  </chart:ChartLegend>
                </chart:SfChart.Legend>
                <chart:DoughnutSeries DataMarkerPosition="OutsideExtended" ItemsSource="{Binding GigsData}" IsVisibleOnLegend="True"
                ConnectorLineType="Line" EnableDataPointSelection="True">
                  <chart:DoughnutSeries.DataMarker>
                    <chart:ChartDataMarker LabelContent="YValue">
                      <chart:ChartDataMarker.LabelStyle>
                        <chart:DataMarkerLabelStyle Font="25" Margin="2">
                        </chart:DataMarkerLabelStyle>
                      </chart:ChartDataMarker.LabelStyle>
                    </chart:ChartDataMarker>
                  </chart:DoughnutSeries.DataMarker>
                </chart:DoughnutSeries>
              </chart:SfChart>

<chart:SfChart HorizontalOptions="FillAndExpand" x:Name="LineChart"  VerticalOptions="FillAndExpand" SelectionChanged="SfLineChart_OnSelectionChanged">
                <!--<chart:SfChart.ChartBehaviors>
                  <chart:ChartZoomPanBehavior EnableSelectionZooming="True" SelectionRectStrokeWidth="1" />
                </chart:SfChart.ChartBehaviors>-->
                <chart:SfChart.PrimaryAxis>
                  <chart:CategoryAxis PlotOffset="10"/>
                </chart:SfChart.PrimaryAxis>
                <chart:SfChart.SecondaryAxis>
                  <chart:NumericalAxis />
                </chart:SfChart.SecondaryAxis>
                <chart:SfChart.Legend>
                  <chart:ChartLegend DockPosition="Bottom" ToggleSeriesVisibility="True">
                    <chart:ChartLegend.LabelStyle>
                      <chart:ChartLegendLabelStyle Font="7"/>
                    </chart:ChartLegend.LabelStyle>
                  </chart:ChartLegend>
                </chart:SfChart.Legend>
                <chart:SfChart.Series>
                  <chart:LineSeries ItemsSource="{Binding Published}" EnableDataPointSelection="True" Label="Published" Color="{StaticResource published}">
                    <chart:LineSeries.DataMarker>
                      <chart:ChartDataMarker ShowLabel="False" ShowMarker="True" MarkerColor="{StaticResource published}" MarkerHeight="{StaticResource MarkerHeight}" MarkerWidth="{StaticResource MarkerWidth}" />
                    </chart:LineSeries.DataMarker>
                  </chart:LineSeries>
                </chart:SfChart.Series>
              </chart:SfChart>
</StackLayout>


C# Code:

   private void SfChart_OnSelectionChanged(object sender, ChartSelectionEventArgs e)
   {
            var chart = sender as SfChart;
            //e.SelectedSeries is always Line Series in our case. 
            if (e.SelectedSeries is DoughnutSeries)
            {
            }
            else
            {
            }
    }

C# Code - End

Regards,

Sajid.

2 Replies

SA Sajid Ali July 24, 2015 11:08 AM UTC

Our actual C# Code:

        private void SfDoughnutChart_OnSelectionChanged(object sender, ChartSelectionEventArgs e)
        {
            //This event does not fires for Doughnut chart as expected.

            var chart = sender as SfChart;
            var doughnut = chart.Series[0] as DoughnutSeries;

            if (e.PreviousSelectedIndex == e.SelectedDataPointIndex)
            {
                    doughnut.ExplodeIndex = -1;
            }
            else
            {
                    doughnut.ExplodeIndex = e.SelectedDataPointIndex;
            }
        }

        private void SfLineChart_OnSelectionChanged(object sender, ChartSelectionEventArgs e)
        {
               //This event fires for both Doughnut and Line Series.
        }


YP Yuvaraj Palanisamy Syncfusion Team July 27, 2015 12:31 PM UTC

Hi Sajid,

Thanks for using Syncfusion Products.

we have created a support incident under your account to track the status of this issue.

Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents  

Please let me know if you have any questions.

Thanks,
Yuvaraj

Loader.
Live Chat Icon For mobile
Up arrow icon