dashboard-schema.md

Part of the ad-performance-analysis skill

generate-dashboard.py payload schema

When the user opts into a visualization, write a JSON payload to /tmp/ad_payload.json with this shape, then run generate-dashboard.py (see SKILL.md for the bash invocation).

All sections are optional except title.

Example payload

{
  "title": "Cross-Channel Ad Performance",
  "subtitle": "7 platforms · Apr 1 – May 1, 2026",
  "badge": "Data current as of May 1, 2026",
  "kpis": [
    {"label": "Total Spend", "value": "$109K", "change": "+18%", "direction": "up", "prior": "Prior: $92K"}
  ],
  "charts": [
    {
      "id": "chart1",
      "title": "Spend by Platform",
      "layout": "half",
      "height": 280,
      "script": "new Chart(document.getElementById('chart1'), { type: 'bar', data: { labels: [...], datasets: [{ label: 'Current', data: [...], backgroundColor: '#0073FF', borderRadius: 4 }] }, options: { ...chartDefaults, scales: { x: { grid: { display: false } }, y: { ticks: { callback: v => '$' + (v/1000).toFixed(0) + 'K' } } } } });"
    }
  ],
  "anomalies": {"title": "Anomalies Detected", "items": ["..."]},
  "table": {
    "title": "Campaign Performance",
    "columns": [
      {"key": "platform", "label": "Platform"},
      {"key": "spend", "label": "Spend", "align": "right"},
      {"key": "tier", "label": "Rating"}
    ],
    "rows": [
      {"platform": "Google Ads", "spend": "$12,981", "tier": {"html": "<span class='tier-badge tier-winner'>Winner</span>"}},
      {"platform": "Facebook Ads", "spend": "$5,423", "tier": {"html": "<span class='tier-badge tier-waste'>Waste</span>"}, "_row_class": "highlight-waste"}
    ]
  },
  "custom_sections": [{"title": "Optional Section", "html": "<p>Any HTML</p>"}],
  "footer": "Generated by Fivetran Ad Performance · May 1, 2026"
}

Key rules

  • charts[].script — write the full new Chart(...) call as a JS string. It is injected verbatim into the page <script> block after fivetranColors and chartDefaults are defined, so you can spread those. Write real JavaScript here — callbacks, dynamic per-bar colors, dual axes, tooltip formatters all work because this is actual JS, not a JSON config.
  • table.rows cell values: plain string = HTML-escaped; {"html": "..."} = raw HTML (use for tier badges).
  • table.rows._row_class: "highlight-waste" (red tint), "highlight-winner" (green tint), "highlight-caution" (yellow tint).
  • custom_sections injects raw HTML cards — use for non-Chart.js content, geographic tables, etc.
  • Run python3 generate-dashboard.py --help-schema for the full schema reference.
  • Derive all values from query results — never type them manually. Every kpis[].value, kpis[].change, kpis[].prior, and numeric string in table.rows must be computed from the same structured query output used to build the charts. Run queries with --format=json to get machine-readable rows, compute totals and formatted strings in Python, then write the payload. Transcribing numbers from terminal output by hand causes KPI/chart mismatches.

Escape hatch (rare)

Only fall back to writing HTML manually if the page structure itself cannot be expressed as cards / chart grid / table / anomalies — e.g. a multi-page report or embedded iframe app. Custom chart types, axis formatters, and dynamic colors all fit in the script field.

Skills Mixer