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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Same SelectionChanged event fires for different charts

Thread ID:

Created:

Updated:

Platform:

Replies:

119720 Jul 24,2015 11:00 AM UTC Jul 27,2015 12:31 PM UTC Xamarin.Forms 2
loading
Tags: SfChart
Sajid Ali
Asked On July 24, 2015 11:00 AM UTC

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.

Sajid Ali
Replied On 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.
        }

Yuvaraj Palanisamy [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;