The exportChart method offers four parameters, but the only one you must provide a value for is the fileName.
If you want to customize your export more than these four parameters allow, you can use the wijmo.exporter.exportChart method. See Custom Chart Exports for more information.
Provide a string value to use for the name of the exported file. By default, the file is saved to the Downloads folder with the name of the file, and the file extension comes from the type parameter.
By default, exportChart creates a png file, but you can specify any of the following five image types or one document type.
In the interest of getting you up and running quickly, we set this parameter by default to point to the demo export service we have set up here:
http://demos.componentone.com/ASPNET/ExportService/exportapi/chart
You can install your own export service in IIS v7.0 or higher. For more information, see Export Service Setup.
This parameter only applies if you set the type parameter to pdf. See Chart PDF Exports for more information.
In this example, we create a button click function for an <input> button element that calls our chart, and exports it to a PDF file named "ConsoleWars."
Script |
Copy Code |
---|---|
<script id="scriptInit" type="text/javascript"> require(["wijmo.wijbarchart", "chartexport"], function () { $(document).ready(function () { $("#wijbarchart").wijbarchart({ seriesList: [{ label: "US", legendEntry: true, data: { x: ['PS3', 'XBOX360', 'Wii'], y: [12.35, 21.50, 30.56] } }] }); }); $("#chartPdfExport").button().click(function () { $("#wijbarchart").wijbarchart("exportChart", "ConsoleWars", "pdf"); }) }); </script> |
Here is the example code above in action. Click the Export to PDF button to create a "ConsoleWars.pdf" file in your Downloads directory.