{"data":{"slug":"github-datopian-portaljs-skills-portaljs-add-chart-893227f0438d","title":"PortalJS \u2014 Add Chart","summary":"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.","url":"https:\/\/skillshunter.net\/skills\/github-datopian-portaljs-skills-portaljs-add-chart-893227f0438d","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-datopian-portaljs-skills-portaljs-add-chart-893227f0438d","markdown_url":"https:\/\/skillshunter.net\/skills\/github-datopian-portaljs-skills-portaljs-add-chart-893227f0438d.md","download_url":"https:\/\/skillshunter.net\/skills\/github-datopian-portaljs-skills-portaljs-add-chart-893227f0438d\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Prerequisites: A scaffolded PortalJS portal, the target dataset already registered in datasets.json, `components\/ui\/parseCsv.ts` present, and Node 18+ and npm available in the portal directory. The user must choose a dataset slug, X column, Y column(s), and chart type (default `line`).","instructions":"---\nname: portaljs-add-chart\ndescription: 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.\nallowed-tools: Read, Write, Edit, Bash(npm:*), Bash(npx:*)\nversion: 1.0.0\nauthor: Datopian <hello@datopian.com>\nlicense: MIT\ncompatibility: Claude Code with PortalJS portals (Next.js 14, React 18, Node 18+). Runs from any project via the plugin, a personal ~\/.claude\/commands install, or a portaljs clone.\ntags:\n  - portaljs\n  - data-portal\n  - chart\n  - recharts\n  - dataviz\n  - nextjs\n---\n\n# PortalJS \u2014 Add Chart\n\n## Overview\n\nAdd a visualization to a dataset's **showcase** in a PortalJS portal. The skill installs\n`recharts` (added directly \u2014 never `@portaljs\/components`), writes a reusable client-side\n`Chart` component into `components\/`, and renders a `<Chart \/>` into the **Views** section\nof the showcase route `pages\/[owner]\/[slug].tsx` for one chosen dataset. The chart reads the\nsame `\/public\/data\/<file>` the showcase `<Table \/>` already uses, so no data is duplicated.\nFive chart types are supported: line, bar, area, pie, and scatter.\n\n## Prerequisites\n\n- A scaffolded PortalJS portal (see `portaljs-new-portal`).\n- The target dataset already registered in `datasets.json` (see `portaljs-add-dataset`).\n- `components\/ui\/parseCsv.ts` present (ships with the template).\n- Node 18+ and npm available in the portal directory.\n\n## Instructions\n\nThe canonical, full step-by-step workflow is\n[`.claude\/commands\/portaljs-add-chart.md`](https:\/\/github.com\/datopian\/portaljs\/blob\/main\/.claude\/commands\/portaljs-add-chart.md) \u2014\nthe single source of truth. Read and follow it when executing. Summary:\n\n1. Gather input \u2014 dataset slug, X column, Y column(s), chart type (default `line`), portal\n   directory. If any is missing, interview the user; never dead-end on a missing value.\n2. Resolve the dataset from `datasets.json` (`namespace`, `file`, `format`).\n3. Validate that the X and every Y column exist in the data file's header; warn on\n   non-numeric Y columns (values are coerced with `Number()`).\n4. Install the chart library: `npm install recharts@^2.15.0`.\n5. Write `components\/Chart.tsx` (idempotent \u2014 do not overwrite a customized component).\n6. Render `<Chart \/>` into the Views section, gated on the dataset's `(namespace, slug)` so\n   other showcases are unaffected. Extend an existing view-dispatch block, do not overwrite.\n7. Verify with `npx tsc --noEmit`.\n8. Report the component, route, and dependency added.\n\n## Output\n\n- **Created:** `components\/Chart.tsx` (recharts wrapper, if absent).\n- **Modified:** `pages\/[owner]\/[slug].tsx` (import + gated `<Chart \/>` in Views);\n  `package.json` (`recharts@^2.15.0`).\n- **UI strings:** any text it adds to JSX renders through `t()` (`lib\/i18n.ts`), with the\n  keys added to `locales\/en.json` and every other `locales\/*.json`; `npm run i18n:check`\n  passes.\n- **Verified:** `npx tsc --noEmit` passes.\n- **Result:** the chart renders at `\/@<namespace>\/<slug>` under a \"Views\" heading.\n\n## Error Handling\n\n| Symptom | Cause | Fix |\n| --- | --- | --- |\n| Missing dataset\/columns | Slug or column not in manifest\/header | List available slugs\/headers and re-prompt; do not error out. |\n| Gaps in the chart | Non-numeric cells coerced to `NaN` | Clean the source data or pick a numeric Y column. |\n| `tsc` failure | Bad column prop or import path | Fix the first reported error before reporting success. |\n| Sluggish render | Over ~2,000 SVG points | Pre-aggregate the series (e.g. yearly buckets). |\n\n## Examples\n\n### Example 1 \u2014 Single line series\n\n```\n\/portaljs-add-chart co2-emissions x=year y=emissions type=line\n```\n\n### Example 2 \u2014 Multi-series bar chart\n\n```\n\/portaljs-add-chart trade x=year y=imports,exports type=bar\n```\n\n### Example 3 \u2014 Pie chart of a categorical breakdown\n\n```\n\/portaljs-add-chart budget x=department y=amount type=pie\n```\n\n## Resources\n\n- Full workflow: [`.claude\/commands\/portaljs-add-chart.md`](https:\/\/github.com\/datopian\/portaljs\/blob\/main\/.claude\/commands\/portaljs-add-chart.md)\n- Chart-type and prop reference: [`references\/reference.md`](references\/reference.md)\n- Related skills: `portaljs-add-dataset`, `portaljs-add-map`, `portaljs-define-schema`\n- recharts documentation: <https:\/\/recharts.org\/>\n","use_cases":["Visualize a dataset's trends with a line chart","Compare multiple metrics with a bar chart","Showcase a categorical breakdown with a pie chart"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/datopian\/portaljs\/blob\/fc7ccd651459549a962c8b7aa08f60f8849fd9a5\/skills\/portaljs-add-chart\/SKILL.md","source_commit":"fc7ccd651459549a962c8b7aa08f60f8849fd9a5","license":"MIT","version":"1.0.0","listing_approved_at":"2026-11-22","created_at":"2026-11-21T15:44:26.000000Z","updated_at":"2026-11-22T11:18:24.000000Z","seo_title":"Add Chart to PortalJS Dataset Showcase","seo_description":"Add a chart to a dataset's showcase in a PortalJS portal. Installs recharts, writes a reusable Chart component, and renders it in the showcase Views section.","seo_keywords":["add chart to portaljs","portaljs chart visualization","recharts chart component","dataset showcase chart","portaljs data visualization"]}}