granite-0.7.4.0: Easy terminal plotting.
Copyright(c) 2025
LicenseMIT
Maintainermschavinda@gmail.com
Safe HaskellNone
LanguageGHC2021

Granite.Format

Description

Apply a declarative Formatter to a Double. Replaces the function-typed LabelFormatter used by the legacy Plot record, so the entire chart spec can stay JSON-shaped.

Synopsis

Documentation

data Formatter Source #

A declarative formatter applied to numeric tick / label values.

The Default behaves like the legacy formatter: scientific for very small or very large magnitudes, fixed-point with one decimal otherwise. The other constructors give the caller explicit control without needing to embed a Haskell function in the spec.

Constructors

FormatDefault 
FormatPrecision Int

fixed point with the given decimals

FormatScientific Int

scientific notation with the given decimals

FormatPercent Int

percentage (multiplies by 100), with given decimals

FormatComma

integer with comma grouping (1,234,567)

FormatDateTime !Text

epoch-millisecond value formatted with the given strftime-style pattern; unsupported in this phase, returns the raw value.

FormatTemplate !Text

a printf-like template with a single "{}" placeholder. This phase only supports "{}" itself.

FormatSI

SI suffixes (1.2k, 3.4M)

Instances

Instances details
Read Formatter Source # 
Instance details

Defined in Granite.Format

Show Formatter Source # 
Instance details

Defined in Granite.Format

Eq Formatter Source # 
Instance details

Defined in Granite.Format