From 633df3dd9f1fcc07e643a5690c36d4cb412883a9 Mon Sep 17 00:00:00 2001 From: David Aaron Suddjian Date: Thu, 16 Dec 2021 16:34:50 -0800 Subject: [PATCH] fix: process color scheme configs correctly --- .../superset-ui-core/src/color/index.ts | 4 ++++ superset-frontend/src/setup/setupColors.ts | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/superset-frontend/packages/superset-ui-core/src/color/index.ts b/superset-frontend/packages/superset-ui-core/src/color/index.ts index f81fcbba72b64..0f7ce6194c6e3 100644 --- a/superset-frontend/packages/superset-ui-core/src/color/index.ts +++ b/superset-frontend/packages/superset-ui-core/src/color/index.ts @@ -22,9 +22,13 @@ import * as CategoricalColorNamespace from './CategoricalColorNamespace'; export { CategoricalColorNamespace }; export { default as CategoricalColorScale } from './CategoricalColorScale'; export { default as CategoricalScheme } from './CategoricalScheme'; +export * from './CategoricalScheme'; export { default as getCategoricalSchemeRegistry } from './CategoricalSchemeRegistrySingleton'; +export { default as ColorScheme } from './ColorScheme'; +export * from './ColorScheme'; export { default as getSequentialSchemeRegistry } from './SequentialSchemeRegistrySingleton'; export { default as SequentialScheme } from './SequentialScheme'; +export * from './SequentialScheme'; export { default as ColorSchemeRegistry } from './ColorSchemeRegistry'; export * from './colorSchemes'; export * from './utils'; diff --git a/superset-frontend/src/setup/setupColors.ts b/superset-frontend/src/setup/setupColors.ts index 7865e4b2a0ff6..01122243ce0eb 100644 --- a/superset-frontend/src/setup/setupColors.ts +++ b/superset-frontend/src/setup/setupColors.ts @@ -18,9 +18,12 @@ */ import { CategoricalScheme, + ColorScheme, + ColorSchemeConfig, getCategoricalSchemeRegistry, getSequentialSchemeRegistry, SequentialScheme, + SequentialSchemeConfig, CategoricalAirbnb, CategoricalD3, CategoricalEcharts, @@ -33,9 +36,9 @@ import { ColorSchemeRegistry, } from '@superset-ui/core'; -function registerColorSchemes( - registry: ColorSchemeRegistry, - colorSchemes: (CategoricalScheme | SequentialScheme)[], +function registerColorSchemes( + registry: ColorSchemeRegistry, + colorSchemes: T[], standardDefaultKey: string, ) { colorSchemes.forEach(scheme => { @@ -48,9 +51,15 @@ function registerColorSchemes( } export default function setupColors( - extraCategoricalColorSchemes: CategoricalScheme[] = [], - extraSequentialColorSchemes: SequentialScheme[] = [], + extraCategoricalColorSchemeConfigs: ColorSchemeConfig[] = [], + extraSequentialColorSchemeConfigs: SequentialSchemeConfig[] = [], ) { + const extraCategoricalColorSchemes = extraCategoricalColorSchemeConfigs.map( + config => new CategoricalScheme(config), + ); + const extraSequentialColorSchemes = extraSequentialColorSchemeConfigs.map( + config => new SequentialScheme(config), + ); registerColorSchemes( // @ts-ignore getCategoricalSchemeRegistry(),