Skip to content
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

tip ignores literal colors #2091

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/legends.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion src/marks/tip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading