Jump to content
Software FX Community

Programmatically accessing user-drawn annotations?


Pete
 Share

Recommended Posts

I am evaluating ChartFX, and am attempting to programmatically get at annotations that were drawn onto the .NET chart by the user through the Annotations toolbar.  For testing purposes I'm using the chart's click handler.  The other properties of the chart in the event correctly reflect the client side state, but annotations are not there.

I tried enabling ViewState on the annotations object.  But when I step through the code, EnableViewState = true does not change the state of the object.  I'm not sure if this has a bearing on my issue or not.

Am I missing something here?

ChartFX.WebForms.Annotation.Annotations annots = new ChartFX.WebForms.Annotation.Annotations();

annots.EnableUI =

true;annots.ToolBar.Visible = true;

annots.Chart = Chart1;

annots.EnableViewState = true;  // <-- Does not change state

Chart1.Extensions.Add(annots);

Link to comment
Share on other sites

What exactly do you want to do? You want to capture in your server a click event in the chart and then from it go through all the annotation objects created by the user?

Are you rendering as a .NET Client Control or as an image?

Please elaborate on what you need to do with the annotation objects and where (server or client).

Link to comment
Share on other sites

The chart is rendered as a .NET Client Control.

Yes, in short I'm looking to get annotations drawn by the user on the client side back to the server side.  I'm open to your suggestion on implementation details, or letting me know if this is even possible.

The user draws an annotation using the exposed ChartFX annotations toolbar.  I was hoping there was some sort of server-side event that would fire whenever an annotation was created or updated.  Since I didn't find that sort of event in the documentation (does one exist?), I just used the chart click event as a convenient entry point for a callback -- in reality, I'd probably use SFX_SendUserCallback from javascript.  The click event fired correctly (so my trust settings are okay), and all of the client-side chart state was correct on the server side, except for the chart.Extensions part where the annotations live.  Since the client-side annotations weren't there, I postulated that I needed to enable ViewState for the Annotations; however setting ViewState to true didn't stick.  I don't know if that is integral to the solution or not, and don't really care as long as I can get the client side annotations back to the server side.

 

Link to comment
Share on other sites

To minimize amount of data transferred to the server, for postback we serialize the chart using our "Template" settings, this means for example we do not save the chart's data.

Unfortunately, the Annotation extension does not serialize the annotation objects when the Data flag is not turned on so unless we modify our code you will have to turn on this flag (e.g. chart1.TemplateContents |= FileContents.Data). Note that in chart with a big number of points this might impact your performance.

I have not personally tested this scenario, please let us know if it works, if it doesn't we might be able to find other ways for the annotation to be sent back to the server as it sounds useful.

JuanC

 

Link to comment
Share on other sites

  • 2 weeks later...

Unfortunately, this doesn't keep the extensions around.  I tried different combinations of TemplateContents (and FileContents), but that didn't help.

On the plus side, I also needed to get TitlesText and Scales, so the tip helped me on a tangential issue.

Any other thoughts?

Link to comment
Share on other sites

  • 4 weeks later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...