|
1 | 1 | import {channelDomain, createChannels, valueObject} from "./channel.js";
|
2 | 2 | import {defined} from "./defined.js";
|
3 | 3 | import {maybeFacetAnchor} from "./facet.js";
|
4 |
| -import {maybeKeyword, maybeNamed, maybeValue} from "./options.js"; |
5 |
| -import {arrayify, isDomainSort, isOptions, keyword, range, singleton} from "./options.js"; |
| 4 | +import {maybeNamed, maybeValue} from "./options.js"; |
| 5 | +import {arrayify, isDomainSort, isObject, isOptions, keyword, range, singleton} from "./options.js"; |
6 | 6 | import {project} from "./projection.js";
|
7 | 7 | import {maybeClip, styles} from "./style.js";
|
8 | 8 | import {basic, initializer} from "./transforms/basic.js";
|
@@ -150,17 +150,27 @@ export function composeRender(r1, r2) {
|
150 | 150 | function maybeChannels(channels) {
|
151 | 151 | return Object.fromEntries(
|
152 | 152 | 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 |
154 | 154 | if (channel.filter === undefined && channel.scale == null) channel = {...channel, filter: null};
|
155 | 155 | return [name, channel];
|
156 | 156 | })
|
157 | 157 | );
|
158 | 158 | }
|
159 | 159 |
|
160 | 160 | function maybeTip(tip) {
|
161 |
| - return tip === true ? "xy" : tip === false ? null : maybeKeyword(tip, "tip", ["x", "y", "xy"]); |
| 161 | + return tip === true |
| 162 | + ? "xy" |
| 163 | + : tip === false || tip == null |
| 164 | + ? null |
| 165 | + : typeof tip === "string" |
| 166 | + ? keyword(tip, "tip", ["x", "y", "xy"]) |
| 167 | + : tip; // tip options object |
162 | 168 | }
|
163 | 169 |
|
164 |
| -export function withTip(options, tip) { |
165 |
| - return options?.tip === true ? {...options, tip} : options; |
| 170 | +export function withTip(options, pointer) { |
| 171 | + return options?.tip === true |
| 172 | + ? {...options, tip: pointer} |
| 173 | + : isObject(options?.tip) && options.tip.pointer === undefined |
| 174 | + ? {...options, tip: {...options.tip, pointer}} |
| 175 | + : options; |
166 | 176 | }
|
0 commit comments