Skip to content

Commit 27e8fff

Browse files
Filmbostock
andauthoredOct 19, 2024··
waffle href (#2203)
* waffle href * fix syntax * ariaLabel, href; fix test * test title, too --------- Co-authored-by: Mike Bostock <[email protected]>
1 parent 07cab1e commit 27e8fff

File tree

3 files changed

+444
-1
lines changed

3 files changed

+444
-1
lines changed
 

‎src/marks/waffle.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class WaffleY extends BarY {
3535

3636
function waffleRender(y) {
3737
return function (index, scales, values, dimensions, context) {
38+
const {ariaLabel, href, title, ...visualValues} = values;
3839
const {unit, gap, rx, ry, round} = this;
3940
const {document} = context;
4041
const Y1 = values.channels[`${y}1`].value;
@@ -86,7 +87,7 @@ function waffleRender(y) {
8687
.attr("id", (i) => `${patternId}-${i}`)
8788
.select("rect")
8889
.call(applyDirectStyles, this)
89-
.call(applyChannelStyles, this, values)
90+
.call(applyChannelStyles, this, visualValues)
9091
)
9192
.call((g) =>
9293
g
@@ -104,6 +105,7 @@ function waffleRender(y) {
104105
)
105106
.attr("fill", (i) => `url(#${patternId}-${i})`)
106107
.attr("stroke", this.stroke == null ? null : (i) => `url(#${patternId}-${i})`)
108+
.call(applyChannelStyles, this, {ariaLabel, href, title})
107109
)
108110
.node();
109111
};

‎test/output/waffleHref.svg

Lines changed: 423 additions & 0 deletions
Loading

‎test/plots/waffle.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,21 @@ export async function waffleYGrouped() {
246246
marks: [Plot.waffleY(athletes, Plot.groupX({y: "count"}, {x: "sport", unit: 10})), Plot.ruleY([0])]
247247
});
248248
}
249+
250+
export function waffleHref() {
251+
return Plot.plot({
252+
inset: 10,
253+
marks: [
254+
Plot.waffleY(
255+
{length: 77},
256+
{
257+
y: 1,
258+
fill: (d, i) => i % 7,
259+
href: (d, i) => `/?${i}`,
260+
title: (d, i) => `waffle ${i}`,
261+
target: "_blank"
262+
}
263+
)
264+
]
265+
});
266+
}

0 commit comments

Comments
 (0)
Please sign in to comment.