This section contains details on some of the PHPlot class member variables listed in the previous section. Remember that all PHPlot class member variables are meant for internal use only.
The fonts[]
array contains information about the fonts to
use for text on the plot. The array keys are the element names (such as
title
or legend
) as used in
SetFont, SetFontGD, or
SetFontTTF. The array values are arrays which contain
information about the font to use for that element. The keys and values of
the second-level arrays are:
Key | Value for TTF | Value for GD Font |
---|---|---|
ttf | True for a TrueType font | False for a GD font |
font | Pathname of the font file | Font number: 1 through 5 |
size | Font point size | Not used |
height | Height in pixels of an upper-case "E" in the font | Font height in pixels |
width | Width in pixels of an upper-case "E" in the font. | Font width in pixels |
spacing | Font's built-in inter-line spacing | Not used |
line_spacing | User-requested inter-line spacing factor. | Same as for TTF |
For TrueType fonts, the height and width can vary by character. The fonts array stores a height and width value for the font, but these are only used for sizing non-text plot elements (such as the legend color boxes). When PHPlot needs to know the drawn size of a string that will use TTF, it calculates the exact size of that specific string when drawn with the designated font.
GD fonts have fixed character width and height, so the values stored in the fonts array can be used to calculate text string sizes.
The spacing
key stores the TrueType font's built-in
inter-line spacing. Although TrueType fonts have this information
internally, PHP cannot access it, so PHPlot calculates it by taking the
height of the string "E\nE" and subtracting twice the height of the letter E.
The line_spacing
key stores the user-specified line spacing
adjustment for a text element, if any, from SetFont or
one of the two related functions. It will be NULL if the spacing was
not set for this element, meaning use the default line spacing.
See SetLineSpacing for more information on how this is used.
Here is an example of part of a fonts array, for the title element:
$plot->fonts['title'] = array( 'ttf' => FALSE, // This element uses a GD font 'font' => 2, // Use GD font 2 'height' => 13, // Provided by GD 'width' => 6, // Provided by GD 'line_spacing' => NULL, // Use default line spacing )
The label_format[]
array contains information about how
text labels should be formatted. This array has 5 entries, with keys 'x',
'y', 'xd', 'yd', and 'p'. The 'x' and 'y' entries are for tick labels, and the
'xd' and 'yd' entries are for data labels. (Note that PHPlot defaults data
label formatting to match tick label formatting, but this is handled in
CheckLabels, with the tick label format information copied
to the data label format information if necessary.) The 'p' entry is for
pie chart labels, and will only exist for pie charts. (The 'p' entry was
added in PHPlot-5.6.0.)
The value of each entry in label_format
is an array
containing formatting information. The arrays are empty by default, meaning
there is no special formatting. If formatting has been enabled, for example
with SetXLabelType, the arrays can contain the following
keys and values:
Key | Used with type | Value |
---|---|---|
type | Formatting type: data, time, printf, or custom. | |
precision | data | The number of decimal positions to produce. |
prefix | data | A prefix string to append to the label (for example, a currency sign). |
suffix | data | A suffix string to append to the label (for example, a currency sign or percent sign). This replaces data_units_text (which still works too). |
time_format | time | The date/time format string for the PHP strftime() function. |
printf_format | printf | The format string for the PHP printf() function. |
custom_callback | custom | The function (or array with object and method name) to call to format the label. |
custom_arg | custom | An additional argument to pass to the custom_callback function. |
The plots[]
array contains information about known plot
types. Essentially, it tells FindDataLimits and
DrawGraph how to produce the main portion of the plot.
This was added in PHPlot-5.3.0.
This is a static member variable in the PHPlot class, so it must be
accessed as PHPlot::$plots
and not through an instance
of the class. It has protected visibility, so is not accessible from
outside the class or derived classes.
The array keys are the plot types (for example: 'bars', 'linepoints'). These must not include upper case letters. The values are arrays which contain information about the plot type. The keys and values of the second-level arrays are:
Key | Value |
---|---|
draw_method | Name of the PHPlot class method (function) to call to draw the 'insides' of the plot. This is the only required entry. The function is responsible for drawing everything inside the plot area. (That is, everything except the plot titles, axis lines, tick marks and tick labels, grid lines, and legend.) |
draw_arg | Optional argument(s) for the drawing method named by draw_method. If present, this must be an array. Each element of the array is passed to the draw_method function as a separate argument. If this is not specified, the drawing method is called with no arguments. This is generally used to 'overload' drawing methods so they handle multiple similar plot types. |
draw_axes | A flag to indicate if the X axis and Y axis should be drawn. The default is TRUE. This is set to FALSE for pie charts. |
abs_vals | Special data processing flag. If TRUE, this tells FindDataLimits that the plot type will take the absolute value of all dependent variable values in the data array. FindDataLimits needs this information so it knows how to find the minimum and maximum values in the data array. The default if omitted is FALSE. |
sum_vals | Special data processing flag. If TRUE, this tells FindDataLimits that the plot type will sum up the dependent variable values in each row of the data array. FindDataLimits needs this information so it knows how to find the minimum and maximum values in the data array. The default if omitted is FALSE. If both abs_vals and sum_vals are TRUE, this means the plot type sums up the absolute values from the data array. (The stackedarea plot type does this.) |
The legend_pos[]
array contains information about
positioning of the legend. This is set by SetLegendPosition,
and by the functions which use it (SetLegendPixels and
SetLegendWorld).
This was added in PHPlot-5.4.0, replacing scalar variables legend_x_pos,
legend_y_pos, and legend_xy_world.
The array keys correspond to the arguments to SetLegendPosition and are shown in the following table.
Keys | Value |
---|---|
x, y | Relative coordinates of a point on the legend box |
mode | One of: image, plot, title, or world |
x_base, y_base | Relative coordinates of a point on the image, plot, or title, or world coordinates |
x_offset, y_offset | Pixel offset to be applied last |