Skip to main content

Module locale

Module locale 

Source
Expand description

Locale conventions for number and date labels.

A Locale bundles the decimal / thousands marks, the currency and percent conventions and the month / weekday names of a region. It is used

  • explicitly, by the label_*_locale formatters in crate::scale::format (e.g. label_currency_locale);
  • plot-wide, via GGPlot::locale: every default continuous axis and legend then labels its breaks with the locale’s marks, and date/datetime scales use its month names and date formats;
  • per scale, via ScaleContinuous::with_locale / ScaleDateTime::with_locale (overrides the plot locale).

Without a locale nothing changes: labels keep the . decimal mark, no thousands grouping on default axes, and ISO dates.

use ggplot_rs::locale::Locale;
use ggplot_rs::scale::format::label_currency_locale;
let de = Locale::from_tag("de-DE");
assert_eq!(label_currency_locale(&de, Some(0.01))(1234.5), "1.234,50 €");
let us = Locale::en_us();
assert_eq!(label_currency_locale(&us, Some(0.01))(1234.5), "$1,234.50");
assert_eq!(de.strftime(1_792_022_400, "%-d. %b %Y"), "15. Okt. 2026");

Structs§

Locale
Number and date formatting conventions of a locale.

Enums§

CurrencyPosition
Where a locale puts the currency symbol relative to the amount.