Android: zoom questions

4 posts, 0 answers
  1. Viollier
    Viollier avatar
    11 posts
    Member since:
    Jul 2016

    Posted 13 Mar Link to this post

    Hi,

    i am showing a RadCartesianChartView with a DateTimeContinuousAxis for OX and a LinearAxis for OY. The OX is showing shorter or longer spans of time, depending on the user's choice.

    1. Zoom

    I want to set the chart zoom level from the moment i display the chart, but also allow the user to manually zoom and pan. I tried to use Chart.SetZoom() and also add ChartPanAndZoomBehavior(), but it doesn't work. If i set the Zoom factor, the user cannot manually pan and zoom. I also tried ChartPanAndZoomBehavior.SetZoomToChart() but has no effect.

    2. Setting DateTimeContinuousAxis MajorStep

    When the user selects a smaller time interval (like 1 month), i want the OX axis to show days, but not all 30 days. So i set the MajorStepUnit to TimeInterval.Day and the MajorStep to 10. However, it doesn't work as expected - i see a tick for every 5 days. Worse, when the user manually zooms on the chart, the tick interval is automatically changed. I can obtain a better result by setting the horizontalAxis.MaximumTicks, but i get other side effects. What can i do to have more control over the labels that are displayed in the OX axis?

     

    Thank you!

     

  2. Nikolay
    Admin
    Nikolay avatar
    15 posts

    Posted 13 Mar Link to this post

    Hello Viollier,

    Thank you for contacting us.

    1.I'm not able to reproduce the PanAndZoom issue. When I set the initial zoom with SetZoom() and add the CartPanAndZoomBehaviour the Chart appears zoomed and I am able to pan and zoom it manually. I'm attaching a sample app that demonstrates this behavior.

    2.Changing the MajorStep on zoom is a build-in feature of the RadChartView. However you can easily restrict how many ticks should be visible with the horizontalAxis.MaximumTicks property. It will be very helpful if you can provide a code sample or more information about the side effects you experience when using this property.

    Let us know if we can assist you further.

    Regards,
    Nikolay
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Viollier
    Viollier avatar
    11 posts
    Member since:
    Jul 2016

    Posted 27 Mar in reply to Nikolay Link to this post

    Hello. I have fixed the panning and zooming issue, thank you. Regarding MaximumTicks, I have the following snippet of code which automatically calculates the number of maximum ticks that we need for the required chart scale:

    if (visibleMonths >= 12)
    {
        maxTicks = maxDate.Year - minDate.Year + 1;
    }
    else switch ((int)visibleMonths)
        {
            case 3:
                {
                    maxTicks = (maxDate.Year - minDate.Year) * 12 + maxDate.Month - minDate.Month + 1;
                    break;
                }
            case 1:
                {
                    maxTicks = (maxDate.DayOfYear - minDate.DayOfYear + 1) / 7;
                    break;
                }
        }

     

    I then set the maximum ticks on the X axis like so (context added, maybe I am not getting the expected effect because of setting MaximumTicks at this particular time):

    Chart.BeginUpdate();
    Chart.Zoom = new RadSize(zoomX, zoomY);
    Chart.PanOffset = new RadPoint(-panX, -panY);
    if (maxTicks != -1)
    {
        (Chart.HorizontalAxis as DateTimeContinuousAxis).MaximumTicks = maxTicks;
    }
    Chart.EndUpdate();

     

    But the MaximumTicks value is always ignored. To work around our initial issue, we are using LabelInterval on the X axis, set to the same value as MajorStep, which gives us our expected behavior but is not optimal from a UI point of view.

     

    Thank you for your assistance.

  4. Nikolay
    Admin
    Nikolay avatar
    15 posts

    Posted 30 Mar Link to this post

    Hello Viollier,

    Thank you for getting back to us.

    I've tried to reproduce the issue with setting the maximum ticks with no luck. In all scenarios that I've tested the MaximumTicks property works as expected. The only thing I can think of is to check if the value of your maxTicks property is correct before setting it to the axis. 

    It will be great is you provide a simple working project with the issue so I can be more helpful.

    Regards,
    Nikolay
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top