Skip to content

Commit ca6fb81

Browse files
authored
tip ignores literal colors (#2091)
1 parent 7c8a465 commit ca6fb81

File tree

5 files changed

+442
-2
lines changed

5 files changed

+442
-2
lines changed

src/channel.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ export function inferChannelScale(name, channel) {
4848
case "stroke":
4949
case "color":
5050
channel.scale = scale !== true && isEvery(value, isColor) ? null : "color";
51+
channel.defaultScale = "color";
5152
break;
5253
case "fillOpacity":
5354
case "strokeOpacity":
5455
case "opacity":
5556
channel.scale = scale !== true && isEvery(value, isOpacity) ? null : "opacity";
57+
channel.defaultScale = "opacity";
5658
break;
5759
case "symbol":
5860
if (scale !== true && isEvery(value, isSymbol)) {
@@ -61,6 +63,7 @@ export function inferChannelScale(name, channel) {
6163
} else {
6264
channel.scale = "symbol";
6365
}
66+
channel.defaultScale = "symbol";
6467
break;
6568
default:
6669
channel.scale = registry.has(name) ? name : null;

src/legends.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function legendOptions({className, ...context}, {label, ticks, tickFormat} = {},
4545

4646
function legendColor(color, {legend = true, ...options}) {
4747
if (legend === true) legend = color.type === "ordinal" ? "swatches" : "ramp";
48-
if (color.domain === undefined) return;
48+
if (color.domain === undefined) return; // no identity legend
4949
switch (`${legend}`.toLowerCase()) {
5050
case "swatches":
5151
return legendSwatches(color, options);

src/marks/tip.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,11 @@ function getSourceChannels(channels, scales) {
345345
for (const key in channels) {
346346
if (key in sources || key in format || ignoreChannels.has(key)) continue;
347347
const source = getSource(channels, key);
348-
if (source) sources[key] = source;
348+
if (source) {
349+
// Ignore color channels if the values are all literal colors.
350+
if (source.scale == null && source.defaultScale === "color") continue;
351+
sources[key] = source;
352+
}
349353
}
350354

351355
// And lastly facet channels, but only if this mark is faceted.

0 commit comments

Comments
 (0)