Skip to content

Commit 75b972a

Browse files
committed
nicer label for extra channels
1 parent 2241a6a commit 75b972a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/mark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export function composeRender(r1, r2) {
150150
function maybeChannels(channels) {
151151
return Object.fromEntries(
152152
Object.entries(maybeNamed(channels)).map(([name, channel]) => {
153-
channel = maybeValue(channel);
153+
channel = typeof channel === "string" ? {value: channel, label: name} : maybeValue(channel); // for shorthand extra channels, use name as label
154154
if (channel.filter === undefined && channel.scale == null) channel = {...channel, filter: null};
155155
return [name, channel];
156156
})

src/marks/tip.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,16 @@ export class Tip extends Mark {
116116
const widthof = monospace ? monospaceWidth : defaultWidth;
117117
const ee = widthof(ellipsis);
118118

119-
// Initialize shorthand formats. TODO Don’t mutate.
119+
// Promote shorthand string formats to functions. TODO Don’t mutate.
120120
for (const key in this.format) {
121121
const format = this.format[key];
122122
if (typeof format === "string" && key in sources) {
123123
this.format[key] = (isTemporal(sources[key].value) ? utcFormat : numberFormat)(format);
124124
}
125125
}
126126

127-
// Initialize default formats for the facet scales. TODO Don’t mutate.
127+
// Borrow the scale tick format for facet channels; this is generally better
128+
// than the default format (and safe for ordinal scales). TODO Don’t mutate.
128129
if (index.fi != null) {
129130
const {fx, fy} = scales;
130131
if (fx && this.format.fx === undefined) this.format.fx = inferTickFormat(fx, fx.domain());

0 commit comments

Comments
 (0)