INNER CODE UNIT · TypeScript
imports
f5/unovis · packages/mcp/src/codegen/index.ts:228
const imports = ['Axis', containerName(spec), ...components.map(c => c.type), ...emit.enumImports]
.filter((name, i, all) => all.indexOf(name) === i && (name !== 'Axis' || xAxis || yAxis))
.sort()
const legend = spec.legend?.length
? `\n// Legend (renders into its own element)\nconst legend = new BulletLegend(document.getElementById('legend') as HTMLElement, {\n items: ${json(spec.legend.map(item => ({ name: item.name })))},\n})\n`
: ''
if (spec.legend?.length) imports.push('BulletLegend')
const content = `import { ${imports.sort().join(', ')} } from '@unovis/ts'
${preamble(emit, `const data = ${dataLiteralFor(spec.data)}\n\ntype DataRecord = typeof data[number]`)}
${componentVars.map(c => c.code).join('\n\n')}
const container = document.getElementById('chart') as HTMLElement
const chart = new ${containerName(spec)}<DataRecord>(container, {
${containerProps.map(p => ` ${p},`).join('\n')}