# `render_chart` — Render Publication-Grade Executive SVG Chart

> Part of [Executive SVG Chart & KPI Card Compiler Edge API](https://chart-viz.apikeg.com/llms.txt) (`com.apikeg/chart-viz`)

Compiles structured business data into a crisp standalone SVG + base64 data URI across bar, stacked_bar, horizontal_bar, line, area, waterfall, funnel, and gantt chart types, returning a verified zero-overlap layoutReport.

**Why call instead of DIY:** Replaces fragile headless Chromium/Canvas chart pipelines and LLM-hallucinated SVG paths with deterministic Heckbert scales and SAT text collision resolution at $0.002/chart in <10ms.

- **REST Endpoint:** `POST https://chart-viz.apikeg.com/v1/render-chart`
- **MCP Server:** `https://chart-viz.apikeg.com/mcp` (tool: `render_chart`)
- **Pricing:** $0.002 USD per rendered executive SVG chart (x402 instant micropayment)
- **Free Dry-Run:** `POST https://chart-viz.apikeg.com/v1/render-chart?dry_run=true`

## Input JSON Schema
```json
{
  "type": "object",
  "properties": {
    "chartType": {
      "type": "string",
      "enum": [
        "bar",
        "stacked_bar",
        "horizontal_bar",
        "line",
        "area",
        "waterfall",
        "funnel",
        "gantt"
      ],
      "description": "Enterprise chart type: 'bar', 'stacked_bar', 'horizontal_bar', 'line', 'area', 'waterfall', 'funnel', or 'gantt'."
    },
    "title": {
      "type": "string",
      "maxLength": 180,
      "description": "Executive headline chart title."
    },
    "subtitle": {
      "type": "string",
      "maxLength": 220,
      "description": "Context subtitle (timeframe, unit scope, or cohort)."
    },
    "footnote": {
      "type": "string",
      "maxLength": 240,
      "description": "Source attribution or footnote rendered along the bottom edge."
    },
    "width": {
      "type": "integer",
      "default": 840,
      "minimum": 360,
      "maximum": 2400,
      "description": "Target SVG viewport width in pixels."
    },
    "height": {
      "type": "integer",
      "default": 480,
      "minimum": 240,
      "maximum": 1800,
      "description": "Target SVG viewport height in pixels (auto-expands if dense rows/margins require it)."
    },
    "palette": {
      "type": "string",
      "enum": [
        "corporate",
        "slate",
        "emerald",
        "dark"
      ],
      "default": "corporate",
      "description": "Accessible executive palette ('corporate', 'slate', 'emerald', or 'dark')."
    },
    "valueFormat": {
      "type": "string",
      "enum": [
        "compact",
        "currency",
        "percent",
        "percent_ratio",
        "integer",
        "decimal",
        "raw"
      ],
      "default": "compact",
      "description": "Axis and data-label formatter ('compact' -> 12.4K, 'currency' -> $1.2M, 'percent' -> 45.3%, 'percent_ratio' -> 0.453 as 45.3%, 'integer', 'decimal', 'raw')."
    },
    "currencySymbol": {
      "type": "string",
      "default": "$",
      "maxLength": 8,
      "description": "Currency symbol prefix used when valueFormat is 'currency'."
    },
    "unitSuffix": {
      "type": "string",
      "default": "",
      "maxLength": 16,
      "description": "Optional unit suffix appended to formatted values (e.g. ' ms', 'x')."
    },
    "xAxisLabel": {
      "type": "string",
      "maxLength": 120,
      "description": "Optional horizontal axis title."
    },
    "yAxisLabel": {
      "type": "string",
      "maxLength": 120,
      "description": "Optional vertical axis title."
    },
    "showDataLabels": {
      "type": "boolean",
      "description": "Render collision-checked value labels directly on bars/points."
    },
    "showLegend": {
      "type": "boolean",
      "description": "Override automatic legend visibility."
    },
    "showGrid": {
      "type": "boolean",
      "default": true,
      "description": "Render subtle dashed reference gridlines."
    },
    "includeZero": {
      "type": "boolean",
      "description": "Force numeric scale to include the 0 baseline."
    },
    "categories": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 160
      },
      "minItems": 1,
      "maxItems": 120,
      "description": "Category or time-bucket labels for bar, stacked_bar, horizontal_bar, line, and area charts."
    },
    "series": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "Series legend name (e.g. 'Enterprise ARR' or 'FY26 Actuals')."
          },
          "values": {
            "type": "array",
            "items": {
              "type": "number",
              "description": "Numeric data values corresponding 1:1 with categories."
            },
            "minItems": 1,
            "maxItems": 120,
            "description": "Ordered numeric values matching categories length."
          },
          "color": {
            "type": "string",
            "maxLength": 32,
            "pattern": "^#[0-9A-Fa-f]{6}$",
            "description": "Optional 6-digit hex color override (e.g. '#1D4ED8')."
          }
        },
        "required": [
          "name",
          "values"
        ],
        "additionalProperties": false,
        "description": "Named numeric data series."
      },
      "minItems": 1,
      "maxItems": 12,
      "description": "1 to 12 data series for Cartesian charts."
    },
    "referenceLine": {
      "type": "object",
      "properties": {
        "value": {
          "type": "number",
          "description": "Target or threshold axis value for the dashed reference line."
        },
        "label": {
          "type": "string",
          "maxLength": 100,
          "description": "Optional callout badge text (defaults to 'Target: <formatted value>')."
        },
        "color": {
          "type": "string",
          "maxLength": 32,
          "pattern": "^#[0-9A-Fa-f]{6}$",
          "description": "Optional 6-digit hex color override for the reference line."
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false,
      "description": "Optional target/threshold reference line."
    },
    "waterfallSteps": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "Bridge step label (e.g. 'Opening ARR', 'Expansion', 'Churn', 'Ending ARR')."
          },
          "kind": {
            "type": "string",
            "enum": [
              "start",
              "delta",
              "subtotal",
              "total"
            ],
            "description": "Bridge step role: 'start' (initial baseline), 'delta' (+/- bridge change), 'subtotal' (running intermediate total), or 'total' (final total)."
          },
          "value": {
            "type": "number",
            "description": "Step amount. Required for 'start' and 'delta'; optional for 'subtotal' and 'total' (auto-computed from running balance when omitted)."
          }
        },
        "required": [
          "label",
          "kind"
        ],
        "additionalProperties": false,
        "description": "Executive waterfall financial/ops bridge step."
      },
      "minItems": 2,
      "maxItems": 40,
      "description": "Ordered bridge steps for 'waterfall' charts."
    },
    "funnelStages": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "Conversion funnel stage name (e.g. 'Qualified Pipeline')."
          },
          "value": {
            "type": "number",
            "minimum": 0,
            "description": "Non-negative volume or revenue at this stage."
          },
          "color": {
            "type": "string",
            "maxLength": 32,
            "pattern": "^#[0-9A-Fa-f]{6}$",
            "description": "Optional 6-digit hex color override."
          }
        },
        "required": [
          "label",
          "value"
        ],
        "additionalProperties": false,
        "description": "Conversion funnel stage."
      },
      "minItems": 2,
      "maxItems": 20,
      "description": "Ordered conversion stages for 'funnel' charts."
    },
    "ganttTasks": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 64,
            "description": "Optional caller task identifier."
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 140,
            "description": "Workstream or milestone title."
          },
          "start": {
            "type": "string",
            "minLength": 8,
            "maxLength": 40,
            "description": "ISO 8601 start date (e.g. '2026-04-01')."
          },
          "end": {
            "type": "string",
            "minLength": 8,
            "maxLength": 40,
            "description": "ISO 8601 end date (e.g. '2026-04-21'). Omit or match start for milestones."
          },
          "group": {
            "type": "string",
            "maxLength": 80,
            "description": "Optional swimlane/owner prefix (e.g. 'Platform' or 'GTM')."
          },
          "progress": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "description": "Optional completion percentage [0-100] rendered inside the bar."
          },
          "milestone": {
            "type": "boolean",
            "description": "Set true to render as a diamond milestone marker."
          },
          "color": {
            "type": "string",
            "maxLength": 32,
            "pattern": "^#[0-9A-Fa-f]{6}$",
            "description": "Optional 6-digit hex color override."
          }
        },
        "required": [
          "label",
          "start"
        ],
        "additionalProperties": false,
        "description": "Gantt timeline task or milestone row."
      },
      "minItems": 1,
      "maxItems": 60,
      "description": "Timeline tasks and milestones for 'gantt' charts."
    },
    "ganttMilestones": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Vertical milestone callout label (e.g. 'GA Launch')."
          },
          "date": {
            "type": "string",
            "minLength": 8,
            "maxLength": 40,
            "description": "ISO 8601 milestone date (e.g. '2026-06-01')."
          },
          "color": {
            "type": "string",
            "maxLength": 32,
            "pattern": "^#[0-9A-Fa-f]{6}$",
            "description": "Optional 6-digit hex color override."
          }
        },
        "required": [
          "label",
          "date"
        ],
        "additionalProperties": false,
        "description": "Vertical milestone guide line across the Gantt timeline."
      },
      "minItems": 1,
      "maxItems": 12,
      "description": "Optional vertical milestone guide lines for 'gantt' charts."
    }
  },
  "required": [
    "chartType"
  ],
  "additionalProperties": false
}
```

## Examples
### FY26 ARR Financial Waterfall Bridge
```bash
curl -X POST "https://chart-viz.apikeg.com/v1/render-chart" \
  -H "Content-Type: application/json" \
  -d '{"chartType":"waterfall","title":"FY26 Net ARR Bridge","subtitle":"Consolidated SaaS ($USD)","palette":"corporate","valueFormat":"currency","currencySymbol":"$","unitSuffix":"","width":840,"height":480,"showGrid":true,"waterfallSteps":[{"label":"Opening ARR","value":4200000,"kind":"start"},{"label":"New Logos","value":1150000,"kind":"delta"},{"label":"Expansion","value":680000,"kind":"delta"},{"label":"Gross ARR","kind":"subtotal"},{"label":"Contraction","value":-210000,"kind":"delta"},{"label":"Logo Churn","value":-320000,"kind":"delta"},{"label":"Ending ARR","kind":"total"}]}'
```
Expected output: Standalone 840x480 SVG + data:image/svg+xml;base64 URI with zeroOverlapsVerified=true.
### Product Launch Gantt Timeline with Milestones
```bash
curl -X POST "https://chart-viz.apikeg.com/v1/render-chart" \
  -H "Content-Type: application/json" \
  -d '{"chartType":"gantt","title":"Enterprise v2.0 Launch Plan","palette":"slate","valueFormat":"compact","currencySymbol":"$","unitSuffix":"","width":840,"height":420,"showGrid":true,"ganttTasks":[{"label":"Security Audit","group":"Infra","start":"2026-04-01","end":"2026-04-18","progress":100},{"label":"Beta Cohort","group":"Product","start":"2026-04-15","end":"2026-05-10","progress":65},{"label":"GA Launch","group":"GTM","start":"2026-05-15","milestone":true}]}'
```
Expected output: Standalone Gantt SVG with auto-sized left task gutter, UTC date ticks, progress bars, and milestone diamond.
