[Xamarin.Forms] Issues on WindowsPhone and Android

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
MiracleTek
Newbie
Newbie
Posts: 9
Joined: Mon Jan 12, 2015 12:00 am

[Xamarin.Forms] Issues on WindowsPhone and Android

Post by MiracleTek » Sat Jan 24, 2015 11:53 am

Hi There,

We hope you are doing fine.

We tried searching on the forum but couldn't find any similar problems. We had recently purchased TeeCharts for Xamarin.Forms license the charts seem to work well on iOS and mostly on Android too. However, we are facing some glaring issues and would like to find solutions to them ASAP.

ISSUE 1:
On Android, if we put the charts in a ListView and scroll the ListView towards the end of the list, all the charts that scroll through the top navigation bar leave trails of their marks on the bar. We tried to figure out the cause but we couldn't and many tweaks we tried to put in didn't work for us. The behavior is identical on Emulator and Device both, and the issue remains the same across different versions of Xamarin.Forms too. We think this might be a bug in the Xamarin.Forms implementation of TeeCharts for Android. (Please see the attached screenshot)

ISSUE 2:
On Windows Phone, we are simply unable to use charts at all on most screens because if TeeCharts are placed inside a scrollable Xamarin.Forms container (like. scrollview or listview), the TeeChart.WP8.DLL crashes with a NullPointerException. We are think this might also be a bug in TeeChart for WinbPhone.

We've attached a sample project and screenshot to demonstrate the issues on both Windows Phone and Android.

Thanks.
Attachments
Nexus 4 (KitKat) Screentshot 1.png
Android screenshot
Nexus 4 (KitKat) Screentshot 1.png (74.75 KiB) Viewed 19009 times
TeeChartsSample.zip
Sample project
(287.25 KiB) Downloaded 636 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: [Xamarin.Forms] Issues on WindowsPhone and Android

Post by Narcís » Mon Jan 26, 2015 10:39 am

Hello,
ISSUE 1:
On Android, if we put the charts in a ListView and scroll the ListView towards the end of the list, all the charts that scroll through the top navigation bar leave trails of their marks on the bar. We tried to figure out the cause but we couldn't and many tweaks we tried to put in didn't work for us. The behavior is identical on Emulator and Device both, and the issue remains the same across different versions of Xamarin.Forms too. We think this might be a bug in the Xamarin.Forms implementation of TeeCharts for Android. (Please see the attached screenshot)
I can reproduce this in Android 4 and Android 5 emulators but can not reproduce it on several Android 5 devices and one Android 4 device. This somehow reminds me of this Xamarin.Forms bug I reported. In some occasions it produced a similar result. In which kind of device can you reproduce the problem on?
ISSUE 2:
On Windows Phone, we are simply unable to use charts at all on most screens because if TeeCharts are placed inside a scrollable Xamarin.Forms container (like. scrollview or listview), the TeeChart.WP8.DLL crashes with a NullPointerException. We are think this might also be a bug in TeeChart for WinbPhone.
I could reproduce the problem here and added it (ID1102) to the defect list. My colleague Christopher Ireland will add a workaround and update on the issue status in a following post.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: [Xamarin.Forms] Issues on WindowsPhone and Android

Post by Christopher » Mon Jan 26, 2015 10:58 am

Narcís wrote:I could reproduce the problem here and added it (ID1102) to the defect list.
This issue is now fixed. It seems that for some reason the code path in WP8 Xamarin Forms has changed a little, either because of your specific code or because of the update to Xamarin Forms 1.3. In any case, there is a workaround you can apply.

The workaround involves adding a new unit, MyTChart.cs, to your project TeeChartsSample.WinPhone with the following content:

Code: Select all

using Steema.TeeChart;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TeeChartsSample.WinPhone
{
  public class MyTChart : TChart
  {
    public MyTChart() : base()
    {
    }

    double oldWidth = 0, oldHeight = 0;

    protected override System.Windows.Size MeasureOverride(System.Windows.Size availableSize)
    {
      Xamarin.Forms.Size result = new Xamarin.Forms.Size();
      result.Width = !double.IsInfinity(availableSize.Width) ? availableSize.Width : 0;
      result.Height = !double.IsInfinity(availableSize.Height) ? availableSize.Height : 0;

      if (oldWidth != result.Width && oldHeight != result.Height && RootElement != null)
      {
        Draw(new Xamarin.Forms.Rectangle(new Xamarin.Forms.Point(0, 0), result));
      }

      oldWidth = result.Width;
      oldHeight = result.Height;

      return new System.Windows.Size(result.Width, result.Height);
    }
  }
}
Then you will need to modify TeeChartRenderer.cs so it looks like this:

Code: Select all

using Xamarin.Forms;
using Xamarin.Forms.Platform.WinPhone;
using Steema.TeeChart;
using TeeChartsSample;
using TeeChartsSample.WinPhone;

[assembly: ExportRenderer(typeof(ChartView), typeof(TeeChartRenderer))]

namespace TeeChartsSample.WinPhone
{
    class TeeChartRenderer : ViewRenderer<ChartView, MyTChart>
    {
        private Chart chartModel;
        private MyTChart chart;

        protected override void OnElementChanged(ElementChangedEventArgs<ChartView> e)
        {
            base.OnElementChanged(e);

            chartModel = Element.Model;

            chart = new MyTChart();

            chart.Chart = chartModel;

            SetNativeControl(chart);
        }

        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);
        }
    }
}
These changes will resolve the problem for you.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

MiracleTek
Newbie
Newbie
Posts: 9
Joined: Mon Jan 12, 2015 12:00 am

Re: [Xamarin.Forms] Issues on WindowsPhone and Android

Post by MiracleTek » Mon Jan 26, 2015 12:19 pm

Hi Narcis,

Thanks for your response.

We can successfully reproduce the Android overlap issue on the following devices:
  • Android Emulator with 4.4.4 KitKat
    Google Nexus 5 with 5.1 Lollipop
    Huawei Ascend G750 with 4.2.2 JellyBean
    HTC D816 with 4.2.2 JellyBean
    Samsung Note 3
Also, the issue is not just overlap over the navigation bar, even if we add some components before the ListView and then scroll the list, the tick marks start overlapping the components above the list, Even before they reach the navigation bar. Also, one thing to note is that if we add other components before the ListView, the marks disappear before they reach the navigation bar. So in other words the overlap issue doesn't have anything to do with the navigation bar.

Also, as soon as the scroll clipping reaches middle of the charts the mark overlap disappears. Also, the overlap is only caused by the Chart Marks and nothing else (i.e. the panel, bars or anything else do not overlap).

I hope this information helps. I've attached a screenshot demonstrating the issue when some other components are placed before the ListView.
Attachments
Nexus 4 (KitKat) Screentshot 7.png
Android issue
Nexus 4 (KitKat) Screentshot 7.png (31.38 KiB) Viewed 18883 times

MiracleTek
Newbie
Newbie
Posts: 9
Joined: Mon Jan 12, 2015 12:00 am

Re: [Xamarin.Forms] Issues on WindowsPhone and Android

Post by MiracleTek » Mon Jan 26, 2015 12:44 pm

Hi Christopher,

The workaround you suggested seems to resolve the issue for us on Windows Phone. Thank you so much.

One thing you might want to know is that the issue did occur on older versions of Xamarin as well so it wasn't just related to Xamarin.Forms 1.3.x.

Do you know if this fix will be out anytime soon in a newer version of TeeCharts for Xamarin.Forms?

I have another question regarding TeeCharts for Xamarin.Forms.

Can you let us know when the iOS Unified compatible version of TeeCharts for Xamarin.Forms will be out?

Thanks.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: [Xamarin.Forms] Issues on WindowsPhone and Android

Post by Narcís » Mon Jan 26, 2015 4:07 pm

Hello,

Thanks for the feedback.

I haven't been able to reproduce it consistently here with a device. It's reproduceable with Android API 19 and Android API 21 emulators but not in a device. Actually, I even tested on a Google Nexus 5 with Android 5.0.1 as you said and worked fine there. I also tested with a Google Nexus 7 (2012) with Android 5.0.2 and a Google Nexus 4 with Android 5.01. At the URL below you can download the .apk I used for the test and a video showing how the application works on the Nexus 7. It worked the same way with the other devices. Can you please test the attached apk at your end and let us know how it works?

http://www.steema.com/files/public/TeeC ... Scroll.zip

BTW, some Android resources that might be helpful here:

How do you install an APK file in the Android emulator?
How to Record Your Android Device’s Screen With Android 4.4 KitKat
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: [Xamarin.Forms] Issues on WindowsPhone and Android

Post by Narcís » Tue Jan 27, 2015 8:30 am

Hello,
MiracleTek wrote: Can you let us know when the iOS Unified compatible version of TeeCharts for Xamarin.Forms will be out?
the iOS Unified version is almost ready. Just a few details need to be finalised before it can be released.

MiracleTek wrote: Do you know if this fix will be out anytime soon in a newer version of TeeCharts for Xamarin.Forms?
Given that Christopher fixed that and a maintenance release might be required to support iOS Unified, yes, that could be the case. Please be aware at this forum or any other Steema Software communication channels for further news.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MiracleTek
Newbie
Newbie
Posts: 9
Joined: Mon Jan 12, 2015 12:00 am

Re: [Xamarin.Forms] Issues on WindowsPhone and Android

Post by MiracleTek » Tue Jan 27, 2015 1:27 pm

Hi Christopher,

I had to do a little tweak to your function you supplied as part of the MyTChart class for the windows phone fix, since the older code was causing the chart to disappear if picker dialog was opened on top of a chart that is inside a list view item. Coming back to chart list from the picker dialog would cause the chart to disappear.

The following implementation seems to work well.

Code: Select all

namespace TeeChartsSample.WinPhone
{
    public class MyTChart : TChart
    {
        public MyTChart()
            : base()
        {
        }

        double oldWidth = 0, oldHeight = 0;

        protected override System.Windows.Size MeasureOverride(System.Windows.Size availableSize)
        {
            if (RootElement != null)
            {
                double width = !double.IsInfinity(availableSize.Width) ? availableSize.Width : 0;
                double height = !double.IsInfinity(availableSize.Height) ? availableSize.Height : 0;

                if (oldWidth != width || oldHeight != height)
                    Draw(new Xamarin.Forms.Rectangle(0, 0, width, height));

                oldWidth = width;
                oldHeight = height;

                return new System.Windows.Size(width, height);
            }

            return availableSize;
        }
    }
}

Just thought I should let you should know. :D

Thanks.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: [Xamarin.Forms] Issues on WindowsPhone and Android

Post by Christopher » Thu Jan 29, 2015 8:56 am

Hello!
MiracleTek wrote: Just thought I should let you should know. :D
That's great, thank you very much :) I have added the change to the TeeChart.PCL.WP8 source code.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

MiracleTek
Newbie
Newbie
Posts: 9
Joined: Mon Jan 12, 2015 12:00 am

Re: [Xamarin.Forms] Issues on WindowsPhone and Android

Post by MiracleTek » Mon Feb 09, 2015 4:22 pm

Hi Narcís,
the iOS Unified version is almost ready. Just a few details need to be finalised before it can be released.
Any updates on the iOS unified version? Our next release is dependent on it :(

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: [Xamarin.Forms] Issues on WindowsPhone and Android

Post by Christopher » Mon Feb 09, 2015 4:29 pm

A new Xamarin Forms version including support for iOS.Unified is available for download from the customer download page here.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

MiracleTek
Newbie
Newbie
Posts: 9
Joined: Mon Jan 12, 2015 12:00 am

Re: [Xamarin.Forms] Issues on WindowsPhone and Android

Post by MiracleTek » Mon Feb 09, 2015 4:47 pm

Hi Christopher,

Thanks a lot for the swift reply. Apologies for not checking the download section first :).

Got the right version now.

Thanks !

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: [Xamarin.Forms] Issues on WindowsPhone and Android

Post by Christopher » Mon Feb 09, 2015 4:53 pm

MiracleTek wrote: Thanks a lot for the swift reply. Apologies for not checking the download section first :).
You're very welcome :)

A happy coincidence that I was finishing publishing this version when I saw your message!
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply