Scrolling on iOS with TChart on page.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
BobReck
Newbie
Newbie
Posts: 16
Joined: Tue Apr 24, 2012 12:00 am

Scrolling on iOS with TChart on page.

Post by BobReck » Tue Jun 05, 2012 4:19 pm

Heya folks,

Another question from me. I am working on my second app using TeeChart for .NET on iOS and with MonoTouch. In my first app, an iPhone/iPod Touch only app, we experienced a problem where putting a chart that took up the entire screen on the view controller would not allow us to scroll or use swipe gestures. We eventually found that if we made the chart a bit smaller and swiped in the area not occupied by the chart's rectangle, we could actually use the swipe and/or scroll gestures.

On my new app, an iPad only app, I am having the same problem. If I try to swipe or scroll when starting with my finger on one of the charts, the page will not scroll or swipe (actually, only scroll in this case - we don't have swipe gestures, just a uiscrollview that the charts are being added to). I have a page that contains 7 different charts. If I scroll making sure to touch between them, it works fine. Unfortunately, this is not very user friendly because users don't think to start their scroll in between graphs.

I understand that this is probably related to the fact that the Charts have their own scrolling capabilities. But I have disabled all scrolling and panning in them. Is there another way to tell the charts to completely ignore the touch, swipe or scroll and allow the page to handle it?

Thanks!
Bob

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Re: Scrolling on iOS with TChart on page.

Post by Pep » Fri Jun 08, 2012 10:50 am

Hi Bob,

I remember I did some tests related with that.
I think you should be able to accomplish it by adding manually the gestures to the Chart object. As the Chart inherits from a UIView you can add specific gestures to it as if it was a standard UIView, something like :

Code: Select all

     UIPanGestureRecognizer onmove;
     onmove = new UIPanGestureRecognizer(this,new MonoTouch.ObjCRuntime.Selector("PanGesture"));					        
     onmove.Delegate = new PanGestureDelegate();

    chart.AddGestureRecognizer(onmove);

   public class PanGestureDelegate : UIGestureRecognizerDelegate
   {
	        public override bool ShouldReceiveTouch(UIGestureRecognizer aRecogniser, UITouch aTouch)
	        {
	            return true;
	        }
   }	
Another way could be to use the clickBackGround event of the Chart object, and once it's fired check whether recognizer is a PanGesture, Tap, or other, and do the necessary work. Something like :

Code: Select all

		private bool chart_clickBackGround(UIGestureRecognizer recognizer, UITouch touch) 
		{
			//Console.WriteLine("BackGround clicked");
			return false;
		}

               chart.ClickBackground += new UITouchEventArgs(chart_clickBackGround);
Please check if this helps, and let me know something in the case you still having problems.

BobReck
Newbie
Newbie
Posts: 16
Joined: Tue Apr 24, 2012 12:00 am

Re: Scrolling on iOS with TChart on page.

Post by BobReck » Wed Jun 20, 2012 6:07 pm

Josep,

Sorry, it's been a while since I looked at this issue. Sometimes I don't get notified when you guys respond.

Ok, so you referenced doing some testing of this before. I believe you worked on a problem we had where touching on a series and then trying to pan the chart would cause a crash. You confirmed the bug, issued a new DLL and that was fixed. This is a different problem, however. This is an issue where when you place a chart rectangle on a view and then try to scroll the view, it will not work if you are trying from anywhere on the chart rectangle. I have a page where I layout about 7 - 9 different charts in two columns. If the user tries to scroll from the majority of the view (which is taken up mostly by the charts) it will not work. However, if they strategically put their finger between the charts and scroll, it works. It also works between two charts (one above another) when touching the space between then. And it works on the left and right margins of the view. In the image below, the green areas represent every where that I you can touch to start a scroll.

Image

If this is not making sense, please let me know. Or just put a chart or two on a uiscrollview and try to scroll. You'll see what I mean.

Bob

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Re: Scrolling on iOS with TChart on page.

Post by Pep » Mon Jun 25, 2012 9:11 am

Hi Bob,

ok, I'm going to check with an example, disabling the gestures for Chart should be the trick.
I'll send the results asap..

BobReck
Newbie
Newbie
Posts: 16
Joined: Tue Apr 24, 2012 12:00 am

Re: Scrolling on iOS with TChart on page.

Post by BobReck » Mon Jun 25, 2012 12:50 pm

Pep wrote:Hi Bob,

ok, I'm going to check with an example, disabling the gestures for Chart should be the trick.
I'll send the results asap..
Thanks again Josep! Your help is very much appreciated!
Bob

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Re: Scrolling on iOS with TChart on page.

Post by Pep » Fri Jun 29, 2012 10:39 am

Hi Bob,

sorry for dealy on answer.
I've been checking the issue here, and using the UserInteractionEnabled property for each chart should solve it :

Code: Select all

			chart1.UserInteractionEnabled = false;
			chart2.UserInteractionEnabled = false;

BobReck
Newbie
Newbie
Posts: 16
Joined: Tue Apr 24, 2012 12:00 am

Re: Scrolling on iOS with TChart on page.

Post by BobReck » Fri Jun 29, 2012 1:51 pm

Josep,
That's it! Thanks again! Once again, you have come through for me! Many thanks!
Bob

Post Reply