Generate a Chart from Data
meta_generate_chartGenerate PNG chart images from data for visual reports. Use to create bar, line, pie, and other chart types from Meta insights data.
Instructions
Generates a chart image (PNG) from provided data. Uses QuickChart (Chart.js) to render.
Perfect for creating visual reports from Meta insights data. The chart is saved as a PNG file that can be inserted into Word docs, presentations, or shared directly.
Args:
chart_type (string): 'bar', 'line', 'pie', 'doughnut', 'radar', 'polarArea', 'horizontalBar'
title (string): Chart title
labels (string[]): X-axis labels or pie slice labels
datasets (array): One or more datasets, each with:
label (string): Dataset name (e.g., "Impressions")
data (number[]): Data values matching labels
color (string, optional): CSS color (e.g., "#1877F2", "rgba(24,119,242,0.5)")
width (number): Image width in pixels (default: 800)
height (number): Image height in pixels (default: 400)
output_path (string, optional): Save PNG to this path. If omitted, returns the chart URL.
stacked (boolean, optional): Stack bars/lines (default: false)
show_values (boolean, optional): Display data values on the chart (default: false)
Returns: Chart URL or file path. The URL can be opened in a browser or fetched as a PNG.
Example datasets for ad performance: labels: ["Mon","Tue","Wed","Thu","Fri"] datasets: [ { label: "Impressions", data: [1200,1800,1500,2100,1900], color: "#1877F2" }, { label: "Clicks", data: [45,62,51,78,65], color: "#42B72A" } ]
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chart_type | No | bar | |
| title | Yes | ||
| labels | Yes | ||
| datasets | Yes | ||
| width | No | ||
| height | No | ||
| output_path | No | Save PNG to this file path | |
| stacked | No | ||
| show_values | No | ||
| response_format | No | Output format: 'markdown' for human-readable or 'json' for machine-readable | markdown |