6.3. Available Callbacks

This section defines the currently available callback names. A callback name is also called a reason.

Most of the callbacks currently available are drawing callbacks, activated during the graph drawing process started by DrawGraph. By convention, a drawing callback occurs right after the event which it names. For example, the draw_titles callback will be called after drawing the plot titles.

Debug callbacks are for use when developing and debugging PHPlot itself. Needless to say, their use for other purposes is discouraged.

The following table lists the available callback reasons.

Callback Name:Calling Point:Extra Parameters:Notes:
data_colorEvery time a color is needed for a data element.$row, $col, $extraThe callback is expected to return an integer color index into the data colors array. This is for custom color selection. For more information, see Section 3.7, “Custom Data Color Selection”.
draw_setupAfter all setup, before drawing anything.(None)Anything drawn here will be covered by the background.
draw_image_backgroundAfter drawing the image backgrounds and border.(None) 
draw_plotarea_backgroundAfter drawing the plot area background.plot_areaplot_area parameter was added in PHPlot-5.1.0
draw_titlesAfter drawing the plot title, X and Y titles.(None)Called even if no titles were set.
draw_axesAfter drawing the X and Y axis and grid lines.(None)Not called for pie charts.
draw_graphAfter drawing the body of the graph.plot_areaplot_area parameter was added in PHPlot-5.1.0
draw_borderAfter drawing the plot area border.(None)Not called for pie charts.
draw_legendAfter drawing the legend, if legend is enabled.(None)Not called if no legend was set.
draw_allAfter all drawing is complete.plot_areaAdded in PHPlot-5.1.0
debug_textboxJust before drawing any text.$px, $py, $bbox_width, $bbox_heightProvides access to the orthogonal bounding box position and size for the text string.
debug_scaleCalled at end of many scale calculation functions.Function name, then an array of variable name => valueFor displaying intermediate values in margin and scale calculations.

Notes:

Several of the drawing callbacks include plot_area as an extra parameter. This is an array of 4 values that define the plot area within the image, in GD pixel coordinates, as left_x, top_y, right_x, and bottom_y. For more information, see Chapter 7, Plot Layout.

See Section 6.5, “Using Callbacks to Annotate Plots” for information on using the drawing callbacks to annotate your plot.