Page 1 of 1

Legend.Clicked not aware legend items have been cleared?

Posted: Tue Jan 12, 2010 8:30 pm
by 15654674
Using TeeChart.WPF.dll version 4.0.2009.35592, we setup some code that watches where a user's mouse goes and allows them to click on items in the legend to perform actions on the series in the chart. We include highlighting of the items in the legend to indicate which item they're about to click on, and do so by hooking into the MouseMove event and passing the point in MouseEventArgs in to TChart.Legend.Clicked to determine which item is being hovered over. We seem to have run into a problem when the user clears the chart. We clear the chart by calling:

Code: Select all

TChart trendControl;
...
trendControl.Axes.Custom.Clear();
trendControl.Series.Clear();
trendControl.Legend.Items.Clear();
(All our axes are custom axes, so this seems to be effective.) However, with a clear chart, the MouseMove event handler's calls to trendControl.Legend.Clicked are still receiving return values which are not -1, indicating that there are legend items to be highlighted (even though there aren't - trendControl.Legend.Items.Count is 0). We've worked around it by adding code which checks to see that Legend.Clicked(...) < Legend.Items.Count before proceeding, but is this proper behaviour? Shouldn't Legend.Clicked be returning -1 all the time if there are no items in the legend and it's not being displayed, or is there something else that needs to be called to properly clear out all the information in a chart?

Re: Legend.Clicked not aware legend items have been cleared?

Posted: Wed Jan 13, 2010 3:15 pm
by yeray
Hi Charles,

Yes I've seen that the legend's clicked function was still returning values once the legend had been hidden. I've corrected it in the sources so it will be fixed for the next maintenance release (TF02014636).