Creating Charts in Batch
With AQT you can create charts in batch / unattended mode. This can be useful for creating regular charts with a script or in an overnight batch process.
To do this:
- build the chart in the Charting window
- click on File > Save Chart to save the chart as an *.xcf file.
This chart file will be a template for the charts created by your batch script. Most of the information about your chart will be contained with the chart file. This includes information such as as chart type, series colors, legends, labels etc.
When you run the chart in batch, you just need to provide information on the data for the chart - eg. the query text, the database the query runs against etc.
- on the Chart window, go File > View Chart Script. This will show you the script which defines your chart. Copy this script to the SQL window.
- you will need to amend the script to include either a saveas or exportfile parameter. You must specify one of these parameters when running the script in batch mode
- the saveas parameter specifies the name of the resultant Chart (.xcf file)
- the exportfile parameter specifies the name of an image file the chart is to be exported to. This can be of types jpg, bmp, png, gif, tif or wmf. Exporting to a pdf file is not supported in batch.
- you can have both a saveas and an exportfile parameter.
- if you are exporting the chart to an image file you can also specify the dimensions of the image file. This is given with the exportimagesize parameter, example
exportimagesize=(800,600)
. In this the image will have a width of 800 pixels and a height of 600 pixels. - the script will have a Caption and Footer parameters which are not used when the script is run in batch mode; these parameters can be removed.
- you can run this script from the Run SQL window:
- the chart will be created and written to the saveas file, and/or exported to the exportfile file.
- you can view the saveas file by going to the Database Explorer window, clicking on View > Queries. The chart will shown in the list of queries. When you click on this you will be shown the chart in the right pane.
- once you have tested the chart script, you can incorporate it into a batch script using the procedure outlined in Unattended Batch Mode.
- when the chart is created, it will have a Footer which will give the date / time the chart was created. You may also wish to amend the saveas or exportfile filename and / or Header to be the different every time a chart is created.
Example:
--aqt chart,series=(col=Sum_Of_quantity_ordered,title=Total Ordered),labelcol=part_number,header="Status of Orders",layout=order_line.xcf,sql="select part_number, sum(quantity_ordered) as Sum_Of_quantity_ordered from Order_Line group by part_number",dbs=AQTDemo,saveas=order_line_20110525.xcf,exportfile=order_line_20110525.jpg,exportimagesize=(800,600)
If the saveas or exportfile file names are not fully qualified, they will be created in the Queries directory.