Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Generate TradingView-style dark-theme candlestick charts with RSI, MACD, Bollinger Bands, and EMA/SMA using mplfinance.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: chart3version: 3.0.24description: |5Interactive web charts: line, bar, candle, scatter, with HTML and screenshot output.67Use when visualizing data for analysis or BI (e.g. plot BTC vs gold last year, bar chart of revenue by quarter, compare two return series).89metadata:10starchild:11emoji: "๐"12skillKey: chart1314user-invocable: true15disable-model-invocation: false1617---1819# Chart โ Project-Based Interactive Charting2021Generate interactive chart pages with Apache ECharts. Each chart lives in a dedicated project folder under `output/chart-html/`, making it easy to reuse and iterate.2223## When to Use2425Any time the user wants a visual chart: price charts, comparisons, dashboards, business analytics, etc.2627## Architecture2829- **ECharts** (CDN) for rendering30- **ECharts native export (`getDataURL`) + canvas merge** for reliable PNG output31- **Project-based storage**: one folder per chart project32- **No gallery mode**: all artifacts stay in the project folder3334## Project Structure (Required)3536Each chart project should follow:3738```39output/chart-html/40<project-name>/41index.html # chart page42generate.py # generation script (for reproducibility)43README.md # title / description / data source notes44data.json # data snapshot45screenshot.png # saved image46```4748Example folder name: `btc-90d-20260401`4950## Workflow5152### Step 1: Pick template or custom layout5354Available templates:5556| Template | Best for |57|---|---|58| `line.html` | Time-series trends, multi-series comparisons |59| `bar.html` | Category comparisons, rankings |60| `pie.html` | Composition / share breakdown |61| `candlestick.html` | OHLCV price charts |62| `scatter.html` | Correlation, distribution |63| `dashboard.html` | KPI cards + 2ร2 multi-chart grid |64| `radar.html` | Multi-dimension scoring |65| `heatmap.html` | Matrix / calendar intensity |66| `dual-axis.html` | Two series with very different scales (e.g. market cap vs stablecoin supply) โ left and right Y axes, each with its own label color |67| `multi-panel.html` | Stacked panels sharing one X axis (e.g. price + volume + RSI) โ single ECharts instance, tooltip/zoom synced across all panels |68| `waterfall.html` | Incremental contribution breakdown (e.g. P&L attribution, budget variance) โ positive/negative bars stacked on a floating base |6970### Step 2: Create project folder7172Use `create_project(name, description, data_sources)` from `scripts/build_chart.py`.7374### Step 3: Build and save chart page7576Use either:77- `build_chart(template_name, ...)`78- `build_chart_custom(...)`7980Then save as `index.html` in the project folder:81- `save_chart(html, project_dir=project_dir)`8283### Step 4: Save reproducible assets8485Also save:86- `save_generate_script(script_content, project_dir)` โ `generate.py`87- `save_data(data, project_dir)` โ `data.json`88- project README is created by `create_project(...)`8990### Step 5: Serve preview9192Use project-root serving (recommended):9394```python95preview_serve(96title="Chart Preview",97dir="skills/chart/scripts",98command="python3 chart_server.py /data/workspace/output/chart-html 7860",99port=7860100)101```102103Then open: `/preview/<id>/<project-name>/index.html`104105Important behavior in v3.0.1:106- `chart_server.py` now rewrites preview-prefixed static paths internally (`/preview/<id>/...` โ `/...`) before filesystem lookup.107- This guarantees the preview iframe resolves the real project `index.html` instead of falling back to root directory listing.108- Keep project pages under `output/chart-html/<project>/index.html` (do not serve `output/chart-html` directly as a static preview without `chart_server.py`).109110### Step 6: Export image111112Two modes:1131. **User wants web page + image**: click "๐พ Save Image" in page toolbar, saves to current project as `screenshot.png`1142. **User wants image only**: call `screenshot_chart(project_dir)` (Playwright) and send `screenshot.png` directly115116## Toolbar Requirements117118Every chart page must include these buttons:119120```html121<div class="actions">122<button onclick="downloadPNG(this)">๐ฅ Download PNG</button>123<button onclick="copyToClipboard(this)">๐ Copy Image</button>124<button onclick="saveToProject(this)">๐พ Save Image</button>125</div>126```127128Do not include gallery entry.129130## Key Files131132| File | Purpose |133|------|---------|134| `skills/chart/scripts/base-styles.css` | Base dark theme CSS |135| `skills/chart/scripts/base-export.js` | Export helpers: download/copy/save-to-project |136| `skills/chart/scripts/build_chart.py` | Project creation, HTML build, data/script save, screenshot |137| `skills/chart/scripts/chart_server.py` | Static server + `/save-chart` API |138| `skills/chart/templates/*.html` | Reusable chart templates |139| `output/chart-html/<project>/*` | All generated chart artifacts |140141## Notes142143- Embed data directly in HTML (`const DATA = ...`) to avoid iframe CORS issues.144- For multi-chart pages, register all chart instances in `window.CHART_INSTANCES`.145- Use meaningful project names (`topic-range-date`) for easy lookup.146