Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TextRenderer

A cell renderer which renders data values as text. The namespace for the TextRenderer class statics.

Hierarchy

Index

Type aliases

Static CellConfig

CellConfig: object

An object which holds the configuration data for a cell.

Type declaration

Static ConfigFunc

ConfigFunc<T>: function

A type alias for a cell renderer config function.

This type is used to compute a value from a cell config object.

Type parameters

  • T

Type declaration

Static ConfigOption

ConfigOption<T>: T | ConfigFunc<T>

A type alias for a cell renderer config option.

A config option can be a static value or a config function.

Type parameters

  • T

Static ElideDirection

ElideDirection: "left" | "right"

A type alias for the supported ellipsis sides.

Static FormatFunc

FormatFunc: ConfigFunc<string>

A type alias for a format function.

Static HorizontalAlignment

HorizontalAlignment: "left" | "center" | "right"

A type alias for the supported horizontal alignment modes.

Static VerticalAlignment

VerticalAlignment: "top" | "center" | "bottom"

A type alias for the supported vertical alignment modes.

Constructors

constructor

Properties

backgroundColor

backgroundColor: ConfigOption<string>

The CSS color for the cell background.

elideDirection

elideDirection: ConfigOption<ElideDirection>

Which side to draw the ellipsis.

font

font: ConfigOption<string>

The CSS shorthand font for drawing the text.

format

format: FormatFunc

The format function for the cell value.

horizontalAlignment

horizontalAlignment: ConfigOption<HorizontalAlignment>

The horizontal alignment for the cell text.

textColor

textColor: ConfigOption<string>

The CSS color for drawing the text.

verticalAlignment

verticalAlignment: ConfigOption<VerticalAlignment>

The vertical alignment for the cell text.

wrapText

wrapText: ConfigOption<boolean>

Boolean flag for applying text wrapping.

Methods

drawBackground

drawText

paint

Static formatDate

  • Create a date format function.

    Parameters

    • Default value options: IOptions = {}

      The options for creating the format function.

    Returns FormatFunc

    A new date format function.

    Notes

    This formatter uses Date.toDateString() to format the values.

    If a value is not a Date object, new Date(value) is used to coerce the value to a date.

    The formatIntlDateTime() formatter is more flexible, but slower.

Static formatExponential

  • Create a scientific notation format function.

    Parameters

    • Default value options: IOptions = {}

      The options for creating the format function.

    Returns FormatFunc

    A new scientific notation format function.

    Notes

    This formatter uses the builtin Number() and toExponential() to coerce values.

    The formatIntlNumber() formatter is more flexible, but slower.

Static formatFixed

  • Create a fixed decimal format function.

    Parameters

    • Default value options: IOptions = {}

      The options for creating the format function.

    Returns FormatFunc

    A new fixed decimal format function.

    Notes

    This formatter uses the builtin Number() and toFixed() to coerce values.

    The formatIntlNumber() formatter is more flexible, but slower.

Static formatGeneric

  • Create a generic text format function.

    Parameters

    • Default value options: IOptions = {}

      The options for creating the format function.

    Returns FormatFunc

    A new generic text format function.

    Notes

    This formatter uses the builtin String() to coerce any value to a string.

Static formatISODateTime

  • Create an ISO datetime format function.

    Parameters

    • Default value options: IOptions = {}

      The options for creating the format function.

    Returns FormatFunc

    A new ISO datetime format function.

    Notes

    This formatter uses Date.toISOString() to format the values.

    If a value is not a Date object, new Date(value) is used to coerce the value to a date.

    The formatIntlDateTime() formatter is more flexible, but slower.

Static formatIntlDateTime

  • Create an international datetime format function.

    Parameters

    • Default value options: IOptions = {}

      The options for creating the format function.

    Returns FormatFunc

    A new international datetime format function.

    Notes

    This formatter uses the builtin Intl.DateTimeFormat object to coerce values.

    This is the most flexible (but slowest) datetime formatter.

Static formatIntlNumber

  • Create an international number format function.

    Parameters

    • Default value options: IOptions = {}

      The options for creating the format function.

    Returns FormatFunc

    A new international number format function.

    Notes

    This formatter uses the builtin Intl.NumberFormat object to coerce values.

    This is the most flexible (but slowest) number formatter.

Static formatPrecision

  • Create a significant figure format function.

    Parameters

    • Default value options: IOptions = {}

      The options for creating the format function.

    Returns FormatFunc

    A new significant figure format function.

    Notes

    This formatter uses the builtin Number() and toPrecision() to coerce values.

    The formatIntlNumber() formatter is more flexible, but slower.

Static formatTime

  • Create a time format function.

    Parameters

    • Default value options: IOptions = {}

      The options for creating the format function.

    Returns FormatFunc

    A new time format function.

    Notes

    This formatter uses Date.toTimeString() to format the values.

    If a value is not a Date object, new Date(value) is used to coerce the value to a date.

    The formatIntlDateTime() formatter is more flexible, but slower.

Static formatUTCDateTime

  • Create a UTC datetime format function.

    Parameters

    • Default value options: IOptions = {}

      The options for creating the format function.

    Returns FormatFunc

    A new UTC datetime format function.

    Notes

    This formatter uses Date.toUTCString() to format the values.

    If a value is not a Date object, new Date(value) is used to coerce the value to a date.

    The formatIntlDateTime() formatter is more flexible, but slower.

Static measureFontHeight

  • measureFontHeight(font: string): number
  • Measure the height of a font.

    Parameters

    • font: string

      The CSS font string of interest.

    Returns number

    The height of the font bounding box.

    Notes

    This function uses a temporary DOM node to measure the text box height for the specified font. The first call for a given font will incur a DOM reflow, but the return value is cached, so any subsequent call for the same font will return the cached value.

Static resolveOption

Generated using TypeDoc