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

fix symbol set hint when fill is a constant currentColor #1830

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion src/marks/dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ export class Dot extends Mark {
if (symbolChannel) {
const {fill: fillChannel, stroke: strokeChannel} = channels;
symbolChannel.hint = {
fill: fillChannel ? (fillChannel.value === symbolChannel.value ? "color" : "currentColor") : this.fill,
fill: fillChannel
? fillChannel.value === symbolChannel.value
? "color"
: "currentColor"
: this.fill ?? options.fill,
stroke: strokeChannel ? (strokeChannel.value === symbolChannel.value ? "color" : "currentColor") : this.stroke
};
}
Expand Down
43 changes: 43 additions & 0 deletions test/output/symbolSetFill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions test/output/symbolSetStroke.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/plots/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export * from "./stargazers-hourly-group.js";
export * from "./stargazers-hourly.js";
export * from "./stargazers.js";
export * from "./stocks-index.js";
export * from "./symbol-sets.js";
export * from "./text-overflow.js";
export * from "./this-is-just-to-say.js";
export * from "./time-axis.js";
Expand Down
15 changes: 15 additions & 0 deletions test/plots/symbol-sets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as Plot from "@observablehq/plot";

export async function symbolSetFill() {
return Plot.dotX(["circle", "cross", "diamond", "square", "star", "triangle", "wye"], {
fill: "currentColor",
symbol: (d, i) => i
}).plot();
}

export async function symbolSetStroke() {
return Plot.dotX(["circle", "cross", "diamond", "square", "star", "triangle", "wye"], {
stroke: "currentColor",
symbol: (d, i) => i
}).plot();
}