October 21, 2014
How to export chart image to a file
Charts can be exported as GIF or PNG files either manually or programmatically.
To export chart image manually, simply use Edit->Image->Export to file menu. Instead of exporting you can also copy the image to Windows clipboard (Edit->Image->Copy As Bitmap – this will copy bitmap image or Edit->Image->Copy As Metafile – this will copy vector/scalable graphic).
In order to export image in programmatic manner (from external program), you can use OLE automation interface described here http://www.amibroker.com/guide/objects.html
Below is a sample JScript code that shows how to use OLE interface from the script:
AB = new ActiveXObject("Broker.Application");
AW = AB.ActiveWindow;
AW.ExportImage( "C:\\example.gif", 640, 480 ); // 640, 480 are pixel dimension
The code is intended to be used from the outside of AmiBroker.
To use above code follow these steps:
- Open Notepad
- Copy-paste above the code
- Save the file with .JS extension (which means that system will treat this as JScript code)
- Make sure that AmiBroker is running with desired chart as active one
- Double click on .JS file to execute the JScript code
After doing so, resulting example.gif image file can be found on C: drive.
OLE automation can also be used from any other COM/OLE-aware programs/languages.
Filed by Tomasz Janeczko at 7:43 pm under Charting
Comments Off on How to export chart image to a file