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.
Files changed (2) hide show
  1. package/cli.js +16 -12
  2. 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: 100, right: 50, bottom: 60, left: 50 }
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 = `-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif`
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 = 130
248
- const legendStartX = W - pad.right - visible.length * legendItemW
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="${y - 8}" width="10" height="10" rx="2" fill="${visible[i].color}" opacity="0.8"/>`
255
- legend += `<text x="${x + 16}" y="${y + 1}" fill="#8b949e" font-family="${font}" font-size="14">${visible[i].name}</text>`
256
- legend += `<text x="${x + 16}" y="${y + 16}" fill="#8b949e" font-family="${font}" font-size="13">${formatTotal(count)}</text>\n`
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.left + 8}" y="${pad.top - 40}" fill="#f0f6fc" font-family="${font}" font-size="42" font-weight="800">${formatTotal(total)}</text>
267
- <text x="${pad.left + 8}" y="${pad.top - 16}" fill="#484f58" font-family="${font}" font-size="14" letter-spacing="1.5" font-weight="600">TOKENS</text>
268
- <rect x="${(pad.left + 200 + legendStartX) / 2 - 125}" y="30" width="250" height="30" rx="6" fill="#161b22"/>
269
- <text x="${(pad.left + 200 + legendStartX) / 2}" y="50" text-anchor="middle" fill="#8b949e" font-family="'SF Mono', 'Fira Code', monospace" font-size="15">npx clanker-stats --share</text>
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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clanker-stats",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "See how many tokens you've burned across AI coding tools",
5
5
  "type": "module",
6
6
  "bin": {