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

Android: zoom questions

3 Answers 84 Views
Chart - Xamarin.iOS
This is a migrated thread and some comments may be shown as answers.
Viollier
Top achievements
Rank 1
Viollier asked on 13 Mar 2017, 08:43 AM

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!

 

3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 13 Mar 2017, 03:08 PM
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
0
Viollier
Top achievements
Rank 1
answered on 27 Mar 2017, 08:52 AM

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.

0
Nikolay
Telerik team
answered on 30 Mar 2017, 07:49 AM
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
Tags
Chart - Xamarin.iOS
Asked by
Viollier
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Viollier
Top achievements
Rank 1
Share this question
or