Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/TargetProcess/tauCharts/llms.txt

Use this file to discover all available pages before exploring further.

Taucharts uses formatters to convert raw data values into human-readable strings on axes and in tooltips. The tickFormat API lets you retrieve any built-in formatter by name or register your own, then reference it anywhere a format name is accepted.

API reference

Taucharts.api.tickFormat.get
function
Retrieve a registered formatter function by name.
tickFormat.get(name: string): (x: any) => string
If the name matches a built-in or previously registered format, the corresponding function is returned. If no match is found, an identity formatter is returned instead.
Taucharts.api.tickFormat.add
function
Register a new named formatter.
tickFormat.add(name: string, formatter: (x: any) => string): void
Once registered, the name can be used anywhere tickFormat accepts a string — in guide, defaultFormats, or plugin formatter maps.

Built-in format names

The following names are available out of the box, sourced from formatter-registry.ts:
NameOutput exampleNotes
x-num-auto1.23k, 0.045Automatic number formatting using d3; removes trailing zeros
x-time-auto14-Jan-2024Resolved at runtime to day or day-utc based on utcTime setting
percent42.5%Multiplies by 100 and appends %
day14-Jan-2024Local time, d3 %d-%b-%Y
day-utc14-Jan-2024UTC, d3 %d-%b-%Y
day-short14-JanLocal time, d3 %d-%b
day-short-utc14-JanUTC, d3 %d-%b
week14-Jan-2024Local time, week start
week-utc14-Jan-2024UTC, week start
week-short14-JanLocal time, short week
week-short-utc14-JanUTC, short week
monthJanuary / January, 2024Year shown only for January
month-utcJanuary / January, 2024UTC variant
month-shortJan / Jan '24Year shown only for January
month-short-utcJan / Jan '24UTC variant
month-yearJanuary, 2024Always includes year
month-year-utcJanuary, 2024UTC variant
quarterQ1 2024
quarter-utcQ1 2024UTC variant
year2024
year-utc2024UTC variant
Any d3 format string (e.g. ".2f" or "%Y-%m-%d") that is not a registered name is passed directly to d3.format or d3.timeFormat, so you can use d3 specifiers without registering them first.

Using a formatter in guide

Pass a format name or an inline function to tickFormat on the x or y axis guide:
new Taucharts.Chart({
  type: 'bar',
  x: 'date',
  y: 'revenue',
  data: [...],
  guide: {
    x: { tickFormat: 'month' },          // named built-in
    y: { tickFormat: (x) => '$' + x.toFixed(2) }  // inline function
  }
});

Registering a custom formatter

Call tickFormat.add once before creating charts that use the new name:
Taucharts.api.tickFormat.add('currency', (x) => '$' + x.toLocaleString());

new Taucharts.Chart({
  type: 'bar',
  x: 'month',
  y: 'revenue',
  data: [...],
  guide: {
    y: { tickFormat: 'currency' }
  }
});

Using formatters in plugins

The tooltip and crosshair plugins accept a formatters map keyed by field name. Each entry can be a function or an object with label and format:
Taucharts.api.plugins.get('tooltip')({
  formatters: {
    revenue: {
      label: 'Revenue',
      format: Taucharts.api.tickFormat.get('currency')
    },
    date: 'month'   // reference a registered name directly
  }
})

defaultFormats setting

The defaultFormats entry in ChartSettings maps dimension types to format names. The built-in defaults are:
defaultFormats: {
  measure: 'x-num-auto',
  'measure:time': 'x-time-auto'
}
Override these globally or per chart:
// Global override
Taucharts.api.globalSettings.defaultFormats = {
  measure: 'currency',
  'measure:time': 'month'
};

// Per-chart override
new Taucharts.Chart({
  settings: {
    defaultFormats: {
      measure: '.2f'
    }
  },
  ...
});

Build docs developers (and LLMs) love