When exporting charts using batch export component, the component raises 3 events (calls JavaScript methods) during the total course of action:
- FC_ExportReady(string DOMId) - This is raised when individual charts in the queue have finished capture process and have passed their data to export component. Between initiation of chart export and till the time FC_ExportReady event is raised, you might show a waiting message/alert to the user that the chart is in processing stage.
- FC_Exported(Object objRtn) - This is raised when the user selects an individual chart from UI to be saved on his disk (not possible when saveMode is set as batch). This method name can be changed by specifying the same in individual chart's XML as exportCallback attribute.
- FC_BatchExported (Object objRtn) - This is raised when the entire batch was saved as a single file on user's disk.
To handle these events, you need to define this function in your JavaScript code. In case of FC_Exported(objRtn) or FC_BatchExported(objRtn), objRtn contains the following parameters (returned from Export Component):
- statusCode - Has the value of 1 in case of success, and 0 in case of failure.
- statusMessage - In case of failure, this parameter contains a string description of the error (returned by server)
- fileName - If saving was successful, this parameter contains the HTTP reference to the image/PDF file saved on server
- width & height - If saving was successful, these parameters contain the width/height of saved image. Else, they contain 0.
- DOMId - In case of Save-All, this parameter contains a list of DOMId of the charts in queue that were successfully exported separated by comma. In case of individual chart saving, it contains that chart's DOM Id.
Let's quickly see an example code where all the callback functions has been implemented. In this example, we just track the events and show messages using JavaScript alert. |