From c8040d835d3b6068a44f57885102ea62362fe987 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Fri, 19 May 2023 17:01:33 -0700 Subject: [PATCH] crosshair format option --- src/marks/crosshair.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/marks/crosshair.js b/src/marks/crosshair.js index 9c1b06020a..11c418ebf9 100644 --- a/src/marks/crosshair.js +++ b/src/marks/crosshair.js @@ -1,6 +1,8 @@ +import {maybeAutoTickFormat} from "../axes.js"; import {getSource} from "../channel.js"; import {pointer, pointerX, pointerY} from "../interactions/pointer.js"; import {marks} from "../mark.js"; +import {map, string} from "../options.js"; import {initializer} from "../transforms/basic.js"; import {ruleX, ruleY} from "./rule.js"; import {text} from "./text.js"; @@ -96,7 +98,11 @@ function textOptions(k, pointerOptions, options) { // initializer to alias the channel values, such that the text channel can be // derived by an initializer such as hexbin. function textChannel(source, options) { + const format = options?.format?.[source]; return initializer(options, (data, facets, channels) => { - return {channels: {text: {value: getSource(channels, source)?.value}}}; + let value = getSource(channels, source).value; + const f = maybeAutoTickFormat(format, value); + if (f !== string) value = map(value, f); // prefer tabular-nums and formatDefault + return {channels: {text: {value}}}; }); }