Skip to content

feat(#612): Intelligent Color Scheme Generation for data visualizations#708

Open
temi-Dee wants to merge 1 commit into
Nanle-code:masterfrom
temi-Dee:feature/612-intelligent-color-scheme
Open

feat(#612): Intelligent Color Scheme Generation for data visualizations#708
temi-Dee wants to merge 1 commit into
Nanle-code:masterfrom
temi-Dee:feature/612-intelligent-color-scheme

Conversation

@temi-Dee

Copy link
Copy Markdown

Summary

Implements issue #612 — AI/ML-assisted intelligent color scheme generation for data visualizations.

Changes

New: src/lib/intelligentColorScheme.ts

Core generator class IntelligentColorSchemeGenerator with:

  • Color theory palette generation: complementary, analogous, triadic, split-complementary, tetradic, and monochromatic harmonies
  • WCAG accessibility checking: reuses calculateContrastRatio / getWCAGLevel from themeTypes.ts; configurable minimum WCAG level
  • Preference learning: records user scheme selections to localStorage with recency-weighted exponential decay
  • Data-characteristic awareness: tailored lightness/saturation profiles for categorical, sequential, and diverging data
  • enforceAccessibility(): adjusts colors that fail the target contrast ratio
  • Synchronous generation: consistently < 50 ms

New: src/hooks/useColorScheme.ts

React hook exposing scheme, allSchemes, regenerate(), applyScheme(), enforceAccessibility().

Modified: src/styles/themeTypes.ts

Added generateChartColorsForTheme() (async) and generateChartColorsForThemeSync() (sync).

Modified: src/hooks/index.ts

Exports useColorScheme from the barrel.

New: tests/unit/lib/intelligentColorScheme.test.ts

48 unit tests — all passing.

Test Results

✓ tests/unit/lib/intelligentColorScheme.test.ts (48 tests) 57ms

Closes #612

Implement AI/ML-assisted color scheme generation for data visualizations.

- Add IntelligentColorSchemeGenerator (src/lib/intelligentColorScheme.ts)
  - Color theory–based palette generation: complementary, analogous, triadic,
    split-complementary, tetradic, monochromatic harmonies
  - WCAG accessibility constraint checking via themeTypes helpers
  - Preference learning via localStorage (tracks selections to bias future
    recommendations with recency-weighted exponential decay)
  - Data-characteristic aware generation: categorical, sequential, diverging
  - Synchronous, deterministic, sub-50ms generation
  - enforceAccessibility() method to adjust colors to meet WCAG target
  - generateChartColors() helper for drop-in chart integration

- Add useColorScheme React hook (src/hooks/useColorScheme.ts)
  - Wraps the generator with React state
  - Exposes regenerate(), applyScheme(), enforceAccessibility()
  - Syncs preferences on window focus

- Integrate with themeTypes.ts
  - generateChartColorsForTheme() (async, uses the full generator)
  - generateChartColorsForThemeSync() (sync, suitable for rendering hot paths)

- Export useColorScheme from src/hooks/index.ts barrel

- Add 48 unit tests (all passing, < 50ms generation verified)

Closes Nanle-code#612
@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

@temi-Dee is attempting to deploy a commit to the nanle-code's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@temi-Dee Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intelligent Color Scheme Generation

1 participant