Skip to main content

render_chart

Function render_chart 

Source
pub fn render_chart(
    rows: &[Value],
    opts: &ChartOptions,
) -> Result<ChartResult, McpError>
Expand description

Render a chart from a list of JSON row objects.

rows is expected to be the output of execute_query_to_json: each entry is a Value::Object with column name → value pairs. Non-object rows are skipped silently.

§Errors

  • Returns ErrorCode::EmptyData if rows is empty.
  • Returns ErrorCode::SchemaMismatch if required columns named in opts are absent, if x or y columns cannot be interpreted as numeric for chart types that require numeric axes, or if a categorical axis produces zero distinct categories.
  • Returns ErrorCode::InternalError wrapping failures from the underlying plotters backend during rendering or PNG/SVG encoding.
  • Returns ErrorCode::InvalidArgument if the result set exceeds 50,000 rows.