Skip to content

MeasurementFormat

ClassChartGuruChartGuru
public sealed class MeasurementFormat

Locale-aware unit-bearing number formatter, modelled on Apple’s Measurement<UnitType>.FormatStyle. Fluent style configurable for Width (ChartGuru.UnitWidth), unit type (ChartGuru.MeasurementUnitKind), numeric precision, and culture.

public MeasurementFormat InUnit(MeasurementUnitKind kind)

Returns a measurement formatter that converts values into the requested standard display unit.

Parameters

Name Type
kind ChartGuru.MeasurementUnitKind

Returns

ChartGuru.MeasurementFormat

public MeasurementFormat InCustomUnit(string unit)

Returns a measurement formatter that appends the supplied custom unit without applying a standard-unit conversion.

Parameters

Name Type
unit System.String

Returns

ChartGuru.MeasurementFormat

public MeasurementFormat WithWidth(UnitWidth width)

Sets whether measurement units use wide, abbreviated, or narrow text and returns this formatter.

Parameters

Name Type
width ChartGuru.UnitWidth

Returns

ChartGuru.MeasurementFormat

public MeasurementFormat WithFractionDigits(int digits)

Sets the minimum fixed fractional precision, clamped to zero or greater, and returns this formatter.

Parameters

Name Type
digits System.Int32

Returns

ChartGuru.MeasurementFormat

public MeasurementFormat WithCulture(CultureInfo culture)

Sets the culture used for numeric formatting, falling back to the current culture when null.

Parameters

Name Type
culture System.Globalization.CultureInfo

Returns

ChartGuru.MeasurementFormat

public string Format(double value)

Formats a numeric measurement using the configured precision, culture, unit conversion, and unit width.

Parameters

Name Type
value System.Double

Returns

System.String

public MeasurementFormat()

public MeasurementUnitKind Unit { get; }

Returns

ChartGuru.MeasurementUnitKind

public string CustomUnit { get; }

Returns

System.String

public UnitWidth Width { get; }

Returns

ChartGuru.UnitWidth

public int FractionDigits { get; }

Returns

System.Int32

public CultureInfo Culture { get; }

Returns

System.Globalization.CultureInfo