Skip to content

crosshair format option #1597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/marks/crosshair.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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}}};
});
}