Skip to content

API Reference parrot_tools.chart

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.chart

View source

Chart Generation Tool for AI-Parrot Agents.

Generates visualizations (bar charts, line charts, pie charts, etc.) from structured data returned by agents.

Supports multiple backends:

  • altair (default): Vega-Lite JSON output — the frontend renders it natively (no extra deps); PNG/SVG export is available via the optional vl-convert-python dependency (falls back to JSON if not installed).
  • plotly (interactive HTML exports)

Alias AbstractTool

Re-exported from parrot_tools.abstract.AbstractTool.

Class ChartFormat

Output format for charts.

Class ChartStyle

Visual styling configuration for charts.

Parameter Type Default Description
primary_color str '#4A90D9'
secondary_colors List[str] (lambda: ['#50C878', '#FFB347', '#FF6B6B', '#9B59B6', '#3498DB', '#1ABC9C', '#F39C12', '#E74C3C'])()
background_color str '#FFFFFF'
text_color str '#333333'
grid_color str '#E0E0E0'
title_font_size int 14
label_font_size int 11
tick_font_size int 10
font_family str 'sans-serif'
figure_width float 10.0
figure_height float 6.0
dpi int 150
show_grid bool True
grid_alpha float 0.3

Fields:

Field Type Default Description
primary_color str '#4A90D9'
secondary_colors List[str] field(default_factory=lambda: ['#50C878', '#FFB347', '#FF6B6B', '#9B59B6', '#3498DB', '#1ABC9C', '#F39C12', '#E74C3C'])
background_color str '#FFFFFF'
text_color str '#333333'
grid_color str '#E0E0E0'
title_font_size int 14
label_font_size int 11
tick_font_size int 10
font_family str 'sans-serif'
figure_width float 10.0
figure_height float 6.0
dpi int 150
show_grid bool True
grid_alpha float 0.3

Class ChartTool

Tool for generating charts from structured data.

Designed to work with integration wrappers (Teams, Telegram) that can send images inline in messages.

Parameter Type Default Description
backend Literal['altair', 'plotly'] 'altair'
output_dir Optional[Path] None
style Optional[ChartStyle] None
auto_cleanup bool True
cleanup_age_hours int 24
artifact_store Any None
**kwargs {}

Attributes:

Attribute Type Description
name str
description str
backend Chart generation library (altair, plotly)
output_dir Directory for saving generated charts
style Default visual styling
auto_cleanup Whether to cleanup old charts

Class ChartType

Supported chart types.

Alias ExportsToStoreMixin

Re-exported from parrot_tools._exports.ExportsToStoreMixin.

Class GenerateChartInput

Input schema for chart generation.

Fields:

Field Type Default Description
chart_type str Type of chart: bar, line, pie, scatter, histogram, area, horizontal_bar, heatmap
title str Title of the chart
data Any Data for the chart. Can be a dict or JSON string. Format depends on chart type:\n - bar/line/area: {"categories": ["A","B"], "values": [10,20]} or {"x": [...], "y": [...]}\n - pie: {"labels": ["A","B"], "values": [30,70]}\n - scatter: {"x": [1,2,3], "y": [4,5,6]}\n - histogram: {"values": [1,2,2,3,3,3,4]}\n - heatmap: {"data": 1,2],[3,4, "x_labels": [...], "y_labels": [...]}\n
x_label Optional[str] None Label for X axis
y_label Optional[str] None Label for Y axis
legend_title Optional[str] None Title for the legend (if applicable)
output_format str 'vegalite' Output format: vegalite (default Vega-Lite JSON spec, no extra deps — recommended when the frontend renders charts natively), png/svg (recommended for Teams/Telegram; requires the optional vl-convert-python dependency, falls back to vegalite if absent), html (plotly backend only)
style Optional[str] 'default' Visual style: default, dark, minimal, corporate

Method GenerateChartInput.parse_data_string

Parse data if it's a JSON string.

parse_data_string(values)

Parameter Type Default Description
values

Alias ToolResult

Re-exported from parrot_tools.abstract.ToolResult.

Function generate_chart

Convenience function to generate a chart without instantiating the tool.

generate_chart(chart_type: str, title: str, data: Dict[str, Any], **kwargs) -> Path

Parameter Type Default Description
chart_type str Type of chart (bar, line, pie, etc.)
title str Chart title
data Dict[str, Any] Chart data
**kwargs {} Additional options (x_label, y_label, output_format, etc.)

Returns: Path — Path to the generated chart image

Alias tool_schema

Re-exported from parrot_tools.decorators.tool_schema.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally