clanker-stats 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +16 -12
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -163,10 +163,11 @@ function formatTotal(n) {
|
|
|
163
163
|
|
|
164
164
|
function renderChart(allDays, results, total) {
|
|
165
165
|
const W = 1500, H = 560
|
|
166
|
-
const pad = { top:
|
|
166
|
+
const pad = { top: 130, right: 50, bottom: 60, left: 50 }
|
|
167
167
|
const chartW = W - pad.left - pad.right
|
|
168
168
|
const chartH = H - pad.top - pad.bottom
|
|
169
|
-
const font =
|
|
169
|
+
const font = `'Berkeley Mono', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif`
|
|
170
|
+
const mono = `'Berkeley Mono', 'SF Mono', 'Fira Code', monospace`
|
|
170
171
|
|
|
171
172
|
const numWeeks = Math.ceil(allDays.length / 7)
|
|
172
173
|
const toolWeekly = results.map(r => {
|
|
@@ -244,16 +245,19 @@ function renderChart(allDays, results, total) {
|
|
|
244
245
|
}
|
|
245
246
|
|
|
246
247
|
const visible = results.filter(r => [...r.counts.values()].reduce((a, b) => a + b, 0) > 0)
|
|
247
|
-
const legendItemW =
|
|
248
|
-
const legendStartX =
|
|
248
|
+
const legendItemW = 145
|
|
249
|
+
const legendStartX = pad.left + 8
|
|
250
|
+
const legendEndX = legendStartX + visible.length * legendItemW
|
|
251
|
+
const totalStartX = W - pad.right - 160
|
|
252
|
+
const midX = (legendEndX + totalStartX) / 2 - 30
|
|
253
|
+
const vcenter = pad.top / 2
|
|
249
254
|
let legend = ""
|
|
250
255
|
for (let i = 0; i < visible.length; i++) {
|
|
251
256
|
const x = legendStartX + i * legendItemW
|
|
252
|
-
const y = 38
|
|
253
257
|
const count = [...visible[i].counts.values()].reduce((a, b) => a + b, 0)
|
|
254
|
-
legend += `<rect x="${x}" y="${
|
|
255
|
-
legend += `<text x="${x +
|
|
256
|
-
legend += `<text x="${x +
|
|
258
|
+
legend += `<rect x="${x}" y="${vcenter - 14}" width="14" height="14" rx="3" fill="${visible[i].color}" opacity="0.8"/>`
|
|
259
|
+
legend += `<text x="${x + 20}" y="${vcenter}" fill="#8b949e" font-family="${font}" font-size="18">${visible[i].name}</text>`
|
|
260
|
+
legend += `<text x="${x + 20}" y="${vcenter + 20}" fill="#8b949e" font-family="${font}" font-size="17">${formatTotal(count)}</text>\n`
|
|
257
261
|
}
|
|
258
262
|
|
|
259
263
|
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
@@ -263,10 +267,10 @@ function renderChart(allDays, results, total) {
|
|
|
263
267
|
</clipPath>
|
|
264
268
|
</defs>
|
|
265
269
|
<rect width="${W}" height="${H}" rx="16" fill="#0d1117" stroke="#30363d" stroke-width="1"/>
|
|
266
|
-
<text x="${pad.
|
|
267
|
-
<text x="${pad.
|
|
268
|
-
<rect x="${
|
|
269
|
-
<text x="${
|
|
270
|
+
<text x="${W - pad.right}" y="${vcenter + 6}" text-anchor="end" fill="#f0f6fc" font-family="${font}" font-size="48" font-weight="800">${formatTotal(total)}</text>
|
|
271
|
+
<text x="${W - pad.right}" y="${vcenter + 26}" text-anchor="end" fill="#484f58" font-family="${font}" font-size="16" letter-spacing="2" font-weight="600">TOKENS</text>
|
|
272
|
+
<rect x="${midX - 170}" y="${vcenter - 20}" width="340" height="40" rx="8" fill="#161b22"/>
|
|
273
|
+
<text x="${midX}" y="${vcenter + 5}" text-anchor="middle" fill="#8b949e" font-family="${mono}" font-size="22">npx clanker-stats --share</text>
|
|
270
274
|
${legend}
|
|
271
275
|
${gridLines}
|
|
272
276
|
${areas}
|