Chart plugins are single JSON files in chart_plugins/. Adding a new chart type means adding one file and submitting a PR. No Python or server knowledge required.
If you have access to any AI chatbot (ChatGPT, Claude, Gemini, etc.) you can generate a complete plugin from your existing visualization code in minutes — no knowledge of the plugin format required.
Step 1 — Generate the prompt:
# From a local file
python scripts/make_prompt.py my_chart.js
# From a GitHub repo (script auto-selects relevant files)
python scripts/make_prompt.py https://github.com/user/repo
# From a single file on GitHub
python scripts/make_prompt.py https://github.com/user/repo/blob/main/src/chart.jsThis fetches the source and produces a ready-to-paste prompt. The prompt is printed to the terminal and also saved to scripts/_last_prompt.txt.
If your source is a snippet rather than a file, run the script with no arguments and paste your code interactively (end with Ctrl+D on macOS/Linux, Ctrl+Z + Enter on Windows).
When given a GitHub repo URL the script automatically filters out node_modules, build artifacts, config files, and oversized bundles — only the visualization source files are included. Files are ranked by relevance (source directories, visualization-related names, reasonable size) and fetching stops once roughly 80 KB of source is collected.
Step 2 — Paste into a chatbot:
Copy the prompt into ChatGPT, Claude, Gemini, or any AI chat. The AI will return a complete plugin JSON — including an exampleSpec (a small inline demo spec) so you can render it instantly to sanity-check it (see Test locally).
Step 3 — Save and strip fences:
Save the JSON response as chart_plugins/<type>.json (the type field in the JSON tells you the filename). If the AI wrapped its output in ``` code fences, remove those before saving.
Step 4 — Validate:
python mcp_server/validate_plugin.py chart_plugins/<type>.jsonFix any errors the validator reports (most are small formatting issues the AI occasionally misses), then skip to Test locally below.
Use this if you prefer to write the plugin by hand or want full control.
- Python 3.8+ (for running the server and validator)
pip install fastmcp- A browser for testing the renderScript
cp chart_plugins/_template.json chart_plugins/YOUR_CHART_TYPE.jsonName the file after the chart type (lowercase, hyphens allowed, e.g. chord.json, force-directed.json).
Open your new file and set:
A unique, lowercase identifier for your chart. Must match the filename without .json.
"type": "chord"A markdown snippet that tells an LLM what this chart does and what the spec looks like. Follow this pattern exactly — it is injected directly into LLM system prompts:
- **chord** — circular diagram showing flows or relationships between categories. Spec: { "type":"chord", "title":"...", "labels":["A","B","C"], "matrix":[[0,10,5],[10,0,8],[5,8,0]] }
Tips:
- Start with
- **type** — - One sentence describing when to use it
- Include a minimal
Spec:example with all required fields
A self-contained JS function as a string:
"renderScript": "function(wrap, spec) { ... }"Requirements:
- Self-contained: load any CDN libraries inside the function using the
load()pattern (see below) - No global state: do not assume any globals except
windowanddocument - Resize-aware: call
window.addEventListener('resize', ...)if the chart needs it - Height: if the chart needs a fixed height, set it only if
wrap.style.heightis not already set:if (!wrap.style.height) wrap.style.height = '400px';
Use this helper pattern (copy it into your function):
function load(url, globalName, callback) {
if (window[globalName]) { callback(); return; }
var s = document.createElement('script');
s.src = url;
s.onload = callback;
document.head.appendChild(s);
}
load('https://cdn.jsdelivr.net/npm/YOUR-LIB/dist/lib.min.js', 'LibGlobalName', function() {
// render here
});This pattern is safe to call multiple times — it reuses already-loaded scripts.
A small, real, fully-inline spec that renders out of the box — the "Demo this plugin" button in playground.html loads and renders it in one click, and it doubles as a smoke test for your renderScript.
"exampleSpec": { "type": "chord", "title": "Demo", "labels": ["A","B","C"], "matrix": [[0,10,5],[10,0,8],[5,8,0]] }Guidelines:
typemust equal the plugin'stype.- Keep it tiny — a handful of data points is enough to show the chart working.
- It must be renderable without a database. If your plugin normally takes a
"sql"spec, ship the equivalent inline-data form here instead (e.g.nodes/links,rows,events,data), since the playground has no SQL backend.
python mcp_server/validate_plugin.py chart_plugins/YOUR_CHART_TYPE.jsonFix any errors reported before proceeding.
Double-click playground.html to open it in your browser, then load your chart_plugins/<type>.json in step 1. Everything below runs in the page — your data never leaves your machine, and there are no network calls.
Just want to see the plugin render? Open the Advanced · work with a spec directly box and click "Demo this plugin" — it loads your exampleSpec (or, if you didn't ship one, scrapes the Spec: example from your promptDescription) and renders it immediately. Shipping an exampleSpec makes this a reliable one-click demo and smoke test.
Want to test it on your own raw data? The playground converts raw data into a spec without ever sending your data to an LLM:
- Step 2 — load or paste your raw CSV or JSON, then click Derive schema. Only your column names and types are read; the rows stay in the page.
- Step 3 — click Build chatbot prompt. It produces a prompt containing the plugin's description + your column names only (sample rows are opt-in). Paste it into any chatbot (ChatGPT/Claude/Gemini).
- Step 4 — paste back the
transform(rows)function the chatbot returns and click ▶ Apply transform & render. The function runs locally on your real data to build the spec.
The actual values never go to the LLM — only the structure does, and you can edit the prompt to redact column names first. Privacy-absolutists can skip the chatbot entirely and just write the transform() themselves.
Your chart appears on the right (drag its corner to resize). Errors are shown below the buttons. The playground preloads the same chart libraries the real app does, so plugins that rely on a global like echarts or d3 work without changes.
Note: a SQL-form spec (one with only a
"sql"field) can't be tested in the playground because there's no database in the browser. Test with the inline data form (e.g.nodes/links) instead.
If you'd rather drive it yourself, open data-explorer.html, open the browser console, and paste — replacing the two placeholders with your plugin JSON and a sample spec:
const plugin = /* paste your plugin JSON here */;
const renderFn = new Function("return (" + plugin.renderScript + ")")();
const wrap = document.createElement('div');
wrap.style.cssText = 'width:600px;height:400px;border:1px solid #ccc';
document.body.appendChild(wrap);
renderFn(wrap, { /* your example spec */ });- Fork the repo on GitHub.
- Create a branch:
git checkout -b chart/YOUR_CHART_TYPE - Add your plugin file.
- Commit:
git commit -m "Add YOUR_CHART_TYPE chart plugin" - Open a pull request against
main.
In the PR description, include:
- A screenshot or description of what the chart looks like
- The library/CDN it depends on
- An example spec
{
"type": "string — unique lowercase identifier",
"promptDescription": "string — markdown snippet for LLM system prompts",
"renderScript": "string — JS function(wrap, spec) { ... }",
"exampleSpec": "object (optional) — a small inline spec the playground can render in one click"
}type, promptDescription, and renderScript are required. exampleSpec is optional but recommended — it powers the playground's "Demo this plugin" button and serves as a smoke test. The server uses only the three required fields.
- Keep renderScript minified or compact — it's loaded into LLM context, so shorter is better.
- Avoid external fetch calls at render time; load everything via
<script>tags. - Test with bad/empty spec values to make sure the chart doesn't throw unhandled errors.
- Look at existing plugins like
chart_plugins/gauge.json(simple, readable) orchart_plugins/bar.json(handles multiple datasets) as references.