Hi there,
I am adding an annotation to my Gantt chart and I am using primitive.Caps = PCaps.HitTest to respond to the mouseover event.
Please can you advise how I now respond to a mouse click event on this annotation to identify the annotation that has been clicked on.
I raised a similar question last year but can not find that answer in the forums now.
Thanks in advance,
Matt
OK, I'll look into the possibility of upgrading.
Thanks.
Unfortunately, with our current Chart API the functionality that you want to do is possible only with this way. We are adding more advanced functionality for chart interaction in v8.2 so I can guess that you need to update to this version.
Thanks for the reply, but I am using version 7.3 and there doesn't appear to be a GetBoxSize() method in the BoxAnnotation class. :(
Also the calulation of the point 'pt' above assumes that the location type is 'pixel', but there are other options (like percentage) which would need a different calculation.
Because of the various possible Location types for an annotation, and because the Width and Height can be calculated based on the text, it makes it difficult to calculate the actual box without knowing the algorithms used. :( I assume there must be a helper method somewhere (like GetBoxSize()) that is used to calculate the Box rectangle from the annotation, that would be the ideal solution, but failing that just knowing how you calculate the size from the text would be a help?
You can try changing the ultraChart1_ChartDataClicked function:
{
}
if (boxAnnotation == null)
Point pt = new Point((int)boxAnnotation.Location.LocationX, (int)boxAnnotation.Location.LocationY);
pt.X -= size.Width / 2;
pt.Y -= size.Height / 2;
Point mousePosition = this.ultraChart1.PointToClient(System.Windows.Forms.Cursor.Position);
clickedAnnotation = annotation;
// add your logic here
Hi, I'm trying to do the same thing, respond to a mouse click on an annotation. The code you show does execute when I click on an annotation but how do I find which annotation was clicked?
Also, when I click on an annotation the event seems to be fired once for each annotation on the chart, although it always passes the same box, or at least it has the same rectangle of the one that was clicked. Any ideas on how to ensure it only fires once?
Brian