Package limn.components.chart
Class ChartFormats
java.lang.Object
limn.components.chart.ChartFormats
Ready-made number formats for axis ticks and tooltip values: what a chart puts on
screen when the application does not supply its own
Chart.setValueFormat(DoubleFunction).
Every format here follows the language in effect where it
formats, read at that moment: a locale switch reaches charts already on screen, and a
chart inside a subtree that declares its own
locale formats in that subtree's language (ADR 035) — separators and digits alike —
because the chart's passes hold its effective locale in scope. A format is a plain
DoubleFunction<String>: anything else you write is equally acceptable, and reads
the same scope for free by asking I18n.locale() when it formats.
chart.setValueFormat(ChartFormats.compact()); // 12500 -> "12.5k"
chart.valueAxis().setFormat(ChartFormats.unit(" ms")); // 16 -> "16 ms"
-
Method Summary
Modifier and TypeMethodDescriptionstatic DoubleFunction<String> compact()Thousands folded into a suffix:27600reads"27.6k",1_200_000reads"1.2M".static DoubleFunction<String> decimals(int digits) Grouped with exactlydigitsdecimals.static DoubleFunction<String> number()Grouped, with up to two decimals and no trailing zeros:1234.5reads"1,234.5"in English and"1.234,5"in German.static DoubleFunction<String> percent(int digits) A fraction as a percentage:0.42reads"42%".static DoubleFunction<String> static DoubleFunction<String>
-
Method Details
-
number
Grouped, with up to two decimals and no trailing zeros:1234.5reads"1,234.5"in English and"1.234,5"in German. -
decimals
Grouped with exactlydigitsdecimals. -
compact
Thousands folded into a suffix:27600reads"27.6k",1_200_000reads"1.2M". Values below 1000 are left alone. -
percent
A fraction as a percentage:0.42reads"42%". Values that are already scaled to 0–100 wantunit(String)with"%"instead. -
unit
-
prefix
-