Page 1 of 1

Scrolling on iOS with TChart on page.

Posted: Tue Jun 05, 2012 4:19 pm
by 17262249
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

Re: Scrolling on iOS with TChart on page.

Posted: Fri Jun 08, 2012 10:50 am
by Pep
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.

Re: Scrolling on iOS with TChart on page.

Posted: Wed Jun 20, 2012 6:07 pm
by 17262249
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

Re: Scrolling on iOS with TChart on page.

Posted: Mon Jun 25, 2012 9:11 am
by Pep
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..

Re: Scrolling on iOS with TChart on page.

Posted: Mon Jun 25, 2012 12:50 pm
by 17262249
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

Re: Scrolling on iOS with TChart on page.

Posted: Fri Jun 29, 2012 10:39 am
by Pep
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;

Re: Scrolling on iOS with TChart on page.

Posted: Fri Jun 29, 2012 1:51 pm
by 17262249
Josep,
That's it! Thanks again! Once again, you have come through for me! Many thanks!
Bob