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 datatypes[]
array contains information about the
available data types. See Section 3.3, “PHPlot Data Types” for more
information about data types.
It is used by SetDataType to validated the supplied data
type, and by DecodeDataType to set the flags that
describe the datatype.
The goal is to keep the names and details about the data types in this array only, and minimize other uses of the actual data type names. However, each plot type drawing function (for example DrawLines) also 'knows' about the data types it supports, and specifies the data type names when calling CheckDataType.
This array was added in PHPlot-6.1.0.
It is a protected static member variable in the PHPlot class, so it must be
accessed as self::$datatypes
from inside the class (or a
derived class), and not through an instance of the class.
Is not accessible from outside the class or derived classes.
The array keys are the data types (for example: 'text-data').
The values are arrays which contain information about the data type.
The second-level array keys correspond to the 'datatype' flag variables,
without the 'datatype_' prefix. A key will be present, with the value
TRUE
, if the flag should be set for that data type.
The key will be absent if the flag should not be set.
For example: for data type text-data
, the array contains
one value: 'implied' => TRUE
. This means that for
data type text-data, the datatype_implied
flag should be
TRUE (indicating that this data type has implied independent variable
values), and all other flags should be FALSE. In addition to
implied
, the other possible keys are
pie_single
, error_bars
,
swapped_xy
, and yz
.
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
FormatLabel.)
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(s) for the PHP printf() function. This can be a single string, or an array of one to three strings. |
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. |
Use of multiple strings for printf_format
was added in
PHPlot-6.2.0.
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 |
The plots[]
array contains information about known plot
types. It is used by FindDataLimits,
DrawGraph, and other class functions to prepare for and
draw the main portion of the plot.
The goal is to contain the information about each available plot type
in a single place - this array. The actual names of the plot types (for
example 'bars' or 'linepoints') appear only in this array. To simplify
somewhat, adding a new plot type to PHPlot involves adding a new element to
the plots[]
array, and adding a new function to PHPlot
which draws the 'insides' of the plot.
This array was added in PHPlot-5.3.0.
It is a protected static member variable in the PHPlot class, so it must be
accessed as self::$plots
from inside the class (or a
derived class), and not through an instance of the class.
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. |
draw_arg | Optional argument array to pass to the draw_method function. |
suppress_axes | Optional flag indicating that the X axis and Y axis should not be drawn. Default is FALSE. |
abs_vals | Optional flag indicating that the plot type uses the absolute values of data. Default is FALSE. |
sum_vals | Optional flag indicating that the plot type sums up the values in each row. Default is FALSE. |
legend_alt_marker | Optional alternate marker mode for legends: box, shape, or line. |
adjust_type | Optional control for adjusting the end of an automatically calculated plot range (see notes below). |
Only the draw_method
entry is required. The named method
is used to draw everything inside the plot area. (That is, everything except
the plot titles, axis lines, tick marks and tick labels, grid lines, and
legend.)
The draw_arg
entry can be used to pass constant
arguments to the draw_method
method.
If present, this must be an array, and each element of the array is passed to
the drawing method 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.
The suppress_axes
flag indicates that X and Y axis lines
should not be drawn (used with pie charts, for example).
If omitted, FALSE is used, meaning the axis lines are drawn.
(Before PHPlot-6.0.0 this was called draw_axes
, with
default TRUE, and FALSE for pie charts.)
The two special data processing flags abs_vals
and
sum_vals
are used by FindDataLimits
to indicate how to compute the minimum and maximum data values.
Plot types that ignore sign and take absolute values of the data set
abs_vals
to TRUE.
Plot types that sum up the data values in each row set
sum_vals
to TRUE.
The default if omitted for both flags is FALSE, meaning the plot type
uses the values as specified in the data array.
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 optional legend_alt_marker
entry indicates the
use of an alternate maker shape in legends.
Use SetLegendUseShapes to select either the primary
mode or the alternate mode for legend shapes. The primary mode is a solid
filled color box. The alternate mode varies with the plot type, according
the the legend_alt_marker
entry.
Use 'box' for rectangular color boxes. This is the default if the
legend_alt_marker
key is omitted from the array.
Effectively, this means there is no alternate marker
mode for these plot types, because color boxes are the primary mode.
Use 'shape' for point shape markers, which applies to points plots and similar
types which use point shapes.
Use 'line' for short line segments, which applies to line plots and similar
types.
The optional adjust_type
entry controls adjustments
made to the end of an automatically calculated plot range.
See TuneXAutoRange and TuneYAutoRange
for more information.
This is used to indicate when a plot type needs additional space, perhaps
for labels, between the data extrema and the edge of the plot area.
If omitted, the default value 0 is used.
A value of 0 means apply the adjustment for the dependent variable only.
A value of 1 means apply the adjustment for both X and Y, and a value of
2 means do not apply the adjustment to either X or Y.
The rangectl[]
array contains parameters which are used
to control the automatic calculation of the plot area range.
The array contains 2 arrays, indexed as 'x'
and
'y'
for X and Y axis parameters respectively.
The keys and values of the second-level arrays are:
Key | Default | Description |
---|---|---|
zero_magnet | 0.857142 (Note this is 6/7) | Strength of the zero magnet |
adjust_mode | T | End adjustment mode: R, T, or I |
adjust_amount | (Dynamic; see GetRangeEndAdjust) | Amount of end adjustment, as a fraction of the plot range |
Values in this array are set with TuneXAutoRange and TuneYAutoRange. For more information see Section 4.6.4, “Automatic Range Parameters”. The values are used by CalcPlotRange.
The tickctl[]
array contains parameters which are used
to control the automatic calculation of tick intervals.
The array contains 2 arrays, indexed as 'x'
and
'y'
for X and Y axis parameters respectively.
The keys and values of the second-level arrays are:
Key | Default | Description |
---|---|---|
min_ticks | 8 | Minimum number of tick intervals |
tick_mode | NULL (calculated) | Tick increment calculation mode: 'decimal', 'binary', or 'date' |
tick_inc_integer | FALSE | If TRUE, force the tick increment to be a whole number |
Values in this array are set with TuneXAutoTicks and TuneYAutoTicks. For more information see Section 4.6.8, “Automatic Tick Increment Parameters”. The values are used by CalcStep.
This version of the manual was produced for the
PHPlot Sourceforge project web service site, which requires the logo on each
page.
To download a logo-free copy of the manual, see the
PHPlot project downloads
area.