Skip to content

Variable: ChartSchema

const ChartSchema: ZodObject<{ chartId: ZodString; error: ZodOptional<ZodString>; result: ZodOptional<ZodObject<{ chartType: ZodUnion<readonly [ZodLiteral<"bar">, ZodLiteral<"horizontalBar">, ZodLiteral<"line">, ZodLiteral<"area">, ZodLiteral<"combo">, ZodLiteral<"waterfall">, ZodLiteral<"scatter">, ZodLiteral<"heatmap">, ZodLiteral<"radar">, ZodLiteral<"pie">, ZodLiteral<"funnel">, ZodLiteral<"treemap">, ZodLiteral<"custom">]>; option: ZodRecord<ZodString, ZodUnknown>; }, $strip>>; }, $strip>

Wire-format AND server-side cache shape for a chart entry. Three lifecycle states inferred from the two optional fields (no discriminator needed):

  • result set -> chart is ready to render
  • error set -> planner / data fetch failed
  • both result and error unset -> still processing

option is typed as a generic record so this package stays dependency-free of echarts. The server (chart.ts) imports this schema directly; the demo client polls the /embed/chart/:id route and parses responses against it.

  • chartId: Opaque id minted by the chart subsystem. Embed verbatim as [chart:<chartId>] in agent prose; the host UI resolves it against this cache entry.
  • error (optional): Error message when the chart failed (data fetch error, planner error, empty dataset). Mutually exclusive with result; absent on success and while processing.
  • result (optional): Resolved chart plan. Absent while processing and when the run errored.
  • result.chartType: The chart shape that best matches the data and intent.
  • result.option: Fully-resolved Echarts EChartsOption JSON for this chart - drop directly into an Echarts instance (or <ReactECharts option={...} />) without further processing. Includes title / tooltip / legend / grid / axis / series defaults already merged in.