SetNumberFormat

SetNumberFormat — Set the separators used when formatting number labels

Synopsis

$plot->SetNumberFormat($decimal_point, $thousands_sep)
    

Description

SetNumberFormat sets the separator characters used when formatting number labels. Labels are formatted as numbers when the 'data' format type is selected with SetXLabelType or SetYLabelType.

Parameters

$decimal_point

The character used as a decimal point, to separate the integer part of the label from the fraction part.

$thousands_sep

The character used as a thousands grouping separator (placed between every group of 3 digits left of the decimal point).

Notes

These separators are only used for labels when 'data' mode formatting is selected with SetXLabelType or SetYLabelType.

If SetNumberFormat is not used, PHPlot attempts to get the proper separator characters from your system locale. If this works and your locale is set correctly, you will probably not need to use this function. If locale information is not available, the default for decimal_point is a period, and the default for thousands_sep is a comma.

If your system locale is set to "C" or "POSIX", you might find that there are no thousands separators in your formatted labels. This is the correct behavior for those locales. If you cannot select a more specific locale, use SetNumberFormat to set the correct separators.

If your PHP script is forcing a specific locale with setlocale(), PHPlot will probably undo that because it uses setlocale(LC_ALL, '') to import locale information from the environment. This is the only way to get at the environment locale settings, but it will override a forced locale in your script.

To set the number of decimal places, use SetPrecisionX and SetPrecisionY.

This was added to PHPlot-5.0.4. Versions up to and including 5.0rc3 always used a period for decimal point, and comma for thousands separator.