makeup_format_js: Create a JavaScript function for formatting numbers in...

View source: R/makeup.R

makeup_format_jsR Documentation

Create a JavaScript function for formatting numbers in Highcharts

Description

This function creates a JavaScript function that can be used to format numbers in Highcharts with custom prefixes and suffixes, and optionally with SI prefixes such as "k" for kilo and "M" for mega. The function uses the which_num_format() and guess_specifier() functions to determine the appropriate formatting settings based on a sample vector and locale settings.

Usage

makeup_format_js(
  sample = NULL,
  locale = NULL,
  prefix = "",
  suffix = "",
  si_prefix = FALSE
)

Arguments

sample

A sample vector with the same data type and range as the data to be plotted, to use as a reference for the formatting settings. If not specified, default formatting settings will be used.

locale

A character string specifying the locale settings to use. If not specified, the default locale will be used.

prefix

A character string to prepend to each formatted value.

suffix

A character string to append to each formatted value.

si_prefix

A logical value indicating whether to use SI prefixes such as "k" and "M" to format the values. If TRUE, the values will be formatted with SI prefixes. If FALSE, standard formatting will be used.

Value

A JavaScript function for formatting numbers in Highcharts.

Examples

makeup_format_js(prefix = "$", suffix = " USD")


datasketch/makeup documentation built on Feb. 21, 2025, 6:53 a.m.