Creates a new FormatterService from MAIDR data. Extracts format configurations from all layers and resolves format functions.
The MAIDR data containing layers with optional format configs
Rebuilds all layer formatters from updated MAIDR data. Called after a live data update replaces the chart data.
The updated MAIDR data
Gets the format function for a specific layer and axis.
The ID of the layer
The axis type ('x', 'y', or 'z')
The format function, or defaultFormat if not found
Whether the layer declared a format for this axis, as opposed to falling back to the default.
The chart description's data table asks before it formats: it has its own rounding, and a reader of an unformatted chart should see exactly what they saw before. Where an author did ask for currency, a percentage or a date, the table has to say the same thing the announcement does, or the two surfaces describe one number two ways.
The ID of the layer
The axis type ('x', 'y', or 'z')
True when the layer's JSON carried a format for that axis
Formats a value (single or array) using the formatter for the specified layer and axis.
This is the primary method for formatting values in the application. It handles both single values and arrays (e.g., boxplot outliers).
The value or array of values to format
The ID of the layer
The axis type ('x', 'y', or 'z')
Formatted string or array of formatted strings
Formats a single value (not an array) and always returns a string. Use this when you're certain the value is not an array.
The single value to format
The ID of the layer
The axis type ('x', 'y', or 'z')
Formatted string
Formats an array of values and always returns a string array. Use this when you're certain the value is an array.
The array of values to format
The ID of the layer
The axis type ('x', 'y', or 'z')
Array of formatted strings
Releases resources held by the service.
Service for managing value formatting across all layers in a MAIDR figure.
The FormatterService extracts format configurations from layer definitions and provides methods to format values consistently throughout the application.
Example