Skip to content

Commit 5c5dfe5

Browse files
committed
feat(killer): switch demo chart to multi-point bars and refresh gif
1 parent 50e4a3b commit 5c5dfe5

3 files changed

Lines changed: 39 additions & 23 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ pnpm playground
253253
Then open the playground page and run this prompt:
254254

255255
```text
256-
Build an analytics dashboard with a LineChart from recharts and KPI toggle buttons
256+
Build an analytics dashboard with KPI toggle buttons and a multi-point bar chart
257257
```
258258

259259
The playground now uses streaming prompt rendering (`/api/prompt-stream`), so you'll see incremental preview updates before final UI completion.
-71 KB
Loading

examples/killer/one-line-chat-dashboard.html

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ <h1 class="headline">One-Line Embed: AI Chat Dashboard</h1>
104104
<div class="layout">
105105
<section class="panel">
106106
<div class="chat-bubble">
107-
User: Build an analytics dashboard with KPI toggles and chart.
107+
User: Build an analytics dashboard with KPI toggles and a multi-point bar chart.
108108
</div>
109109
<div class="chat-bubble">
110110
Assistant emitted RuntimePlan + TSX source. Render immediately.
@@ -177,18 +177,28 @@ <h1 class="headline">One-Line Embed: AI Chat Dashboard</h1>
177177
" { day: 'Wed', revenue: 148, users: 52 },",
178178
" { day: 'Thu', revenue: 222, users: 74 },",
179179
" { day: 'Fri', revenue: 261, users: 91 },",
180+
" { day: 'Sat', revenue: 238, users: 87 },",
181+
" { day: 'Sun', revenue: 312, users: 119 },",
182+
" { day: 'Mon+', revenue: 286, users: 102 },",
183+
" { day: 'Tue+', revenue: 334, users: 128 },",
180184
" ], []);",
181185
" const key = metric === 'revenue' ? 'revenue' : 'users';",
182-
" const width = 560;",
183-
" const height = 280;",
184-
" const pad = 28;",
186+
" const width = 620;",
187+
" const height = 310;",
188+
" const pad = 30;",
189+
" const chartHeight = height - pad * 2;",
190+
" const chartWidth = width - pad * 2;",
185191
" const max = Math.max(...data.map((entry) => entry[key]));",
186-
" const points = data.map((entry, index) => {",
187-
" const x = pad + (index * (width - pad * 2)) / Math.max(1, data.length - 1);",
188-
" const y = height - pad - (entry[key] / Math.max(1, max)) * (height - pad * 2);",
189-
" return { x, y, day: entry.day, value: entry[key] };",
192+
" const gap = 8;",
193+
" const barWidth = Math.max(10, chartWidth / data.length - gap);",
194+
" const bars = data.map((entry, index) => {",
195+
" const value = entry[key];",
196+
" const x = pad + index * (barWidth + gap);",
197+
" const barHeight = (value / Math.max(1, max)) * chartHeight;",
198+
" const y = height - pad - barHeight;",
199+
" return { x, y, barHeight, day: entry.day, value };",
190200
" });",
191-
" const polyline = points.map((point) => `${point.x},${point.y}`).join(' ');",
201+
" const axisTicks = 4;",
192202
" return (",
193203
" <section style={{ fontFamily: 'IBM Plex Sans, sans-serif' }}>",
194204
" <h2 style={{ margin: '0 0 6px' }}>Revenue Assistant Dashboard</h2>",
@@ -198,25 +208,31 @@ <h1 class="headline">One-Line Embed: AI Chat Dashboard</h1>
198208
" <button type='button' onClick={() => setMetric('users')}>Users</button>",
199209
" </div>",
200210
" <div style={{ overflowX: 'auto' }}>",
201-
" <svg width={width} height={height} viewBox={`0 0 ${width} ${height}`} role='img' aria-label='Metric chart'>",
211+
" <svg width={width} height={height} viewBox={`0 0 ${width} ${height}`} role='img' aria-label='Metric bar chart'>",
212+
" {Array.from({ length: axisTicks + 1 }).map((_, tickIndex) => {",
213+
" const y = pad + (tickIndex * chartHeight) / axisTicks;",
214+
" return <line key={`grid-${tickIndex}`} x1={pad} y1={y} x2={width - pad} y2={y} stroke='#e6edf7' strokeDasharray='4 4' />;",
215+
" })}",
202216
" <line x1={pad} y1={height - pad} x2={width - pad} y2={height - pad} stroke='#d1d8e6' />",
203217
" <line x1={pad} y1={pad} x2={pad} y2={height - pad} stroke='#d1d8e6' />",
204-
" <polyline",
205-
" fill='none'",
206-
" stroke={metric === 'revenue' ? '#0f766e' : '#1d4ed8'}",
207-
" strokeWidth={3}",
208-
" points={polyline}",
209-
" />",
210-
" {points.map((point) => (",
211-
" <g key={point.day}>",
212-
" <circle cx={point.x} cy={point.y} r={4} fill={metric === 'revenue' ? '#0f766e' : '#1d4ed8'} />",
213-
" <text x={point.x} y={height - 8} textAnchor='middle' fontSize='11' fill='#5c6f88'>{point.day}</text>",
214-
" <text x={point.x} y={point.y - 10} textAnchor='middle' fontSize='11' fill='#2a3f58'>{point.value}</text>",
218+
" {bars.map((bar) => (",
219+
" <g key={bar.day}>",
220+
" <rect",
221+
" x={bar.x}",
222+
" y={bar.y}",
223+
" width={barWidth}",
224+
" height={bar.barHeight}",
225+
" rx={6}",
226+
" fill={metric === 'revenue' ? '#0f766e' : '#1d4ed8'}",
227+
" opacity={0.9}",
228+
" />",
229+
" <text x={bar.x + barWidth / 2} y={height - 9} textAnchor='middle' fontSize='11' fill='#5c6f88'>{bar.day}</text>",
230+
" <text x={bar.x + barWidth / 2} y={Math.max(pad + 12, bar.y - 6)} textAnchor='middle' fontSize='11' fill='#2a3f58'>{bar.value}</text>",
215231
" </g>",
216232
" ))}",
217233
" </svg>",
218234
" </div>",
219-
" <p style={{ marginBottom: 0 }}>Current metric: <strong>{metric}</strong></p>",
235+
" <p style={{ marginBottom: 0 }}>Current metric: <strong>{metric}</strong> · Data points: <strong>{data.length}</strong></p>",
220236
" </section>",
221237
" );",
222238
"}",

0 commit comments

Comments
 (0)