Skip to content

Commit fd6cd37

Browse files
committed
adopt the new classes for plot's big numbers
1 parent 4c1a7e9 commit fd6cd37

File tree

3 files changed

+36
-53
lines changed

3 files changed

+36
-53
lines changed

examples/plot/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The [`npm-downloads.csv.ts`](./docs/data/npm-downloads.csv.ts) loader retrieves
2626

2727
## Big numbers
2828

29-
Key performance indicators are displayed as “big numbers” with, in some cases, a trend indicating growth over one week. See the components/bigNumber.js file.
29+
Key performance indicators are displayed as “big numbers” with, in some cases, a trend indicating growth over one week. Their layout is using the convenience CSS classes _big_, _red_ etc.
3030

3131
## Charts
3232

examples/plot/docs/components/bigNumber.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

examples/plot/docs/index.md

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ theme: dashboard
66
# Plot
77

88
```js
9-
import {BigNumber} from "./components/bigNumber.js";
109
import {DailyPlot, today, start} from "./components/dailyPlot.js";
1110
```
1211

@@ -43,17 +42,25 @@ const burndown = issues
4342
```
4443
4544
<div class="grid grid-cols-4" style="grid-auto-rows: 86px;">
46-
<div class=card>${BigNumber(versions.at(-1).version, {
47-
title: "Current release",
48-
href: `https://github.com/observablehq/plot/releases/tag/v${versions.at(-1).version}`,
49-
trend: d3.utcDay.count(versions.at(-1).date, Date.now()),
50-
trendFormat: d => `${d === 0 ? "today" : d===1 ? "yesterday" : `${d} days ago`}`,
51-
trendColor: "#888",
52-
trendArrow: null
53-
})}</div>
54-
<div class=card>${BigNumber(stars.length, {title: "GitHub stars", trend: stars.filter((d) => d.starred_at >= lastWeek).length, trendFormat: "+", trendTitle: "Since last week"})}</div>
55-
<div class=card>${BigNumber(downloads[0].value, {title: "Daily npm downloads", trend: downloads[7].value ? (downloads[0].value - downloads[7].value) / downloads[7].value : undefined, trendTitle: "Compared to last week"})}</div>
56-
<div class=card>${BigNumber(d3.sum(downloads, (d) => d.value), {title: "Total npm downloads"})}</div>
45+
<div class=card>
46+
<h2>Current release</h2>
47+
${html`<span class=big>${versions.at(-1).version}`}
48+
${html`<a href="https://github.com/observablehq/plot/releases/tag/v${versions.at(-1).version}">
49+
<span class=muted>${((days) => days === 0 ? "today" : days === 1 ? "yesterday" : `${days} days ago`)(d3.utcDay.count(versions.at(-1).date, Date.now()))}`}
50+
</div>
51+
<div class=card>
52+
<h2>GitHub stars</h2>
53+
${html`<span class=big>${d3.format(",")(stars.length)}`}
54+
${html`<span class=green>${d3.format("+")(d3.sum(stars, (d) => d.starred_at >= lastWeek))} ↗︎`}
55+
</div>
56+
<div class=card>
57+
<h2>Daily npm downloads</h2>
58+
${html`<span class=big>${d3.format(",")(downloads[0].value)}`}
59+
${((trend) => html`<span class=${trend > 0 ? "green" : trend < 0 ? "red" : "muted"}>${d3.format("+.1%")(trend)} ${trend > 0 ? "↗︎" : trend < 0 ? "↘︎" :""}`)(downloads[7].value ? (downloads[0].value - downloads[7].value) / downloads[7].value : undefined)}
60+
</div>
61+
<div class=card>
62+
<h2>Total npm downloads</h2>
63+
${html`<span class=big>${d3.format(",")(d3.sum(downloads, (d) => d.value))}`}
5764
</div>
5865
5966
<div class="card grid grid-cols-1" style="grid-auto-rows: calc(260px + 2rem);">
@@ -100,10 +107,22 @@ const burndown = issues
100107
</div>
101108
102109
<div class="grid grid-cols-4" style="grid-auto-rows: 86px;">
103-
<div class=card>${BigNumber(issues.filter((d) => !d.pull_request && d.state === "open").length, {title: "Open issues", href: "https://github.com/observablehq/plot/issues"})}</div>
104-
<div class=card>${BigNumber(issues.filter((d) => !d.pull_request && d.open >= lastMonth).length, {title: "Opened issues, 28d"})}</div>
105-
<div class=card>${BigNumber(issues.filter((d) => !d.pull_request && d.close >= lastMonth).length, {title: "Closed issues, 28d"})}</div>
106-
<div class=card>${BigNumber(issues.filter((d) => d.pull_request && d.state === "open" && !d.draft).length, {title: "Open PRs", href: "https://github.com/observablehq/plot/pulls?q=is%3Apr+is%3Aopen+draft%3Afalse"})}</div>
110+
<div class=card>
111+
<h2>Open issues</h2>
112+
<span class=big>${d3.format(",")(d3.sum(issues, (d) => !d.pull_request && d.state === "open"))}</span>
113+
</div>
114+
<div class=card>
115+
<h2>Opened issues, 28d</h2>
116+
<span class=big>${d3.format(",")(d3.sum(issues, (d) => !d.pull_request && d.open >= lastMonth))}</span>
117+
</div>
118+
<div class=card>
119+
<h2>Closed issues, 28d</h2>
120+
<span class=big>${d3.format(",")(d3.sum(issues, (d) => !d.pull_request && d.close >= lastMonth))}</span>
121+
</div>
122+
<div class=card>
123+
<h2>Open PRs</h2>
124+
<a class=big href="https://github.com/observablehq/plot/pulls?q=is%3Apr+is%3Aopen+draft%3Afalse"><span class=muted>${d3.format(",")(d3.sum(issues, (d) => d.pull_request && d.state === "open" && !d.draft))}</span></a>
125+
</div>
107126
</div>
108127
109128
<div class="grid grid-cols-2" style="grid-auto-rows: 276px;">

0 commit comments

Comments
 (0)