This is a migrated thread and some comments may be shown as answers.

Getting displayed chart items

1 Answer 10 Views
Chart
This is a migrated thread and some comments may be shown as answers.
igor
Top achievements
Rank 1
igor asked on 16 Oct 2020, 10:59 AM
Hello.
Tell me how to get the items that are currently displayed on the chart after zooming and scrolling?
I use custom renderer to get native control and handle pan and zoom events using PanZoomListener, but in the handler I can only get relative offset.

here is my renderer

    class ChartPointRenderer : CartesianChartRenderer
    {
        public ChartPointRenderer(Context context) :base(context)
        {
        }
        protected override RadCartesianChartView CreateNativeControl()
        {
             Control = base.CreateNativeControl();
             return Control;
        }
        protected override void OnAttachedToWindow()
        {
            base.OnAttachedToWindow();
            var beh = Control.Behaviors.ToArray();
            for (int j = 0; j < beh.Length; j++)
            {
                if (beh[j].GetType() == typeof(Telerik.XamarinForms.ChartRenderer.Android.AndroidChartPanAndZoomBehavior))
                {
                    var zoomBehavior = (Telerik.XamarinForms.ChartRenderer.Android.AndroidChartPanAndZoomBehavior)beh[j];
                    zoomBehavior.AddPanZoomListener(new Listeners.ChartPanZoomListener());
                }
            }
        }
    }



and listener

    public class ChartPanZoomListener :Java.Lang.Object, IPanZoomListener
    {

        public IntPtr Handle => throw new NotImplementedException();

        public void OnPan(double p0, double p1)
        {
            //do something
        }

        public void OnZoom(double p0, double p1)
        {
            //do something
        }
    }

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 20 Oct 2020, 04:42 AM

Hello Igor,

I am afraid for the time being RadChart does not provide a way to get the current visible range - we have a feature request regarding such a functionality, please follow the item and cast your vote at the link below:

Chart: Implement VisibleRange property in the axes

There is not direct workaround I can suggest, still, you can take a look at the customer's implementation with gestures discussed in the following thread:

https://www.telerik.com/forums/chartpanandzoombehavior-limited-to-current-items-source

I am sorry for any inconvenience caused.

Regards,
Yana
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Chart
Asked by
igor
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or