Page 1 of 1

Unhandled exception in iOS charting

Posted: Wed May 02, 2012 2:45 am
by 17262248
I am handling a Series click event and if I touch up outside and let go on a series, I get a fatal error (not in me code).


Unhandled Exception: System.InvalidCastException: Cannot cast from source type to destination type.
at Steema.TeeChart.Chart.DoMouseDown (Boolean IsDoubleClick, MonoTouch.UIKit.UIGestureRecognizer e) [0x00000] in <filename unknown>:0
at Steema.TeeChart.TChart.OnMouseMove (MonoTouch.UIKit.UIGestureRecognizer e) [0x00000] in <filename unknown>:0
at Steema.TeeChart.TChart.PanGesture (MonoTouch.UIKit.UIPanGestureRecognizer e) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
at eLogic.Application.Main (System.String[] args) [0x00000] in /Users/ndiab/Projects/eLogic/eLogic/Main.cs:17
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidCastException: Cannot cast from source type to destination type.
at Steema.TeeChart.Chart.DoMouseDown (Boolean IsDoubleClick, MonoTouch.UIKit.UIGestureRecognizer e) [0x00000] in <filename unknown>:0
at Steema.TeeChart.TChart.OnMouseMove (MonoTouch.UIKit.UIGestureRecognizer e) [0x00000] in <filename unknown>:0
at Steema.TeeChart.TChart.PanGesture (MonoTouch.UIKit.UIPanGestureRecognizer e) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
at eLogic.Application.Main (System.String[] args) [0x00000] in /Users/ndiab/Projects/eLogic/eLogic/Main.cs:17

Re: Unhandled exception in iOS charting

Posted: Wed May 09, 2012 9:53 am
by Pep
Hello,

I've been doing some tests here, and using the following code it is wording fine :

Code: Select all

_controller.chart.ClickSeries += new Steema.TeeChart.TChart.SeriesEventHandler(series_clicked);

private void series_clicked(object sender, Steema.TeeChart.Styles.Series s, int valueIndex, UIGestureRecognizer e) 
{
	Console.WriteLine("Series clicked");
}	
You can try to add this code to the Features demo project.
Does the problem happens with both simulator and device ?
In the case you still having problems, would you be so kind to send us a simple test project with which we can reproduce the problem as is here ?

Re: Unhandled exception in iOS charting

Posted: Wed May 09, 2012 2:14 pm
by 17262249
Pep,
Thanks for the response. I work with the originator of this article and we're both trying to determine the reason for this crash.

Your code example addresses tapping on a series. We have that working fine and can zoom into the series as we want. I did try implementing your code (successfully) but the crash still exists when you pan the chart. The problem is when we try to pan the chart by starting from a point where you tap on a series (bar, line, etc) and then swipe left or right and let go. This causes a crash. Please try try creating a bar chart, for example, and then pan it left or right. If you pan by touching above all the series, you're fine. If you pan by touching a series first, it crashes.

This is rather time sensitive and we purchased your product specifically for this project. Unfortunately, we are now thinking we may have to abandon your product because this is a serious issue and a show stopper. A quick turn around would be greatly appreciated.

Thanks very much!
Bob

Re: Unhandled exception in iOS charting

Posted: Thu May 10, 2012 9:32 am
by Pep
Hi Bob,

yes, you're correct, I'm able to reproduce the problem here.
I'm trying to fix it. I can advise and send the new assembly to you when it's fixed. Hope as soon as possible.

Re: Unhandled exception in iOS charting

Posted: Thu May 10, 2012 2:42 pm
by yeray
Hi Bob,

I've just sent the fixed dll to the mail account you have registered in this forum.
Don't hesitate to let us know if you still find any problem with it.

Re: Unhandled exception in iOS charting

Posted: Thu May 10, 2012 3:35 pm
by 17262249
Yeray,

Thanks so much. I installed the new DLL and it's working. You rock! Thanks for the great support Steema!

Bob

Re: Unhandled exception in iOS charting

Posted: Thu May 10, 2012 10:41 pm
by 17262249
Ok guys, the crash problem is corrected, but now I have something else going on related to this.

Now if I do a swipe to scroll the bar graph, the click/tap is registered right away. We have a click handler that "Zooms" in to the next level of data when you pick a series. This needs to only happen when the user taps and does not swipe. And likewise, when we swipe, we need it to move and not do the click event. Here's our click series handler. Any suggestions would be great.

Thanks,
Bob

void Handle_chartClickSeries (object sender, Steema.TeeChart.Styles.Series s, int valueIndex, UIGestureRecognizer e)
{
if (e.State == UIGestureRecognizerState.Cancelled ||
e.State == UIGestureRecognizerState.Failed ||
e.State == UIGestureRecognizerState.Possible)
return ;

if (valueIndex > s.XValues.Count)
return;

switch (_resolution)
{
case "Monthly":
_resolution = "Daily";
break;
case "Daily":
_resolution = "Hourly";
break;
case "Hourly":
default:
return;
}

_startDate = Steema.TeeChart.Utils.DateTime(s.XValues[valueIndex]);

DisplayPortraitData();
DisplayChartData();
}

Re: Unhandled exception in iOS charting

Posted: Tue May 15, 2012 8:58 am
by Pep
Hi Bob,

I think one woy could be checking what kind of UIGestureRecognizer is into the Handle_chartClickSeries method. You should be able to do something like:

Code: Select all

if (e is UISwipeGestureRecognizer)
{}

Re: Unhandled exception in iOS charting

Posted: Tue May 15, 2012 2:50 pm
by 17262249
Thank you Josep! We got it working.

Bob