Unplanned
Last Updated: 19 Feb 2021 18:04 by RAMAKANT
RAMAKANT
Created on: 16 Feb 2021 19:45
Category: Chart
Type: Bug Report
1
Setting PanOffset in XAML is Not Applied

Hi Team,

If you set the PanOffset in XAML, it is not applied. 

Does not work:

<telerikChart:RadCartesianChart x:Name="MyChart"  Zoom="2, 1"  PanOffset="-400,0" >

I would expect that the RadChartView renderer would be responsible for handling this after the control is loaded and the series/axis is rendered (see workaround).

Workaround

If I subscribe to the ChartView's NativeControlLoaded event and wait approx 100ms before calling PanOffset, it will work.

e.g.

<telerikChart:RadCartesianChart x:Name="MyChart"  Zoom="2, 1" 
                                                     NativeControlLoaded="MyChart_OnNativeControlLoaded">

private async void MyChart_OnNativeControlLoaded(object sender, EventArgs e)
{
    await Task.Delay(100);
    
    MyChart.PanOffset = new Point(-400, 0);
}

Takeaway and Action Requested

The takeaway, and basis of this Bug Report, is that the control should internally perform this delay check and set the PanOffset.

This will enable MVVM scenarios because (I originally wanted to bind the PanOffset value from my view model).

Thank you,

Ramakant

6 comments
RAMAKANT
Posted on: 19 Feb 2021 18:04

Thanks Yana. 

It works fine in iOS now with the effect.

ADMIN
Yana
Posted on: 19 Feb 2021 07:50

Hello Ramakant,

Please take your time.  

If you have any additional questions or concerns, I'll be glad to help.

Regards,
Yana
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

RAMAKANT
Posted on: 18 Feb 2021 17:41
Thanks Yana. I will try that out and let you know.
ADMIN
Yana
Posted on: 18 Feb 2021 17:21

Hi Ramakant,

Our Xamarin.Forms Chart component wraps native Android and iOS Chart implementations, basically that's why there are some differences across platforms.

The native iOS Chart provides NormalizedPan property which should be set between 0 and 1 and it represents a normalized value of the axis. The chart visible area will be moved based on the calculated value corresponding to the NormalizedPan value depending on the type of the axis.  So, in the concrete case, setting the NormailizedPan to 1 will move the visible area to the right end. In order to access the native Chart you can use a custom renderer or Xamarin.Forms Effects.

I have attached a sample app showing the approach for setting NormalizedPan on iOS through a XF effect, please download it and give it a try. Let me know if you have any issues with the workaround.

Regards, 
Yana
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Attached Files:
RAMAKANT
Posted on: 16 Feb 2021 20:40

It appears for iOS, the PanOffset is a very high positive number unlike Android which is a negative number. 

In my case, once I set the PanOffset to {X=330750.0001 Y=0} then on iOS the chart displays the end instead of the beginning.

I am still not sure how to dynamixcally figure out the PnaOffset similar to Andoid - new Point(-(chart.Width * chart.Zoom.Width), 0);

RAMAKANT
Posted on: 16 Feb 2021 20:04

"The workaround only works for Android, please provide guidance on how to address the issue in iOS".