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.