Page 1 of 1
Double click chart series in IOS application
Posted: Tue Jul 24, 2012 12:05 pm
by 17262900
Hello,
I am developing an ios application using Teechart. I have created a bar chart. Now want 2 events :
1.) single tap/click on series : to display tooltip of x and y axes values.
2.) Double tap/click series : to drill down the chart.
I am able to find out the code for single click on series as follows:
this.chart.ClickSeries += (sender, s, valueIndex, e) =>
{ };
Please let me know how can i catch the double click on chart series. Sample code would be helpful.
Thanks
Re: Double click chart series in IOS application
Posted: Fri Jul 27, 2012 9:21 am
by yeray
Hi,
Take a look at the discussion here:
http://www.teechart.net/support/viewtop ... recognizer
Instead of using the clickBackGround event, you could use the clickSeries. Then, you could use the uirecognizer parameter to know what kind of gesture has arrived and the numberOfTouches.
Re: Double click chart series in IOS application
Posted: Tue Jul 31, 2012 6:04 am
by 17262900
Hi Yeray,
I am able to find double click on my chart.
Following is my code:
Code: Select all
var tapRecognizerSingle = new UITapGestureRecognizer(this,new MonoTouch.ObjCRuntime.Selector("HandleTapFromDouble"));
tapRecognizerSingle.NumberOfTapsRequired = 2;
tapRecognizerSingle.Delegate = new GestureDelegate();
this.chart.AddGestureRecognizer(tapRecognizerSingle);
[Export("HandleTapFromDouble")]
public void HandleTapFromDouble (UITapGestureRecognizer recognizer)
{
new UIAlertView("Double", "No of touches: " + recognizer.NumberOfTouches.ToString(),null,"OK",null).Show();
}
// delegate methods for UITapGestureRecognizer
public class GestureDelegate : UIGestureRecognizerDelegate
{
public override bool ShouldReceiveTouch (UIGestureRecognizer recognizer, UITouch touch)
{
return true;
}
public override bool ShouldBegin (UIGestureRecognizer recognizer)
{
return true;
}
public override bool ShouldRecognizeSimultaneously (UIGestureRecognizer gestureRecognizer, UIGestureRecognizer otherGestureRecognizer)
{
return true ;
}
}
recognizer.NumberOfTouches.ToString() always gives me 1.
but my requirement is to find double and single click on CHART SERIES and find out the clicked x and y axes values.
For single click we already have ClickSeries event.
Code: Select all
this.chart.ClickSeries += (sender, s, valueIndex, e) =>
{
string Yvalue = s.YValues [valueIndex].ToString();
string Xvalue = s.XValues [valueIndex].ToString();
string Title = s.Title;
string MarkValue = s.LegendString(valueIndex, LegendTextStyles.Plain);
Re: Double click chart series in IOS application
Posted: Thu Aug 02, 2012 8:43 am
by Pep
Hello,
I've been looking at the code you are using. The first code will add the gesture to the Chart, but not just to the Series of the Chart. In the case you want to control the touch over the Chart you could use the ClickBackground event, as it's used into the post Yeray said, there you should be able to control the numberoftouches used in recognizer.
Please do not hesitate to contact us if you still having problems.
Re: Double click chart series in IOS application
Posted: Fri Aug 03, 2012 6:36 am
by 17262900
Hello
Thanks for your reply.
ClickBackground event will not serve my purpose. I want to find click on series event in following two cases;
1.) Single click on chart series only (not the background of the chart.) . For this we have [this.chart.ClickSeries += (sender, s, valueIndex, e) => ]
2.) Double click on chart series only (not the background of the chart.)
Please let me know how can i capture double click on chart series. And i want clicked series x and y axes values on double click.
Thanks
Re: Double click chart series in IOS application
Posted: Fri Aug 03, 2012 8:12 am
by Pep
Hello,
Ok, I'm going to prepare an example code and send it to you asap.
Re: Double click chart series in IOS application
Posted: Thu Aug 09, 2012 6:17 am
by 17262900
Thanks Josep
I am waiting..
Re: Double click chart series in IOS application
Posted: Mon Aug 13, 2012 10:54 am
by Pep
Hello,
sorry for delay, here an example of code which allows to catch double tap into the Chart view, and also checks if tap has been done over the Series pointer, hope that it helps :
Code: Select all
// This method could be called insode the ViewDidLoad
WireUpTapGestureRecognizer ();
protected void WireUpTapGestureRecognizer ()
{
// create a new tap gesture
UITapGestureRecognizer tapGesture = new UITapGestureRecognizer ();
// wire up the event handler (have to use a selector)
tapGesture.AddTarget ( () => {
Console.WriteLine("Chart tapped @" + tapGesture.LocationOfTouch (0, (UIView)_controller.chartController.View).ToString ());
if (_controller.chartController.chart.Series[0].Clicked(Point.Round(tapGesture.LocationOfTouch(0, (UIView)_controller.chartController.View)))==1)
Console.WriteLine("Series double clicked");
});
// configure it
tapGesture.NumberOfTapsRequired = 2;
// add the gesture recognizer to the view
_controller.chartController.View.AddGestureRecognizer (tapGesture);
}
Re: Double click chart series in IOS application
Posted: Tue Aug 14, 2012 9:57 am
by 17262900
Hello Josep,
Thanks for the sample code. It was very useful.
Following is my final code to drill on double click of chart series:
Code: Select all
protected void WireUpTapGestureRecognizer()
{
// create a new tap gesture
UITapGestureRecognizer tapGesture = new UITapGestureRecognizer();
// configure it
tapGesture.NumberOfTapsRequired = 2;
// wire up the event handler (have to use a selector)
tapGesture.AddTarget(() => {
Steema.TeeChart.Styles.Series s = this.chart.Series [0];
int valueIndex = s.Clicked(Point.Round(tapGesture.LocationOfTouch(0, (UIView)this.chartView)));
int iSeriesCount = this.chart.Series.Count;
int iCounter = 1;
for (iCounter=1; iCounter<=iSeriesCount; iCounter ++)
{
if (this.chart.Series.Count >= iCounter)
{
s = this.chart.Series [iCounter - 1];
valueIndex = s.Clicked(Point.Round(tapGesture.LocationOfTouch(0, (UIView)this.chartView)));
if (valueIndex >= 0)
{
DrillChartOnClick(s, valueIndex);
}
}
}
}
);
// add the gesture recognizer to the view
this.chartView.AddGestureRecognizer(tapGesture);
}
Re: Double click chart series in IOS application
Posted: Tue Aug 14, 2012 10:24 am
by Pep
Hi,
ok, I'm glad to hear that.
best regards !