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

Chart DateTimeCategoricalAxis

7 Answers 61 Views
Chart - Xamarin.Android
This is a migrated thread and some comments may be shown as answers.
Itamar
Top achievements
Rank 1
Itamar asked on 19 Dec 2016, 10:51 AM

Hello, I need to set the horizontal date axis 

to display either 6 hours ticks or date ticks.

The label format should change like in the attached file.

We want to set the zoom behavior to zoom-in to 15 days

Appreciate Help

7 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 21 Dec 2016, 09:27 AM
Hi Itamar,

Thanks for writing.
You can achieve this by using the axis.LabelValueToStringConverter property. A simple label format will not suffice because it can't decide when to display the month and when the hours.
The converter should look like something this:

public class Converter : Java.Lang.Object, IFunction
    {
        public Java.Lang.Object Apply(Java.Lang.Object p0)
        {
            MajorTickModel tick = (MajorTickModel)p0;
 
            // Use the collection index to get the correct date from your data.
            // Then you can return the correct string based on that date.
            return tick.CollectionIndex().ToString();
        }
    }

Can you please explain what you mean by zoom in to 15 days? Is that a max zoom or data drill down. Our chart currently does not support data drill down if this is what you need.

Regards,
Victor
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
Itamar
Top achievements
Rank 1
answered on 29 Dec 2016, 04:49 AM

Hello


We have data of 60 days each point is an hour 
We want to display be default only 15 days 
We use ChartPanAndZoomBehavior ,SetZoomToChart method
The scaleX = 4 , scaleY =0, the zoom is working good but the chart display the last 15 days.
How can we pan to the most recent 15 days ?

Thanks

0
Victor
Telerik team
answered on 03 Jan 2017, 11:33 AM
Hello Itamar,

Thanks for writing.
This should be really simple. You can calculate the pan based on the chart plot area size. You can get the plot area like this:
chart.PlotAreaClip.Width;
Then based on the width and your zoom factor you can set the pan offset. Please note that the offset must be a negative value because the chart contents need to move to the left if are to see the right-most (latest) data points.

Regards,
Victor
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
Itamar
Top achievements
Rank 1
answered on 09 Jan 2017, 09:03 AM

Hi Victor,

I use the SetPanOffsetToChart method without any success. See code below:

 var pw = Chart.PlotAreaClip.Width;      
_pzBehavior.SetZoomToChart(MaxDays / DefaultDays, 0,0 , 0);
_pzBehavior.SetPanOffsetToChart(-pw* MaxDays / DefaultDays, 0);

It seems like the pan value is too bigger then the chart width.

Do I do something wrong?

 

Thanks,

Roey.

 

0
Accepted
Victor
Telerik team
answered on 11 Jan 2017, 10:09 AM
Hi Itamar,

Thanks for writing. Please try this:
double zoom = 3;
chart.SetZoom(3, 1);
double panOffset = chart.PlotAreaClip.Width * zoom;
chart.SetPanOffset(-panOffset, 0);

The difference is that the zoom and pan are set on the chart itself, not the behavior.

Regards,
Victor
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
Itamar
Top achievements
Rank 1
answered on 12 Jan 2017, 09:18 AM

Hi Victor,

Thanks alot. It works :-)

0
Victor
Telerik team
answered on 12 Jan 2017, 05:33 PM
Excellent!

Let us know if you need further assistance.
Meanwhile I'll fix the zoom reset.

Regards,
Victor
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.Android
Asked by
Itamar
Top achievements
Rank 1
Answers by
Victor
Telerik team
Itamar
Top achievements
Rank 1
Share this question
or