import fs from 'node:fs'; import { renderChart, chartToPng, chartTable } from '../src/tools/artifacts/chart.js'; const out = 'C:/Users/HP/AppData/Local/Temp/claude/c--Users-HP-Desktop-Dev-Agentic-AI/8b30e040-7edd-46bd-97f0-c9d03d3965cf/scratchpad'; fs.mkdirSync(out, { recursive: true }); const specs = { bar: { type: 'bar', title: 'Leads by stage', subtitle: 'Last 90 days · live CRM data', data: [ { label: 'new_lead', value: 3417 }, { label: 'contacted', value: 500 }, { label: 'lost', value: 282 }, { label: 'qualified', value: 59 }, { label: 'demo', value: 4 }, { label: 'converted', value: 4 }, ], }, barMulti: { type: 'bar', title: 'Leads vs enrolments by source', subtitle: 'Grouped, two series', series: [ { name: 'Leads', data: [{ label: 'ad_campaign', value: 2833 }, { label: 'website', value: 316 }, { label: 'organic', value: 140 }, { label: 'linkedin', value: 62 }] }, { name: 'Enrolments', data: [{ label: 'ad_campaign', value: 0 }, { label: 'website', value: 1 }, { label: 'organic', value: 3 }, { label: 'linkedin', value: 2 }] }, ], }, hbar: { type: 'hbar', title: 'Top batches by paid enrolments', format: 'number', data: [ { label: 'AI Basics for Manufacturing', value: 59 }, { label: 'AI Quality Inspection', value: 31 }, { label: 'Build Your First AI Agent in 60 Minutes (Live)', value: 31 }, { label: 'AI for IoT & Sensors', value: 14 }, { label: 'Digital Marketing Mastery', value: 12 }, ], }, line: { type: 'line', title: 'Lead volume trend', subtitle: 'Weekly buckets', series: [ { name: 'New leads', data: [{ label: 'W30', value: 65 }, { label: 'W31', value: 243 }, { label: 'W32', value: 310 }, { label: 'W33', value: 288 }, { label: 'W34', value: 251 }] }, { name: 'Contacted', data: [{ label: 'W30', value: 20 }, { label: 'W31', value: 88 }, { label: 'W32', value: 140 }, { label: 'W33', value: 96 }, { label: 'W34', value: 74 }] }, ], }, donut: { type: 'donut', title: 'Payment attempts by status', center_label: 'attempts', data: [{ label: 'CANCELLED', value: 206 }, { label: 'SUCCESS', value: 39 }, { label: 'FAILED', value: 5 }, { label: 'ERROR', value: 3 }], }, pieMany: { type: 'pie', title: 'Slice cap check (6 → 3 + Other)', data: [{ label: 'A', value: 40 }, { label: 'B', value: 25 }, { label: 'C', value: 15 }, { label: 'D', value: 10 }, { label: 'E', value: 6 }, { label: 'F', value: 4 }], }, currency: { type: 'hbar', title: 'Abandoned checkout value by batch', format: 'currency', data: [{ label: 'AI Basics for Manufacturing', value: 363817 }, { label: 'Applied AI 4-Week', value: 128400 }, { label: 'AI Quality Inspection', value: 64200 }], }, }; const cards = []; for (const [name, spec] of Object.entries(specs)) { const svg = renderChart(spec, 'auto'); fs.writeFileSync(`${out}/chart-${name}.svg`, svg); const png = await chartToPng(spec, 1.5); fs.writeFileSync(`${out}/chart-${name}.png`, png); cards.push(`
${name}
${svg}
`); console.log(`${name.padEnd(10)} svg ${String(svg.length).padStart(6)}b png ${String(png.length).padStart(7)}b tableCols=${chartTable(spec).columns.length}`); } fs.writeFileSync(`${out}/charts.html`, `${cards.join('')}`); console.log('\nwrote preview:', `${out}/charts.html`); process.exit(0);