Frame and legend

Chart.Frame and Chart.Legend are available from the web entry point.

tsx
import { Chart, zyplot } from '@hzblj/zyplot/web'

const legend = [
  { id: 'revenue', label: 'Revenue', color: '#6d28d9' },
  { id: 'costs', label: 'Costs', color: '#0284c7' },
]

const chart = zyplot(z => ({
  categories: ['Jan', 'Feb', 'Mar'],
  series: [
    z.series({ id: 'revenue', label: 'Revenue', values: [42, 56, 72] }),
    z.series({ id: 'costs', label: 'Costs', values: [28, 34, 41] }),
  ],
}))

export function RevenueCard() {
  return (
    <Chart.Frame title="Revenue" description="Last 6 months" caption="Updated today">
      <Chart.Line {...chart} />
      <Chart.Legend items={legend} />
    </Chart.Frame>
  )
}

Frame props

NameTypeDefaultDescription
titlestring—Main heading.
descriptionstring—Text below the heading.
actionsReactNode—Controls placed in the header.
captionstring—Small text below the chart.
children*ReactNode—Chart and optional legend.

Legend props

NameTypeDefaultDescription
items*ChartLegendItem[]—Stable id, visible label, and color for each item.
classNamestring—CSS class on the list.