ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Button or another method to use to launch makeChart
Posted by Thom on Jun-07-2012 22:15
What is the preferred method to use to have an end-user click a 'button' to have the option
to save the chart to a designated location? I have reviewed previous forum posts but didn't
find anything specific to this.

Thank you,

Thom

  Re: Button or another method to use to launch makeChart
Posted by Peter Kwan on Jun-07-2012 23:31
Hi Thom,

For web applications, ChartDirector charts are just normal images, the same as any other images you use on your web page. The users can use the features of their browsers to save the images. In most browsers, the user can "right click" on the image, and select "Save Picture As", just like saving any other images.

Regards
Peter Kwan

  Re: Button or another method to use to launch makeChart
Posted by Thom on Jun-07-2012 23:38
Yes and that is working fine but I would like to have the ability to auto-save the graph or
by using a button if they select to do so. Is this possible? The markChart works great but I
want to give the end-user to the option to save it.

  Re: Button or another method to use to launch makeChart
Posted by Peter Kwan on Jun-08-2012 23:55
Hi Thom,

Do you mean to "auto-save" the chart on the server hard disk, or on the client computer (the computer with the browser)?

To "auto-save" the chart on the server hard disk, you just need to use c.makeChart("/path/of/file/aaa.png");

It is not possible to "auto-save" anything on the client computer in any arbitrary directory. (If you can "auto-save" a file on the client computer in any arbitrary directory, then a hacker can easily hack the computer.) The user may need to manually choose where to save the file, and some browsers may save the file to a certain protected directory.

As ChartDirector is just an image, you can save it just like any other image on your web page. The "right click / Save Picture As" is one method. If you prefer to use a push button instead, one method I know of that works with any image file is to use a script or serlvet to send the file as a MIME stream of type "image/png", and use HTTP headers to inform the browser that the image is intended to be saved as a file and not displayed. To apply this to your case, you would need to save the chart as an image file on the server side (use BaseChart.makeChart), and then your button should reference that script or servlet..

To begin with, you may try to test your script and button with a normal static image file. Once your code works with a static image file, it should work with the chart image file as well.

(Note: The above is not specific or related to ChartDirector. It is just a general method to save an image to the browser computer.)

Regards
Peter Kwan