Skip to content

datopian/portaljs / skills/portaljs-add-chart

portaljs-add-chart

Verified

Add a chart (line, bar, area, pie, or scatter) to a dataset's showcase in a PortalJS portal. Installs recharts, writes a reusable Chart component, and renders it in the showcase Views section. Use when visualizing a dataset already registered in datasets.json.

FileKindSize
SKILL.mdskill md4.3 KB
references/reference.mdmarkdown2.2 KB

references/reference.md

View on GitHub
# Add Chart — Reference

Detailed reference for the `portaljs-add-chart` skill. The executable workflow lives in
[`.claude/commands/portaljs-add-chart.md`](https://github.com/datopian/portaljs/blob/main/.claude/commands/portaljs-add-chart.md).

## Chart types

| Type | Uses | Notes |
| --- | --- | --- |
| `line` (default) | X vs one or more numeric Y series | `type="monotone"`, dots hidden. |
| `bar` | X vs one or more numeric Y series | One bar per Y column. |
| `area` | X vs one or more numeric Y series | Filled at 20% opacity. |
| `pie` | `x` → slice name, `y[0]` → slice value | First Y column only. |
| `scatter` | numeric `x` vs numeric `y[0]` | Both axes numeric; first Y only. |

Pie and scatter use only the first Y column. Pass multiple Y columns for multi-series
line, bar, and area charts.

## `<Chart />` props

| Prop | Type | Purpose |
| --- | --- | --- |
| `url` | string | CSV/TSV file under `/public`, e.g. `/data/file.csv`. |
| `data` | `Row[]` | Pre-parsed rows (alternative to `url`). |
| `type` | `line \| bar \| area \| pie \| scatter` | Chart form (default `line`). |
| `x` | string | X-axis / category column key. |
| `y` | `string \| string[]` | One or more numeric column keys to plot. |
| `height` | number | Pixel height (default `320`). |

## Design rationale

- **recharts, not `@portaljs/components`.** The bundled package ships leaflet, vega,
  ag-grid, and pdf.js in one non-tree-shakeable 1.9 MB blob. recharts is ~100 KB gzipped
  and tree-shakes.
- **Numeric coercion.** CSV cells are strings; the component runs `Number()` on every Y
  value. Non-numeric cells become `NaN` and render as gaps.
- **One showcase route, many datasets.** `pages/[owner]/[slug].tsx` renders every dataset,
  so every view is gated on the dataset's `(namespace, slug)`.
- **Client-side rendering.** The chart fetches in the browser like `Table`, so it works
  with static export and needs no server code.

## Troubleshooting

- **`parseCsv` not found** — the portal predates the current template. Copy
  `parseCsv.ts` from `examples/portaljs-catalog/components/ui/`.
- **Chart appears on every dataset** — a view was not gated on `(namespace, slug)`.
- **Large series render slowly** — pre-aggregate above ~2,000 points.
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall