Chart Generation
The chart generation agent creates custom data visualizations based on user requests.
How it works
Section titled “How it works”The agent uses this workflow:
- Receives a natural language request from the user
- Executes queries to obtain relevant data for the visualization
- Generates the requested chart(s)
Input parameters
Section titled “Input parameters”Required:
message(string): The natural language question or request to send to the agentdata_product_id(string): The data product to query
Optional:
data_product_version(string): The data product version to query. Defaults to the active version when omitted.
Output format
Section titled “Output format”The agent produces a series of thinking, tool call, tool return, and text blocks as it works through the user request.
The final message, assuming no errors, is a string.
The chart(s) generated are available as html and json vega configs with successful charting tool return blocks.
Available tools
Section titled “Available tools”The agent is configured with 3 tools:
Get data schema
Section titled “Get data schema”Retrieves the schema for tables in the data product. Optionally supports semantic search of sample values.
Key parameters:
data_product_id: The data product to get schema forquery: Optional semantic search query for sample values
SQL execution
Section titled “SQL execution”Executes SQL queries against the data product’s database. The tool automatically handles result serialization and may limit rows/columns for very large results.
Key parameters:
data_product_id: The data product to querysql: The SQL query to executeresult_table_name: A semantic name for the result table
Chart generation from asset
Section titled “Chart generation from asset”Generates visualizations from an asset (a CSV produced by a prior SQL execution).
The agent uses ChartGrammar — a structured chart configuration — by default; if the requested chart can’t be expressed in ChartGrammar, the agent falls back to providing custom Altair Python code via chart_code_snippet.
Key parameters:
asset_id(required): ID of the CSV asset containing the datachart_grammar: Structured chart configuration (preferred path)chart_code_snippet: Python function using Altair (fallback when ChartGrammar can’t express the chart; required withimage_title)image_title: Title for the chart (required withchart_code_snippet)
Behavior notes
Section titled “Behavior notes”- The agent always uses result tables from executed queries to answer questions (never synthesizes data)
- For complex questions, the agent may execute multiple queries to explore the dataset or obtain intermediate results
- When generating charts, it returns the first reasonable visualization without excessive iteration
- Charts are generated using Altair and returned as JSON representations