Function: useChartFetch()
useChartFetch(
chartId):ByIdFetchState<{chartId:string;error?:string;result?: {chartType:"custom"|"bar"|"horizontalBar"|"line"|"area"|"combo"|"waterfall"|"scatter"|"heatmap"|"radar"|"pie"|"funnel"|"treemap";option:Record<string,unknown>; }; }>
Fetch a chart by id from the Mastra plugin’s generic
/embed/chart/:id endpoint via MastraPluginClient.chart.
Used by the chat UI to resolve [chart:<chartId>] markers the agent
embeds in prose.
The chart planner runs in the background after prepare_chart
mints the id, so the server long-polls the cache until the
entry settles (result or error set) and returns the final
payload in a single response. The hook performs ONE cached
fetch and surfaces:
data.resultset → render the Echarts spec.data.errorset → surface viadata.error.datawith neither field (planner exceeded the server’s long-poll budget) → render nothing; this answer is NOT cached, so a re-mount will retry.data === undefined(404) → unknown / expired id; render nothing.
Parameters
Section titled “Parameters”chartId
Section titled “chartId”string | undefined
Returns
Section titled “Returns”ByIdFetchState<{ chartId: string; error?: string; result?: { chartType: "custom" | "bar" | "horizontalBar" | "line" | "area" | "combo" | "waterfall" | "scatter" | "heatmap" | "radar" | "pie" | "funnel" | "treemap"; option: Record<string, unknown>; }; }>