Features · tooltip

Tooltip value formatting

native

Format numbers/dates in tooltips

Matrix status native. Verification render · strong. ChartKit option: ChartKitChartSpecV1.encoding.y.format.specifier, ChartKitChartSpecV1.tooltip.template.

A format preset, or {specifier} for .2f, ,.0f, $,.0f, .1%, .2e, +.1f, and s. tooltip.fields[].unit and tooltip.template with {x}, {name}, {value}, {unit}, and data field names. A d3-style string repairs to {specifier}. An unknown pattern is CK3058. A missing template token is CK3059.

Source: chartkit:packages/core/src/format.ts

ChartKit spec

Passed validate() during npm run matrix:refresh. The SVG is the server render.

Units rose in Q2.Units rose in Q2.40455055Q1Q2
{
  "version": "1",
  "type": "line",
  "data": [
    {
      "quarter": "Q1",
      "units": 40
    },
    {
      "quarter": "Q2",
      "units": 55
    }
  ],
  "encoding": {
    "x": "quarter",
    "y": {
      "field": "units",
      "format": {
        "specifier": ",.0f"
      }
    }
  },
  "a11y": {
    "alt": "Units rose in Q2."
  },
  "size": {
    "width": 640,
    "height": 260
  },
  "tooltip": {
    "template": "{name} {value} {unit}",
    "fields": [
      {
        "field": "units",
        "format": {
          "specifier": ",.0f"
        },
        "unit": "u"
      }
    ]
  }
}

Other libraries

Option names are the paths recorded in the matrix. A grep-only cell names the identifier that matched, not a render test. Markdown copy: tooltip.format.md.

LibraryStatusOptionVerificationSource
Chart.jsnativegrep: callbackstooltip.callbacks.labelgrep · weakchart.js/dist/types/index.d.ts:2681
RechartsnativeTooltip.formatter, Tooltip.labelFormattertypes · strongrecharts/types/component/DefaultTooltipContent.d.ts:41
Apache EChartsnativetooltip.valueFormatter, tooltip.formattertypes · strongecharts/types/dist/shared.d.ts:8078
Highchartsnativetooltip.valueDecimals, tooltip.valuePrefixtypes · stronghighcharts/highcharts.d.ts:107591
Plotly.jsnativetrace.hovertemplatetypes · strongplot-schema.json#traces.{bar,barpolar,box,candlestick,choropleth,choroplethmap,…}.attributes.hovertemplate
NivonativeLine.yFormat, Line.xFormattypes · strong@nivo/line/dist/types/types.d.ts:133
VictorynativeVictoryTooltiplabels functiontypes · strongvictory-tooltip/lib/victory-tooltip.d.ts:66
visxmanualGrouprender your own contentmechanism · weak@visx/group/lib/Group.d.ts:15
ApexChartsnativetooltip.y.formattertypes · strongapexcharts/types/apexcharts.d.ts:4816
Tremor (npm)nativeLineChart.valueFormattertypes · strong@tremor/react/dist/index.d.ts:60
Observable Plotnativegrep: formattip format / channelsgrep · weak@observablehq/plot/src/scales.d.ts:349
Vega-Litenativegrep: formatgrep · weak84: "description"
AG Chartsnativegrep: renderergrep · weakag-charts-enterprise/dist/types/src/license/licenseManager.d.ts:2
amCharts 5nativegrep: labelTextgrep · weak@amcharts/amcharts5/index.d.ts:72
Google Chartsnativegrep: formatNumberFormat formatters on DataTablegrep · weak@types/google.visualization/index.d.ts:162
uPlotmanualOptions.hooksmechanism · weakuplot/dist/uPlot.d.ts:394
TradingView Lightweight Chartsnone—absence · absence—
MUI X Chartsnativegrep: valueFormattergrep · weak@mui/x-charts/SparkLineChart/SparkLineChart.d.ts:43
Mermaid (chart-ish diagrams only)none—absence · absence—
AntV G2nativegrep: itemsgrep · weak@antv/g2/lib/runtime/transform.d.ts:10