diff --git a/src/channel.js b/src/channel.js
index 4fb46c3448..567143f032 100644
--- a/src/channel.js
+++ b/src/channel.js
@@ -48,11 +48,13 @@ export function inferChannelScale(name, channel) {
case "stroke":
case "color":
channel.scale = scale !== true && isEvery(value, isColor) ? null : "color";
+ channel.defaultScale = "color";
break;
case "fillOpacity":
case "strokeOpacity":
case "opacity":
channel.scale = scale !== true && isEvery(value, isOpacity) ? null : "opacity";
+ channel.defaultScale = "opacity";
break;
case "symbol":
if (scale !== true && isEvery(value, isSymbol)) {
@@ -61,6 +63,7 @@ export function inferChannelScale(name, channel) {
} else {
channel.scale = "symbol";
}
+ channel.defaultScale = "symbol";
break;
default:
channel.scale = registry.has(name) ? name : null;
diff --git a/src/legends.js b/src/legends.js
index 677bc043ee..64215ebaf3 100644
--- a/src/legends.js
+++ b/src/legends.js
@@ -45,7 +45,7 @@ function legendOptions({className, ...context}, {label, ticks, tickFormat} = {},
function legendColor(color, {legend = true, ...options}) {
if (legend === true) legend = color.type === "ordinal" ? "swatches" : "ramp";
- if (color.domain === undefined) return;
+ if (color.domain === undefined) return; // no identity legend
switch (`${legend}`.toLowerCase()) {
case "swatches":
return legendSwatches(color, options);
diff --git a/src/marks/tip.js b/src/marks/tip.js
index d741b8e103..a29d11d619 100644
--- a/src/marks/tip.js
+++ b/src/marks/tip.js
@@ -345,7 +345,11 @@ function getSourceChannels(channels, scales) {
for (const key in channels) {
if (key in sources || key in format || ignoreChannels.has(key)) continue;
const source = getSource(channels, key);
- if (source) sources[key] = source;
+ if (source) {
+ // Ignore color channels if the values are all literal colors.
+ if (source.scale == null && source.defaultScale === "color") continue;
+ sources[key] = source;
+ }
}
// And lastly facet channels, but only if this mark is faceted.
diff --git a/test/output/tipColorLiteral.svg b/test/output/tipColorLiteral.svg
new file mode 100644
index 0000000000..36cc8ee6ad
--- /dev/null
+++ b/test/output/tipColorLiteral.svg
@@ -0,0 +1,418 @@
+
\ No newline at end of file
diff --git a/test/plots/tip.ts b/test/plots/tip.ts
index 4cecf671d3..6c827e7b85 100644
--- a/test/plots/tip.ts
+++ b/test/plots/tip.ts
@@ -265,3 +265,18 @@ export async function tipFacetX() {
]
});
}
+
+export async function tipColorLiteral() {
+ const penguins = await d3.csv("data/penguins.csv", d3.autoType);
+ return Plot.plot({
+ grid: true,
+ marks: [
+ Plot.dot(penguins, {
+ x: "culmen_length_mm",
+ y: "culmen_depth_mm",
+ fill: (d) => (d.species === "Adelie" ? "orange" : "steelblue"),
+ tip: true
+ })
+ ]
+ });
+}