Forum Xamarin Xamarin.iOS

CorePlot : Bar selected event in coreplot

MelisaMelisa USMember

Hi, I'm currently trying to put some touch event on my coreplot barchart but it doesn't seems to work.

I see that coreplot have this "CPTBarPlotDelegate" and it have "BarSelected" event.
I've tried to create my own delegate class based on CPTBarPlotDelegate and override the BarSelected function with some UIAlert command.


public class MyBarDelegate : CPTBarPlotDelegate
{
private const string SelectedText = "Selected at";
private const string OkText = "OK";
public override void BarSelected (CPTBarPlot plot, int recordIndex)
{
Console.WriteLine("testtt");
new UIAlertView(SelectedText, recordIndex.ToString(CultureInfo.InvariantCulture), null, OkText, null).Show();
}
}

And put it in my bar chart


_graph.DefaultPlotSpace.AllowsUserInteraction = true;
_graph.DefaultPlotSpace.Delegate = new MyBarDelegate();

Can somebody please help? Thanks!!

Sign In or Register to comment.