Chapter 6: Create and Display a Chart
Build a Small APPX Chart
Start from a shipped 1CD chart close to the required result. The following sequence describes a small bar chart using the documented 0CD API. Define application work fields long enough for the chart name, returned path and result handling; use the parameter field types shown by the matching routine in your installed release.
- Initialize a one-dimensional dataset through
.DATASET INITIALIZEand give it a name such asQUARTER SALES. - Add values 120, 90 and 150 through three
.POINT ADD NEWcalls. - Initialize an
XY Chartwith.CHART INITIALIZE. Use a distinct chart name for each independent specification. - Add a bar layer through
.XY ADD BAR LAYER. For this first single-dataset chart, use its documented automatic linking to the current dataset. - Set the chart size and plot area, add labels
Q1,Q2andQ3, and apply a title. - Render to a fresh filename by passing an alpha work field to
.CHART RENDERwith ShareY. - Check the routine's result and display the returned pathname only after success.
For a process that repeatedly replaces its datasets or handles several series, turn off automatic linking and explicitly manage the data group, dataset template and dataset link. Otherwise a later layer can retain the previously current dataset. The dataset routines and bar layer documentation describe the contracts.