Pete Posted August 24, 2007 Report Share Posted August 24, 2007 I'm having trouble catching the UserCommand event from the annotations context menu. I can add custom items to the chart context items and catch those events just fine, but I'm having trouble here. And by the way, it is somewhat bizarre that the default fill color for annotations is transparent, but there is no way for the end user to change the color back to transparent from their selected fill color. ChartFX.WebForms.Annotation.Annotations annots = new ChartFX.WebForms.Annotation.Annotations(); annots.EnableUI = true;annots.ToolBar.Visible = true; annots.EnableViewState = true;annots.Chart = this.chart; annots.ToolBar.Dock = ChartFX.WebForms. DockArea.Right;this.chart.Extensions.Add(annots); // Annotation Context MenuSubCommandCollection subcommands = annots.Commands[(int)ChartFX.WebForms.Annotation.AnnCommandID.Object].SubCommands; Command command = new Command(10);command.Style = CommandStyles.None; command.ImageIndex = 3;command.Text = "Set Transparent"; annots.Commands.Add(command); subcommands.Add(command.ID); -------- Javascript handler. Is there a different handler I should be using? < script type="text/javascript" for="<%= this.ChartID %>" event="UserCommand(sender,eventargs)"><!-- alert('UserCommand'); --> Quote Link to comment Share on other sites More sharing options...
Frank Posted August 29, 2007 Report Share Posted August 29, 2007 As an extension, Annotation commands are handled separately, you need to attach to the UserCommand event of the annotation extension, not the chart. Quote Link to comment Share on other sites More sharing options...
Pete Posted October 3, 2007 Author Report Share Posted October 3, 2007 I'm finally getting back to this. On the javascript side, I would need the unique id of the annotations object, but I'm missing something here... Chart javascript: <script type="text/javascript" for="<%= this.ChartID %>" event="UserCommand(sender,eventargs)"> Annotation javascript: <script type="text/javascript" for="<%= this.AnnotationID %>" event="UserCommand(sender,eventargs)"> Unfortunately, the UniqueID of the annotations object is null. ChartFX.WebForms.Annotation.Annotations annots = (ChartFX.WebForms.Annotation.Annotations)this.chart.Extensions[0]; return (annots != null) ? annots.UniqueID : null; What am I missing? Quote Link to comment Share on other sites More sharing options...
Frank Posted October 17, 2007 Report Share Posted October 17, 2007 The problem is that the annotation object is not part of the DOM. I'm not sure if you can attach an event to a COM (.NET) object from JavaScript (through code). You can get a pointer to the annotation extension from javascript by doing: var annotation = chart.Extensions.FindByName("Annotations"); But all the attempts I have made tried to attach an event to it have failed (I tried attachEvent, assigning the event itself). Quote Link to comment Share on other sites More sharing options...
Pete Posted October 17, 2007 Author Report Share Posted October 17, 2007 Well, this was one attempt at skinning the metaphorical cat. The real problem is getting annotations back to the server side so they can be saved along with our custom representation of the chart. Your suggestion got me part of the way there. If I draw an object and then kick off a javascript function, I can get to the annotations and further drill down to the individual objects. However, some of the properties don't appear javascript-friendly... For instance, annotation.List.Item(0).Color results in "Operation not supported. Unknown error: 0x80131509" annotation.List.Item(0).ObjectBounds is coming in as a User-Defined Type, so I can't access any of its properties. I can get Top, Left, Height, Width from the object itself, but if the object is an arrow, I'd need ObjectBounds to get at the orientation of the arrow. I'm still open to different implementation suggestions. If ChartFX can't send the annotations that are drawn by the user back to the server in an SFX_SendUserCallback call, then if I could pull out the interesting properties in javascript, stuff them into XML and send them back across, I'd be okay with that too. But I'm kind of stuck here. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.