Utility Routines

*TOOLS/CHARTIMAGE

Generate a Chart Image File

Formats

1.

Generate a Chart Image File:

CALL "*tools/chartimage", ERR=stmtref, query$, library$, chart$, imgPath$ [,imgWidth, imgHeight]

2.

Load a Chart from a Query Definition:

CALL "*tools/chartimage", ERR=stmtref, query$, library$, chart$, control, [,controlSettings, var_iol$, var_rec$]

3.

Get Chart Definition:

CALL "*tools/chartimage;GetChartInfo", ERR=stmtref, query$, library$, chart$, object

(The Get Chart Definition format was added in PxPlus 2022.)

Where:

query$

Name of the query which owns the chart.

library$

Path of the library where the query definition resides.

chart$

Name given to the chart definition associated with the query. (Must be a public definition)

object

Variable to receive an *plus/winutil/autochart object that contains the chart definition.This must be freed by the caller when no longer needed. (added in PxPlus 2022)

imgPath$

Path for the resulting image file. (Must include image type suffix; i.e. .png, .jpg, .bmp, .htm/.html)

imgWidth

Width of the resulting image in pixels. (Optional - Default is 400 if not specified)

imgHeight

Height of the resulting image in pixels. (Optional - Default is 300 if not specified)

Note:
If an .htm or .html file is being generated for a Plus chart, set imgWidth and imgHeight to 0 (zero) to create HTML for a responsive chart (i.e. a chart that auto-resizes).

control

CTL value of the chart control to be loaded. (added in PxPlus 2019)

controlSettings

Values are: (added in PxPlus 2019)

   0 - Use chart format/titles from Query AutoChart definition
   1 - Use chart format/titles from control definition

var_iol$

(Optional) Compiled IOList of variables to be passed to the Load logic. (added in PxPlus 2019 Update 1)

var_rec$

(Optional) Values of variables in the IOList derived by REC(var_iol$). (added in PxPlus 2019 Update 1)

stmtref

Error transfer. Errors may result when:

Query library does not exist

Error #12

Query definition does not exist

Error #11

Chart definition files do not exist

Error #12

Chart definition does not exist

Error #11

Errors accessing temporary HTML file

Various errors

Errors generating image

Error #201 with explanatory messages

Description

This utility creates an image file (.png, .jpg, .bmp or .htm) based on a chart definition associated with a PxPlus Query+ public AutoChart Definition.

Not all chart brands are supported when generating images. Plus, RGraph and Google charts can be rendered on a Windows system; however, only Plus charts can be rendered on a Linux system. See Important Note, which outlines further restrictions.

If the specified chart brand is not supported by image generation, Plus charts will be used. To generate chart images, Plus charts are recommended, as well as using the .png image format, which does not require additional conversion.

Important Note:
To generate a chart image, certain third-party applications are required:

   On Windows servers, the Chrome browser is recommended for generating images based on Plus, Google and RGraph charts; however, the Firefox browser (v57 and later) can be used to generate images based on Plus charts.

   On Linux servers, the Firefox browser (v57 and later) will generate .png images for Plus charts. To generate .jpg and .bmp images, the ImageMagick command line tool must also be installed.

This utility can also be used to generate data to load a chart control based upon a PxPlus Query+ public AutoChart definition using Format 2.

(Plus charts were added in PxPlus 2019.)