supportChartOption
Presentation normalizer for planner-produced Echarts specs.
The chart planner (@dbx-tools/appkit-mastra) emits a JSON-safe
EChartsOption that travels through the cache and over the wire, so
it can’t carry function-valued formatters or make width-dependent
layout choices. This module patches those presentation concerns back
in at render time - identically for the live inline chart
(embed-slots) and the print/PDF export (export.ts) - so both read
the same way:
- large value-axis ticks render compact (
800M, not800,000,000); - value/category axis names sit in conventional positions (rotated
on the left for
y, centered below forx) instead of floating at the axis ends where they collide with the centered title; - category labels stay legible (shown, rotated, de-overlapped) rather than silently decimated when many bars share a narrow canvas;
- the title and grid leave room for one another;
- the chrome (tick labels, axis names, grid lines, tooltip) is painted in the reader’s current theme, which a canvas cannot inherit from CSS the way the chart’s frame does.
Layout only fills gaps: any field the spec already sets (an explicit
axisLabel.formatter, nameLocation, etc.) is preserved. Chrome
colors are the exception - they OVERRIDE, because the whole point is
to replace whatever was baked in at plan time with the live theme.