Data Visualization: CSS Utilities & Chart Wrapper (Group A) #44
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.
Uh oh!
There was an error while loading. Please reload this page.
Feature name
Data Visualization: CSS Utilities & Chart Wrapper
Feature area
Component patterns (cards, search, archive layouts, etc.)
Describe the idea
Ship CSS utilities and a
.hds-chartlayout wrapper that implements the Figma Data Visualization spec's UI Shell, color utility classes, D3 integration selectors, tooltip styling, and interaction states. All pure SCSS, feature-flagged behind$hds-enable-dataviz-chart, shipping inside@nasa/hds-core.What's Included
Task A0: SCSS Feature Flag (XS)
Add
$hds-enable-dataviz-chartboolean flag (defaultfalse) gating all Group A output. Follows existing pattern of$hds-enable-datavizfor tokens.Task A1: Categorical Utility Classes + Line Style Utilities (XS,
good-first-issue).hds-dataviz-cat-{n}classes mappingfill,stroke,colorto existing--hds-dataviz-cat-*custom properties via SCSS loop.hds-dataviz-line-dashedand.hds-dataviz-line-dottedwith standardizedstroke-dasharrayvalues.hds-chart rect { rx: 0; ry: 0; }for sharp bar edges per spec_scheme-darkoverridesTask A2: D3 Structural Selectors (S)
.hds-chart .tick line,.hds-chart .domain,.hds-chart .axis texttargeting D3's well-known generated SVG class namesfont-feature-settings: 'tnum'for tabular figures on axis text--hds-color-*tokens for gridlines, axis lines, axis textTask A3:
.hds-chartWrapper — Core Layout (M,needs-figma-values)CSS grid layout shell implementing Figma Architecture → UI Shell. All slots optional — grid collapses gracefully when elements are absent.
Typography classes:
.hds-chart-title— Inter Bold.hds-chart-subtitle— Inter Regular, smaller.hds-chart-description— body or small text.hds-chart-citation— small text, bold "Data source:" label patternControls row:
.hds-chart-controls— flexbox, right-aligned, houses existing HDS icon buttons and form elements.Pre-work: Figma values needed (see Open Questions section below).
Task A4:
.hds-chartWrapper — Responsive Behavior (S)Task A5:
.hds-chartWrapper — Variants and States (S–M).hds-chart--desc-sidemodifier — two-column grid with description beside chart area[aria-busy="true"]centers placeholder in chart area.hds-chartscope:--hds-motion-appear: 1000ms--hds-motion-transition: 500ms--hds-motion-curve: cubic-bezier(0.30, 0, 0.20, 1)<details class="hds-chart-data">element — no JS required, pairs with existing HDS table component.hds-chart-emptyand.hds-chart-errorstates (spec is silent — needs creative decision)Task A6: Tooltip Styling (S,
needs-figma-values).hds-chart-tooltipclass for developer-built tooltip divs (common with D3)_scheme-darkfont-feature-settings: 'tnum'for numeric valuesTask A7: Hover Opacity Interaction (S)
:has(),[data-series]convention, or sibling combinators):has()(no interaction, no breakage)Open Questions Requiring Figma Values
Before implementation, these values need to be extracted from the Figma Data Visualization spec. Alternative approach: map everything to closest existing USWDS type scale / spacing tokens for an "80% good enough" first pass, refine after creative review.
border-top: 0.25rem solid1,1.5,2,3)heading-lgorheading-xlbodyorsmallbodyorsmallsmall, bold labelsmall12pxsquare swatch, USWDSsmalltextDesign Decisions for Contributor
.hds-chart-legendCSS for HTML legends built outside the chart. D3 devs build their own legends anyway. Highcharts/Plotly devs can opt in or keep library-native.0.3for inactive elements — industry standard (Carbon uses0.3, Highcharts defaults0.2).Spec Sections Implemented by Group A
What Group A Cannot Implement (Needs Group B or Docs Only)
Use case / user story
Multiple user stories served:
Primary audience
Front-end developers
Is this already in the HDS Figma library?
✅ Yes — fully specced in HDS Figma
Figma reference
Data Visualization page in HDS Figma — covers Architecture (UI Shell), Look & Feel (Color, Typography, Style, Motion), Interactions, and Accessibility sections.
Implementation maturity
🔍 Seen elsewhere — exists in another design system or library (not NASA)
Prior art details
No other USWDS theme layer has attempted chart CSS utilities. Industry comparisons:
@carbon/charts) — full React/Vue/Angular charting components wrapping D3. Much heavier approach than what we're proposing. Out of scope for CSS-only HDS Core.@shopify/polaris-viz) — same pattern, D3 under the hood.@adobe/react-spectrum-charts) — uses Vega/D3 internally.Our approach is a middle ground: more actionable than token-only systems (SLDS, GOV.UK) but lighter than full component libraries (Carbon, Polaris). The key insight is that D3 generates SVG with predictable, well-known class names (
.tick,.domain,.axis) that CSS can target directly, so a CSS-only design system can meaningfully style D3 chart internals without JavaScript.Relationship to USWDS
Extends USWDS with something it doesn't provide
Potential breaking change?
No — purely additive
Alternatives considered
Group A as proposed hits the 80% sweet spot: consistent layout + color + typography + interactions via CSS, without the maintenance burden of a component library.
Additional context
This is the first of two related ideas. Group A (this idea) ships the CSS foundation. #45 would then ship config files for Highcharts, Plotly, matplotlib, Tableau, and Power BI that encode the same design opinions in each library's native format. Together they cover the full Figma spec for all major audiences.
Audience coverage after Group A ships:
Would you contribute to this?
Yes — I could submit a PR
All reactions