Data Visualization: Token Bridge & Library Theme Configs (Group B) #45
abbybowman
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Feature name
Data Visualization: Token Bridge & Library Theme Configs
Feature area
Design tokens (colors, typography, spacing)
Describe the idea
Ship
hds-dataviz-tokens.mjsas the single source of truth for all dataviz design values, plus config/theme files for Highcharts, Plotly, matplotlib, Tableau, and Power BI. Files live in athemes/directory within@nasa/hds-core, accessible via npm subpath exports (JS consumers) or direct download (Python/BI consumers).Architecture
Source of truth flow:
All downstream configs are mechanical translations of the same values in different formats.
Packaging — subpath exports (decided):
{ "exports": { ".": "./scss/index.scss", "./themes/tokens": "./themes/hds-dataviz-tokens.mjs", "./themes/highcharts": "./themes/hds-highcharts-theme.js", "./themes/plotly": "./themes/hds-plotly-template.json", "./themes/matplotlib": "./themes/hds.mplstyle", "./themes/tableau": "./themes/hds-tableau.tps", "./themes/powerbi": "./themes/hds-powerbi.json" }, "files": ["scss/**", "themes/**"] }What's Included
Task B0: Package Architecture — Subpath Exports (S)
themes/directoryexportsmappings topackage.jsonthemes/**tofilesarrayTask B1:
hds-dataviz-tokens.mjs(S)Single source of truth ES module. All other Group B files derive from this.
Hex values from
DataVisualizationPalettes.stories.js(existing source of truth).Pre-work: Extract diverging palette combinations from Figma (which 3 hue pairings, step counts, midpoint color).
Task B2:
hds.mplstyle— matplotlib (XS,good-first-issue)Standard matplotlib rcParams file (~30 lines):
Consumer usage:
Depends on B1 for canonical values.
Task B3:
hds-highcharts-theme.js(S)Highcharts
setOptions()config (~50 lines):Consumer usage:
Pre-work: Pin supported version (recommend Highcharts 11+). Depends on B1.
Task B4:
hds-plotly-template.json(S)Plotly template (~80 lines). Works for both Plotly.js and Plotly.py:
{ "layout": { "colorway": ["#hex1", "#hex2"], "font": { "family": "Public Sans, sans-serif" }, "title": { "font": { "family": "Inter, sans-serif", "weight": "bold" } }, "xaxis": { "gridcolor": "#hex", "linecolor": "#hex" }, "yaxis": { "gridcolor": "#hex", "linecolor": "#hex" }, "bargap": 0.5, "transition": { "duration": 500 } } }Consumer usage (JS):
Consumer usage (Python):
Pre-work: Pin supported version (recommend Plotly 5+). Depends on B1.
Task B5:
hds-tableau.tps(XS)Tableau XML theme file (~40 lines):
Note: Tableau
.tpscontrols color palettes only. Font/axis styling requires manual formatting — document on Storybook setup page.Consumer usage:
My Tableau Repository/Preferences.tpsDepends on B1.
Task B6:
hds-powerbi.json(XS)Power BI JSON theme (~60 lines):
{ "name": "HDS Core", "dataColors": ["#hex1", "...12 categorical"], "textClasses": { "title": { "fontFace": "Inter, Segoe UI, sans-serif", "fontWeight": "bold" }, "label": { "fontFace": "Public Sans, Segoe UI, sans-serif" }, "callout": { "fontFace": "DM Mono, Consolas, monospace" } } }Note: Fonts must be available on user's machine or Power BI Service environment. Document Segoe UI as fallback on Storybook setup page.
Consumer usage:
Depends on B1.
Pre-Work Before Building
.tpsformatStorybook Documentation Deliverables
setOptions()code, before/afterplt.style.use()code, example output, font noteThese pages live alongside the existing React Setup page and can be linked directly.
Use case / user story
Multiple user stories:
Highcharts developer (6 known sites — giovanni, fermi, gs671-suske, hitide, neoproperties, oltaris):
As a developer maintaining a Highcharts dashboard on a NASA science site, I want to import
@nasa/hds-core/themes/highchartsand callHighcharts.setOptions(hdsTheme)so that all my charts (colors, fonts, gridlines, bar spacing, tooltips, animation) match HDS standards with a single line of code.matplotlib / Jupyter scientist (large hidden audience behind JupyterHub):
As a scientist generating charts in Jupyter notebooks, I want to call
plt.style.use('hds')so that every chart I produce — in notebooks, papers, and dashboards — uses NASA's official colors and typography without manually setting them on each plot.Plotly.py scientist:
As a scientist building interactive Plotly charts in Python, I want to apply an HDS template so my visualizations match the design system whether they're viewed in a notebook, embedded on a web page, or exported to an image.
Tableau analyst (large internal audience):
As a data analyst building Tableau dashboards for NASA stakeholders, I want to import an HDS color palette into Tableau Desktop so that all my visualizations use consistent, accessible, on-brand colors without manually entering hex codes.
Power BI analyst:
As an analyst creating Power BI reports, I want to apply an HDS theme file so that my reports use official NASA colors and typography, and so that my organization's admin can push this theme to all users centrally.
D3 developer needing resolved values:
As a D3 developer who needs hex values for canvas rendering or image export (where CSS custom properties don't resolve), I want to import color arrays from
@nasa/hds-core/themes/tokensso I have a single source of truth that stays in sync with the SCSS tokens.Primary audience
Other (describe in your use case above)
Is this already in the HDS Figma library?
✅ Yes — fully specced in HDS Figma
Figma reference
Data Visualization page — Color (palettes), Typography (font use, hierarchy), Style (bar gaps, border widths, line styles), Motion (animation timing), Architecture (axis/gridline styling).
Implementation maturity
🔍 Seen elsewhere — exists in another design system or library (not NASA)
Prior art details
@carbon/chartswraps D3 in components. Much heavier than config files.@shopify/polaris-tokens) — uses npm subpath exports for different output formats (CSS, JSON). Our packaging approach follows this model.plt.style.use('ggplot'),plt.style.use('seaborn')etc. demonstrate the.mplstylepattern is well-established and familiar to scientists.highcharts/themes/dark-unica.jsetc. demonstrate thesetOptions()theme pattern.Audience validated via Wappalyzer scan (March 2025) of ~97 NASA sites with JavaScript graphics detected. ~18-20 use actual charting libraries: D3 (10, 43%), Highcharts (6, 26%), Chart.js (3-4, 15%), Plotly (3, 13%), Bokeh (2, 9%). These numbers significantly undercount: Wappalyzer can't detect libraries behind reverse proxies, JupyterHub, or Tableau/Power BI platforms. The Python/BI audience is estimated 10-50× larger than what's visible in web scans.
Relationship to USWDS
Extends USWDS with something it doesn't provide
Potential breaking change?
No — purely additive
Alternatives considered
@nasa/hds-dataviz-themes) — Monorepo with independent versioning. Trade-off: cleaner separation but adds monorepo tooling complexity, two publish processes, and friction for consumers who need two npm installs. Decided against for now — can migrate later if scale justifies it.Additional context
This is the second of two related ideas. #44ships the CSS foundation. Group B (this idea) ships config files that encode the same design opinions in each library's native format. Together they implement the full Figma Data Visualization spec across all major audiences.
Audience coverage — incremental over Group A:
Chart.js and Bokeh dedicated configs are deferred to the Ideas backlog — build when adoption signal grows.
Permanently underserved:
Would you contribute to this?
Partially — I could help with design/research/testing
All reactions