SetXDataLabelPos

SetXDataLabelPos — Position and control X data labels

Synopsis

$plot->SetXDataLabelPos($xdlp)
    

Description

SetXDataLabelPos determines if and where X data labels are drawn. For vertical plots, these are X axis data labels, which display the label strings from your data array. The labels can be drawn at the bottom of the plot (below the X axis), above the plot, in both positions, or neither. For horizontal plots, these are X data value labels, displaying the value of the data point. They can be drawn within the plot to label bars and bar segments. This type of label is only available for 'bars' and 'stackedbars' plots.

Parameters

$xdlp

A string indicating the desired position for the X data labels:

PositionDescription
plotdownData labels below the plot. This is for vertical plots.
plotupData labels above the plot. This is for vertical plots.
bothData labels both below and above the plot. This is for vertical plots.
plotinData value labels to the right (or left) of each bar. For stacked bar charts, this means only the bar total labels and not the bar segment labels. This is valid for horizontal bar and horizontal stacked bar plots only.
plotstackData value labels to the right of each bar, and just left of the end of each bar segment. This is valid for horizontal stacked bar plots only. It turns on both bar total labels (as with 'plotin') and bar segment labels.
noneNo data labels or data value labels

Notes

With vertical plots, this function controls the X axis data labels. For an example, see Section 5.3, “Example - Area Plot”, where the labels are enabled by default and displayed below the X axis. With horizontal plots, this function controls the X data value labels. For examples, see Example 5.27, “Horizontal Bar Chart” and Example 5.28, “Horizontal Stacked Bar Chart”.

The default position for X data labels (for vertical plots) is below the plot. However, PHPlot only enables the data labels if SetXDataLabelPos was used to position them, or if SetXTickLabelPos was not used to enable the tick labels and the data labels are not all empty.

The default position for X data value labels (for horizontal plots) is 'none', meaning no labels. X data value labels only apply to horizontal bar and stackedbar plots.

For tick labels, see SetXTickLabelPos.

The bar segment labels, if enabled ('plotstack'), are drawn inside the bars and may not be very visible if dark colors are used for the bar fill. Bar segment labels will be omitted for segments which are too short.

X data value labels will be drawn to the left of the bars for negative values. This only applies to horizontal bar charts. Stacked bar charts are not allowed to have negative values.

If X data lines are enabled with SetDrawXDataLabelLines, then SetXDataLabelPos() also determines the direction of the lines which are drawn from the data points.

The X data label text angle is set with SetXDataLabelAngle. The X data label text format can be controlled with SetXDataLabelType or SetXLabelType.

History

Horizontal bar plot data value labels were added in PHPlot-5.1.3. Through PHPlot-5.1.2, the 'plotin' and 'plotstack' values were not available.

Through PHPlot-5.0.7, the default position for X data labels was below the plot ('plotdown'). This would result in overlaid data and tick labels by default. In addition, positioning the X tick labels with SetXTickLabelPos with a position other than 'none' resulted in disabling the X data labels, and vice-versa. If both tick and data labels were positioned, the later setting overrode the earlier, which was turned off. Starting with PHPlot-5.1.0, PHPlot handles tick and data label positions as described in the notes above.