Skip to content

Commit 1970db9

Browse files
committed
chess halo
1 parent 1409349 commit 1970db9

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

examples/chess/docs/index.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ import {revive} from "./components/revive.js";
1111
const {womens, mens, MONTHS_OF_DATA, TOP_N_COUNT} = await FileAttachment("data/top-ranked-players.json").json().then(revive);
1212
```
1313

14-
```js
15-
function formatTitle(title) {
16-
return title === "GM" ? "Grand Master" : title;
17-
}
18-
```
19-
2014
```js
2115
function bumpChart(data, {x = "month", y = "rating", z = "name", interval = "month", width} = {}) {
2216
const rank = Plot.stackY2({x, z, order: y, reverse: true});
@@ -43,8 +37,8 @@ function bumpChart(data, {x = "month", y = "rating", z = "name", interval = "mon
4337
strokeWidth: 24,
4438
curve: "bump-x",
4539
sort: {color: "y", reduce: "first"},
46-
mixBlendMode: dark ? "lighten" : "darken",
47-
interval
40+
interval,
41+
render: halo({stroke: "var(--theme-background-alt)", strokeWidth: 27})
4842
})),
4943
Plot.text(data, {
5044
...rank,
@@ -71,6 +65,23 @@ function bumpChart(data, {x = "month", y = "rating", z = "name", interval = "mon
7165
]
7266
})
7367
}
68+
69+
function halo({stroke = "currentColor", strokeWidth = 3} = {}) {
70+
return (index, scales, values, dimensions, context, next) => {
71+
const g = next(index, scales, values, dimensions, context);
72+
for (const path of [...g.childNodes]) {
73+
const clone = path.cloneNode(true);
74+
clone.setAttribute("stroke", stroke);
75+
clone.setAttribute("stroke-width", strokeWidth);
76+
path.parentNode.insertBefore(clone, path);
77+
}
78+
return g;
79+
};
80+
}
81+
82+
function formatTitle(title) {
83+
return title === "GM" ? "Grand Master" : title;
84+
}
7485
```
7586

7687
<div class="grid">

0 commit comments

Comments
 (0)