Build and revise reusable OntoPlato .chart.json charts and maps from query results or datasets, unifying 13 standard statistical/graph chart categories, WGS-84 point maps, and China province choropleth maps.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Ontoplato Chart?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ontomato-ai-ontoplato-chart)
---
name: ontoplato-chart
description: Build and revise reusable OntoPlato .chart.json charts and maps from query results or datasets, unifying 13 standard statistical/graph chart categories, WGS-84 point maps, and China province choropleth maps.
compatibility: Requires Node.js 24+; runs locally with no server credentials.
---
# Chart
This skill is the single authoritative `.chart.json` specification across OntoPlato. Use it whenever a conversation needs a chart or map reusable in dashboards, object views, analysis reports, or metric widgets: it produces a validated `.chart.json` file that the platform renders centrally and re-runs with current parameters whenever bound to a MetricView.
## Command and Runtime Notes
The script runs purely locally (bundling the `china-provinces` map resource; no network access or server credentials are needed). Write the input to a JSON file and run from the workspace root, where `<this-skill>` is the directory containing this `SKILL.md`:
```sh
node <this-skill>/scripts/index.mjs work/input.json
```
After validating rows and field mappings, the script writes `outputs/<name>.chart.json` (overridable via `ONTOMATO_OUTPUT_DIR`) and prints its relative path.
- Reference the printed `.chart.json` path as a Markdown image in chat or reports. The image alt text is the title displayed in chat and becomes the card name when added to a dashboard; **do not put titles inside the chart file**.
- Input rows must already be at the final display grain: counts, aggregations, and shares belong to the MetricView or `ontoplato-data-retrieval` logic. This skill handles column mapping, sorting, formatting, and display limits only.
## Input Schema
```json
{
"chartType": "bar",
"name": "staff-by-department",
"dataset": "outputs/staff.dataset.json",
"fields": { "xAxis": "department", "yAxis": "headcount" },
"display": { "sort": [{ "field": "headcount", "order": "desc" }], "displayLimit": 10 },
"source": { "metric": { "metricId": "metric-id", "parameters": { "year": 2025 } } }
}
```
| Field | Required | Meaning |
| --- | --- | --- |
| `chartType` | yes | Chart or map type from the table below. |
| `name` | yes | Output file name without directory separators or extension. |
| `data` | one of | Inline array of row objects (mutually exclusive with `dataset`). |
| `dataset` | one of | Workspace data file path: an accepted `.dataset.json`, or a JSON row array / `{ "rows": [...] }`. |
| `fields` | yes | Mapping of chart roles from the table below to real column names. |
| `display` | no | Display settings: `sort`, `displayLimit`, `formats`. |
| `seriesNames` | no | Mapping of series column names to legend labels. |
| `axisNames` | no | `{ "x": "...", "y": "...", "y2": "..." }` axis titles. |
| `graphInput` | required for `graph` | `object` or `edges`. |
| `featureNameProperty` | optional for choropleth | Boundary property matched by `name` in `admin-choropleth-map`: omit for short names (`name`), `fullname` for official full names, `code` for administrative codes. |
| `source` | no | Single source binding object: accepts only `metric` or `dataset`; providing both or any other key is rejected. |
## Chart Types and Field Roles
Role values must be real column names in the data; roles ending in `?` are optional. `graph` supersedes the retired `network-graph` type—always use `graph` for new relationship charts.
| Category | `chartType` | Field roles |
| --- | --- | --- |
| Bar / Line / Area / Pictorial bar | `bar`, `line`, `area-line`, `pictorial-bar` | `xAxis`, `yAxis` (one numeric column or an array of numeric columns) |
| Dual-axis bar + line | `bar-line` | `xAxis`, `barSeries` (array of one or more numeric columns), `lineSeries` |
| Pie / Donut / Nightingale rose | `pie`, `donut`, `nightingale-rose` | `name`, `value`, `share?` |
| Treemap / Funnel | `treemap`, `funnel` | `name`, `value`, `share?` |
| Sankey | `sankey` | `source`, `target`, `value` |
| Scatter / Bubble | `scatter` | `xAxis`, `yAxis`, `name?`, `size?` |
| Heatmap | `heatmap` | `xAxis`, `yAxis` (both categories), `value` (numeric) |
| Radar | `radar` | `name`, `value` (one non-negative axis per row) |
| Sunburst | `sunburst` | `id`, `parent`, `name`, `value`, `share?` (`parent` is `null` on roots) |
| Boxplot | `boxplot` | `category`, `min`, `q1`, `median`, `q3`, `max` |
| Gauge / Liquid fill | `gauge`, `liquid-fill` | `value` (single row, with an explicit format in `display.formats`) |
| Timeline | `timeline` | `date`, `name`, `description` |
| Relationship graph | `graph` | `graphInput: "object"` uses `nodes`, `links` (one row holding two JSON arrays); `graphInput: "edges"` uses `source`, `target`, `value?`, `relation?`, `sourceName?`, `targetName?`, `sourceCategory?`, `targetCategory?` |
| WGS-84 point map | `leaflet-map` | `lng`, `lat`, `name`, `value?` |
| China province choropleth map | `admin-choropleth-map` | `name`, `value` |
## Map Rules
### WGS-84 point maps (`leaflet-map`)
- `lng` and `lat` must be WGS-84 decimal degrees; convert other coordinate systems before charting.
- The basemap is fixed to the platform's bundled `china-provinces` resource; street-level tiles are not available.
- `name` is the readable place label; when `value` is provided, marker size scales from 6 to 40px and appears in tooltips.
- Rows without valid coordinates cannot be plotted; fix the source data rather than silently dropping them.
### China province choropleth maps (`admin-choropleth-map`)
- Boundaries use the platform's bundled `china-provinces` resource; external boundaries are never downloaded or cached.
- Before writing, the script verifies every row's `name` value against the selected boundary property:
- default (omit `featureNameProperty`, uses `name`): short province names such as `北京`, `广东`, `内蒙古`;
- `fullname`: official full names such as `北京市`, `广东省`;
- `code`: administrative codes as strings such as `110000`.
- Any unmatched region aborts with an error and writes no file; fix the region column or pass the matching `featureNameProperty`.
## Display Settings and Theme Rules
`display` supports `sort`, `displayLimit`, and `formats`:
- `sort` is an array of `{ "field": "<column>", "order": "asc" | "desc" }`. Sorting is stable with nulls last and never mutates underlying values.
- `displayLimit` is a positive integer limiting displayed rows.
- `formats` maps column names to format definitions where `kind` is `number`, `percent`, `text`, `date`, or `currency`, with optional `decimals` (non-negative integer) and `currency`. Percent formats (`kind: "percent"`) require an explicit `scale`: `100` displays `0.25` as `25%`, and `1` displays `25` as `25%`.
```json
{
"sort": [{ "field": "amount", "order": "desc" }],
"displayLimit": 10,
"formats": {
"amount": { "kind": "number", "decimals": 0 },
"rate": { "kind": "percent", "scale": 100 }
}
}
```
Themes and palettes are applied centrally by the platform from shared design tokens (PPTX rendering likewise uses `resources/chart-theme.json` bundled in `ontoplato-report`). Do not invent custom palettes, embed titles inside `.chart.json`, or use executable option keys (`formatter`, `valueFormatter`, `renderItem`, `callback`, etc., all rejected by validation).
## Single Source Binding
Each `.chart.json` binds at most one formal source, explicitly supporting both **MetricView** and **retrieval `.dataset.json`** paths:
- **MetricView path**: When rows come from a published MetricView, write
`"source": { "metric": { "metricId": "...", "parameters": { ... } } }`.
This object uses a strict schema allowing **only `metricId` and `parameters`** (do not include extra keys such as `revision`). Copy `metricId` and `parameters` verbatim from the accepted dataset's metric recipe or from `ontoplato-query` (`metrics` / `execute-metric`); never invent them.
- **Retrieval dataset path and `work/` vs. `outputs/` reuse boundary**: Reading a `dataset` file without an explicit `source` automatically records that path in `ontomato.dataset.path`, but only formal delivered artifacts (`outputs/*.dataset.json`) can be settled and reused by reports or dashboards. If you pass a temporary rows file under `work/` (e.g. `work/rows.json`), either pair it with an explicit `"source": { "metric": ... }` or read from the formal `outputs/*.dataset.json`—an auto-recorded `work/` path cannot be settled for dashboard/report reuse.
- **Precedence and exclusivity**: An explicit `source` takes precedence over the auto-recorded `dataset`. `source` accepts only `metric` or `dataset`; specifying both or any other key is rejected.
- **Unbound limitation**: Charts with neither `metric` nor `dataset` (such as inline `data` only) can only be previewed in the current conversation and cannot be added to dashboards or reused elsewhere.
## Revising and Troubleshooting
Update the input JSON and rerun the command with the same `name` to overwrite the file. The generated `.chart.json` is the formal definition—reference it directly and never hand-edit it. If validation reports `MISSING_FIELDS`, `MISSING_QUARTILE_COLUMNS`, `PERCENT_SCALE_REQUIRED`, missing regions, or schema errors, fix the named role or source data and rerun.