Skip to content

Commit

Permalink
fix crash with fill: true
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Jan 18, 2022
1 parent 8515c48 commit fcdad98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/marks/dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export class Dot extends Mark {
const fillChannel = channels.find(({name}) => name === "fill");
const strokeChannel = channels.find(({name}) => name === "stroke");
symbolChannel.hint = {
fill: fillChannel ? (fillChannel.value === symbolChannel.value ? "color" : true) : this.fill,
stroke: strokeChannel ? (strokeChannel.value === symbolChannel.value ? "color" : true) : this.stroke
fill: fillChannel ? (fillChannel.value === symbolChannel.value ? "color" : "currentColor") : this.fill,
stroke: strokeChannel ? (strokeChannel.value === symbolChannel.value ? "color" : "currentColor") : this.stroke
};
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/plots/legend-symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export function symbolLegendColorStroke() {
return Plot.plot({color: {domain: "ABCDEF"}, symbol: {domain: "ABCDEF"}}).legend("symbol", {stroke: "color"});
}

// Note: The symbol hint requires reference equality for channel definitions,
// and so doesn’t consider the fill and symbol channels to be using the same
// encoding here.
export function symbolLegendDifferentColor() {
return Plot.dotX("ABCDEF", {fill: d => d, symbol: d => d}).plot().legend("symbol");
}

// TODO It would be nice if the symbol hint could apply here; but the hint is
// currently only set by marks that have matching channels.
export function symbolLegendFill() {
Expand Down

0 comments on commit fcdad98

Please sign in to comment.