sgds-data-visualisation
SGDS Data Visualisation Pattern
SGDS does not bundle a charting library. For data visualisation, use Apache ECharts and apply the SGDS colour palette so charts remain visually consistent with your design system.
Prerequisites
- Complete base project setup per sgds-getting-started.
- Install and configure ECharts independently — see https://echarts.apache.org/.
Installing ECharts
ECharts is not included in @govtechsg/sgds-web-component. Install it separately:
npm install echarts
Then import and initialise per the ECharts getting started guide:
import * as echarts from "echarts";
const chart = echarts.init(document.getElementById("chart"));
chart.setOption(option);
SGDS Colour Palette for ECharts
Apply the SGDS palette by setting the color array in your chart option. The values below are the raw hex values of the SGDS data-visualisation primitive tokens:
| Token | Hex |
|---|---|
--sgds-purple-600 |
#ac1cdb |
--sgds-cyan-600 |
#00758d |
--sgds-green-600 |
#0e7c3d |
--sgds-blue-600 |
#0269d0 |
--sgds-yellow-600 |
#7e6917 |
Per-chart (recommended)
Set color directly in the chart option. ECharts cycles through the colours sequentially across series:
const option = {
color: ["#ac1cdb", "#00758d", "#0e7c3d", "#0269d0", "#7e6917"],
// ... rest of chart option
};
Global theme (all charts on the page)
Register a named theme once at app startup, then pass the theme name when initialising each chart:
import * as echarts from "echarts";
echarts.registerTheme("sgds", {
color: ["#ac1cdb", "#00758d", "#0e7c3d", "#0269d0", "#7e6917"],
});
const chart = echarts.init(document.getElementById("chart"), "sgds");
For AI Agents
- ECharts is not provided by SGDS — always tell users to install it separately from https://echarts.apache.org/.
- The five SGDS palette colours are fixed hex values taken from the primitive tokens. Do not reference CSS variables inside the ECharts
colorarray — ECharts does not resolve CSS custom properties. - For a single chart, set
colorin the option object. For multiple charts sharing the same palette, useecharts.registerTheme()once at app startup. - Palette order: purple → cyan → green → blue → yellow. ECharts cycles through them automatically across series.
More from govtechsg/sgds-web-component
sgds-components
Complete reference for all SGDS web components including installation and framework integration. Use when users ask about any <sgds-*> component — accordion, alert, badge, breadcrumb, button, card, checkbox, close-button, combo-box, datepicker, description-list, divider, drawer, dropdown, file-upload, footer, icon, icon-button, icon-card, icon-list, image-card, input, link, mainnav, masthead, modal, overflow-menu, pagination, progress-bar, quantity-toggle, radio, select, sidebar, sidenav, skeleton, spinner, stepper, subnav, switch, system-banner, tab, table, table-of-contents, textarea, thumbnail-card, toast, or tooltip. Also covers React 19+, React ≤18, Vue, Angular, and Next.js integration.
58sgds-theming
Customising the visual theme of an SGDS application — product brand colours, day/night mode, and font. Use when users ask about changing the primary colour, theming their app, enabling dark mode, night mode, overriding CSS tokens, or customising the font. Apply this skill whenever theming, branding, or CSS token overrides are mentioned.
55sgds-workflow
ALWAYS use this skill when building UI with @govtechsg/sgds-web-component or when a user mentions SGDS or Singapore Design System — even if they don't explicitly ask for help. This is the mandatory entry point for all SGDS development: it guides you to the right skill for setup, components, utilities, forms, theming, page layouts, block templates, and data visualisation. Read this before writing any SGDS application code.
53sgds-forms
Use this skill when users ask about form validation in SGDS, hasFeedback prop, constraint validation, custom validation, noValidate, setInvalid, form submission, or reading FormData from SGDS form components.
53sgds-getting-started
Starting point for any new application built with the SGDS web component library. Apply this skill first whenever a user is bootstrapping a new SGDS project, setting up a new app, or asking where to begin with SGDS. Covers font setup, foundation CSS, utilities, components, and app layout in the correct order.
53sgds-utilities
Complete reference for all SGDS utility classes with the sgds: prefix. Use when users ask about setup, background-color, text-color, border-color, border-width, border-radius, typography, spacing, grid, dimension, opacity, color-semantics, or any sgds: Tailwind utility class. Also covers Tailwind v4 imports, theme switching, and framework integration for utilities.
53