From c1aab3b26dc4dc4a276941ce8177c439b2256b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Sat, 19 Oct 2024 18:05:42 +0200 Subject: [PATCH 1/4] waffle href --- src/marks/waffle.js | 3 +- test/output/waffleHref.svg | 423 +++++++++++++++++++++++++++++++++++++ test/plots/waffle.ts | 17 ++ 3 files changed, 442 insertions(+), 1 deletion(-) create mode 100644 test/output/waffleHref.svg diff --git a/src/marks/waffle.js b/src/marks/waffle.js index c9d8771d21..c7ced9c36f 100644 --- a/src/marks/waffle.js +++ b/src/marks/waffle.js @@ -34,8 +34,8 @@ export class WaffleY extends BarY { } function waffleRender(y) { - return function (index, scales, values, dimensions, context) { const {unit, gap, rx, ry, round} = this; + return function (index, scales, {href, ...values}, dimensions, context) { const {document} = context; const Y1 = values.channels[`${y}1`].value; const Y2 = values.channels[`${y}2`].value; @@ -104,6 +104,7 @@ function waffleRender(y) { ) .attr("fill", (i) => `url(#${patternId}-${i})`) .attr("stroke", this.stroke == null ? null : (i) => `url(#${patternId}-${i})`) + .call(applyChannelStyles, this, {href}) ) .node(); }; diff --git a/test/output/waffleHref.svg b/test/output/waffleHref.svg new file mode 100644 index 0000000000..0117ade5f9 --- /dev/null +++ b/test/output/waffleHref.svg @@ -0,0 +1,423 @@ + + + + + 0 + 10 + 20 + 30 + 40 + 50 + 60 + 70 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plots/waffle.ts b/test/plots/waffle.ts index 455efd3a4a..933619b9fc 100644 --- a/test/plots/waffle.ts +++ b/test/plots/waffle.ts @@ -246,3 +246,20 @@ export async function waffleYGrouped() { marks: [Plot.waffleY(athletes, Plot.groupX({y: "count"}, {x: "sport", unit: 10})), Plot.ruleY([0])] }); } + +export function waffleHref() { + return Plot.plot({ + inset: 10, + marks: [ + Plot.waffleY( + {length: 77}, + { + y: 1, + fill: (d, i) => i % 7, + href: (d, i) => `/?${i}`, + target: "_blank" + } + ) + ] + }); +} From 00ae5ec825698985d30fb0e3f7de067972cfd144 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Sat, 19 Oct 2024 09:58:56 -0700 Subject: [PATCH 2/4] fix syntax --- src/marks/waffle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/marks/waffle.js b/src/marks/waffle.js index c7ced9c36f..2baaa0477b 100644 --- a/src/marks/waffle.js +++ b/src/marks/waffle.js @@ -34,8 +34,8 @@ export class WaffleY extends BarY { } function waffleRender(y) { - const {unit, gap, rx, ry, round} = this; return function (index, scales, {href, ...values}, dimensions, context) { + const {unit, gap, rx, ry, round} = this; const {document} = context; const Y1 = values.channels[`${y}1`].value; const Y2 = values.channels[`${y}2`].value; From 482f14cd22dd3a9c312c92308ddaa20e7a6196bf Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Sat, 19 Oct 2024 10:08:58 -0700 Subject: [PATCH 3/4] ariaLabel, href; fix test --- src/marks/waffle.js | 7 +- test/output/waffleHref.svg | 154 ++++++++++++++++++------------------- 2 files changed, 81 insertions(+), 80 deletions(-) diff --git a/src/marks/waffle.js b/src/marks/waffle.js index 2baaa0477b..883a4a1b14 100644 --- a/src/marks/waffle.js +++ b/src/marks/waffle.js @@ -34,7 +34,8 @@ export class WaffleY extends BarY { } function waffleRender(y) { - return function (index, scales, {href, ...values}, dimensions, context) { + return function (index, scales, values, dimensions, context) { + const {ariaLabel, href, title, ...visualValues} = values; const {unit, gap, rx, ry, round} = this; const {document} = context; const Y1 = values.channels[`${y}1`].value; @@ -86,7 +87,7 @@ function waffleRender(y) { .attr("id", (i) => `${patternId}-${i}`) .select("rect") .call(applyDirectStyles, this) - .call(applyChannelStyles, this, values) + .call(applyChannelStyles, this, visualValues) ) .call((g) => g @@ -104,7 +105,7 @@ function waffleRender(y) { ) .attr("fill", (i) => `url(#${patternId}-${i})`) .attr("stroke", this.stroke == null ? null : (i) => `url(#${patternId}-${i})`) - .call(applyChannelStyles, this, {href}) + .call(applyChannelStyles, this, {ariaLabel, href, title}) ) .node(); }; diff --git a/test/output/waffleHref.svg b/test/output/waffleHref.svg index 0117ade5f9..77b4734b75 100644 --- a/test/output/waffleHref.svg +++ b/test/output/waffleHref.svg @@ -265,159 +265,159 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + \ No newline at end of file From 54515cd2f19162cd86cce21241b5db24a5c7f81b Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Sat, 19 Oct 2024 10:11:44 -0700 Subject: [PATCH 4/4] test title, too --- test/output/waffleHref.svg | 154 ++++++++++++++++++------------------- test/plots/waffle.ts | 1 + 2 files changed, 78 insertions(+), 77 deletions(-) diff --git a/test/output/waffleHref.svg b/test/output/waffleHref.svg index 77b4734b75..b8b5e3ad46 100644 --- a/test/output/waffleHref.svg +++ b/test/output/waffleHref.svg @@ -265,159 +265,159 @@ - + waffle 0 - + waffle 1 - + waffle 2 - + waffle 3 - + waffle 4 - + waffle 5 - + waffle 6 - + waffle 7 - + waffle 8 - + waffle 9 - + waffle 10 - + waffle 11 - + waffle 12 - + waffle 13 - + waffle 14 - + waffle 15 - + waffle 16 - + waffle 17 - + waffle 18 - + waffle 19 - + waffle 20 - + waffle 21 - + waffle 22 - + waffle 23 - + waffle 24 - + waffle 25 - + waffle 26 - + waffle 27 - + waffle 28 - + waffle 29 - + waffle 30 - + waffle 31 - + waffle 32 - + waffle 33 - + waffle 34 - + waffle 35 - + waffle 36 - + waffle 37 - + waffle 38 - + waffle 39 - + waffle 40 - + waffle 41 - + waffle 42 - + waffle 43 - + waffle 44 - + waffle 45 - + waffle 46 - + waffle 47 - + waffle 48 - + waffle 49 - + waffle 50 - + waffle 51 - + waffle 52 - + waffle 53 - + waffle 54 - + waffle 55 - + waffle 56 - + waffle 57 - + waffle 58 - + waffle 59 - + waffle 60 - + waffle 61 - + waffle 62 - + waffle 63 - + waffle 64 - + waffle 65 - + waffle 66 - + waffle 67 - + waffle 68 - + waffle 69 - + waffle 70 - + waffle 71 - + waffle 72 - + waffle 73 - + waffle 74 - + waffle 75 - + waffle 76 \ No newline at end of file diff --git a/test/plots/waffle.ts b/test/plots/waffle.ts index 933619b9fc..fdfa98a025 100644 --- a/test/plots/waffle.ts +++ b/test/plots/waffle.ts @@ -257,6 +257,7 @@ export function waffleHref() { y: 1, fill: (d, i) => i % 7, href: (d, i) => `/?${i}`, + title: (d, i) => `waffle ${i}`, target: "_blank" } )