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

2 questions about using SfCartesianChart

Hi,

Here are my questions:


1. I want to put Legend under the X axis, seems not an option for ChartAlignment?


2. I don't want Y axis to change interval when do zooming, so I set enableAutoIntervalOnZooming to false, but it don't work, why?


5 Replies 1 reply marked as answer

YG Yuvaraj Gajaraj Syncfusion Team January 16, 2023 12:53 PM UTC

Hi Zhu,


Greetings from Syncfusion.


Query #1: I want to put Legend under the X axis, seems not an option for ChartAlignment?

For placing the legend under the x-axis you can use the position property used to position the legend relatively. The available options are auto, bottom, left, right, and top. We have shared the code snippet below for your reference.


Code snippet:

legend: Legend(
isVisible: true,
position: LegendPosition.bottom,
),


Screenshot:



Query 2#: I don't want Y axis to change interval when do zooming, so I set enableAutoIntervalOnZooming to false, but it don't work, why?

When the enableAutoIntervalOnZooming property is set to 'false', the nice interval will not be calculated based on the visible range. Instead, the actual interval will be maintained while zooming. This means that the difference between the two axis labels will remain the same as the original interval. E.g., if the actual interval is 2, after performing zooming the interval will be the same. We have shared the UG link below for your reference.




UG, https://help.syncfusion.com/flutter/cartesian-charts/zoom-pan#auto-interval-on-zooming


Regards,

Yuvaraj.



ZH Zhu January 19, 2023 01:41 AM UTC

Hi, Yuvaraj,


Thank you so much for the detailed reply.


About question 2, what I need is to change intervals on X axis to apply to zooming, but on Y axis keep the old intervals at zooming time, how to do that?

I tried to set enableAutoIntervalOnZooming to false on Y axis, but it don't work.


Regards,

Zhu



LP Lokesh Palani Syncfusion Team January 19, 2023 12:37 PM UTC

Query:  What I need is to change intervals on X axis to apply to zooming, but on Y axis keep the old intervals at zooming time, how to do that?


Your requirement can be achieved by setting the zoommode property value to ZoomMode.x in the ZoomPanBehavior and setting the y-axis anchorRangeToVisiblePoints to false. This will result in applying the zooming only on the x-axis range and will not affect the y-axis range. 


Code snippet:


SfCartesianChart(

          zoomPanBehavior: ZoomPanBehavior(

            enableMouseWheelZooming: true,

            zoomMode: ZoomMode.x,

          ),

          primaryXAxis: NumericAxis(),

          primaryYAxis: NumericAxis(

          anchorRangeToVisiblePoints: false,

          ),

           ),


For more details, please refer the following ug:

https://help.syncfusion.com/flutter/cartesian-charts/zoom-pan#panning

https://help.syncfusion.com/flutter/cartesian-charts/axis-customization#auto-range-calculation


Regards,

Lokesh Palani.


Marked as answer

ZH Zhu replied to Lokesh Palani January 20, 2023 02:25 PM UTC

Hi,  Lokesh Palan,


I added 'zoomMode: ZoomMode.x' and it works!

Thank you so much for the help.


Regards,

Zhu



YG Yuvaraj Gajaraj Syncfusion Team January 23, 2023 08:49 AM UTC

Hi Zhu,


Most Welcome. Kindly get back to us if you have further queries. We are always happy to assist you.


Regards,

Yuvaraj.


Loader.
Live Chat Icon For mobile
Up arrow icon