Binding SeriesBehavior not working in Android

Hello Syncfusion Support.


Binding SeriesBehavior doesn't seem to work in Android, but everything works properly in iOS.

In Android, chart cannot zoom after double tap.


My code:

 

[XAML]

    <ContentPage.BindingContext>

  <locals:TestChartVM/>

    </ContentPage.BindingContext>


    <chart:SfChart

        x:Name="myChart"

        HorizontalOptions="FillAndExpand"

        VerticalOptions="FillAndExpand"

        BackgroundColor="White"

        Series="{Binding SeriesCollection}"

        ChartBehaviors="{Binding SeriesBehavior}">

    </chart:SfChart>



[ViewModel]

        public ObservableCollection<ChartDataPoint> myData { get; set; }


        private ChartSeriesCollection seriesCollection;

        public ChartSeriesCollection SeriesCollection

        {

            get { return seriesCollection; }

            set { SetValue(ref seriesCollection, value); }

        }


        private ChartBehaviorCollection seriesBehavior;

        public ChartBehaviorCollection SeriesBehavior

        {

            get { return seriesBehavior; }

            set { SetValue(ref seriesBehavior, value); }

        }

       

        public TestChartVM()

        {

            SeriesCollection = new ChartSeriesCollection();

            SeriesBehavior = new ChartBehaviorCollection();


            myData = new ObservableCollection<ChartDataPoint>()

            {

                new ChartDataPoint("Jan", 30),

                new ChartDataPoint("Feb", 44),

                new ChartDataPoint("Mar", 50),

                new ChartDataPoint("Apr", 68),

                new ChartDataPoint("May", 71),

                new ChartDataPoint("Jun", 88),

            };


            ColumnSeries columnSeries = new ColumnSeries()

            {

                ItemsSource = myData,

                XBindingPath = "XValue",

                YBindingPath = "YValue",

                EnableAnimation = true,

                XAxis = new CategoryAxis(),

                YAxis = new NumericalAxis(),

                EnableTooltip = true,

            };


            ChartZoomPanBehavior chartZoomPanBehavior = new ChartZoomPanBehavior()

            {

                ZoomMode = ZoomMode.XY,

                EnableDoubleTap = true,

            };


            SeriesBehavior.Add(chartZoomPanBehavior);

            SeriesCollection.Add(columnSeries);

        }


One more question, are all the graphs created and exported by SfChart are Copyright Free? 

Can I share those graphs on social media?     



2 Replies 1 reply marked as answer

JK Jon Kao June 24, 2021 08:10 AM UTC

Is there any update on this thread?



YP Yuvaraj Palanisamy Syncfusion Team June 24, 2021 03:37 PM UTC

 
Greetings from Syncfusion. 
 
# Chart Query 
 
We have analyzed your query and you can resolve this by setting of PrimaryAxis and SecondaryAxis for SfChart as per the below code snippet. 
 
CodeSnippet: [MainPage.xaml] 
<chart:SfChart 
x:Name="myChart" 
HorizontalOptions="FillAndExpand" 
VerticalOptions="FillAndExpand" 
BackgroundColor="White"             
ChartBehaviors="{Binding SeriesBehavior}" 
Series="{Binding SeriesCollection}"> 
 
    <chart:SfChart.PrimaryAxis> 
        <chart:CategoryAxis/> 
    </chart:SfChart.PrimaryAxis> 
 
    <chart:SfChart.SecondaryAxis> 
        <chart:NumericalAxis/> 
    </chart:SfChart.SecondaryAxis> 
 
</chart:SfChart> 
 
ViewModel.cs 
ColumnSeries columnSeries = new ColumnSeries() 
{ 
    ItemsSource = myData, 
    XBindingPath = "XValue", 
    YBindingPath = "YValue", 
    EnableAnimation = true, 
    XAxis = new CategoryAxis(), 
    YAxis = new NumericalAxis(), 
    EnableTooltip = false, 
}; 
 
## Copyright query 
 
Please feel free to share the graph creations on social media and also please link back to our Website. 
 
Regards, 
Yuvaraj. 


Marked as answer
Loader.
Up arrow icon