Delegate not called when in SChartSelection.Point


#1

Relatively new user here so calibrate accordingly.

Trying to call a delegate when a point on a line series is selected by the user. Following the sample/example closely, I’ve setup my delegate properly

public class LineChartToggledSelection :SChartDelegate
	{
	
		public LineChartToggledSelection ()
		{
		}

		public delegate void ToggledSelectionEventHandler (ShinobiChart chart, SChartSeries series, SChartDataPoint dataPoint, PointF pixelPoint);

		public event ToggledSelectionEventHandler ToggledSelection;

		protected override void OnToggledSelection (ShinobiChart chart, SChartSeries series, SChartDataPoint dataPoint, PointF pixelPoint)
		{
			if (ToggledSelection != null) {
				ToggledSelection (chart, series, dataPoint, pixelPoint);
			}
		}
	}

and hook up to the chart properly

LineChartToggledSelection lineSeriesClickDelegate = new LineChartToggledSelection ();
lineSeriesClickDelegate.ToggledSelection += this.PointSelected;
chart.Delegate = lineSeriesClickDelegate;

Which should call

void PointSelected (ShinobiChart chart, SChartSeries series, SChartDataPoint dataPoint, PointF pixelPoint)
{
	this.txtWeight.Text = dataPoint.YValue.ToString();
}

But for some reason it doesn’t call it. Note that when I change

series.SelectionMode = SChartSelection.Point;

to

series.SelectionMode = SChartSelection.Series;

It starts to call just it just fine.  Seems like I don’t understand the difference between the two modes although I would have expected little to be required.  Any suggestions on why it’s not firing?


#2

Hi,

There are 2 different methods for selection events (both with the same name but different signatures). You’re using:

OnToggledSelection (ShinobiChart, SChartSeries, SChartDataPoint, System.Drawing.PointF)

which is called when a series is selected. The other method is used when a data point is selected:

OnToggledSelection (ShinobiChart, SChartDataPoint, SChartSeries, System.Drawing.PointF)

You should implement this method to receive callbacks when the selection mode is set to data point.

sam