mirror of
https://github.com/apache/superset.git
synced 2026-04-20 16:44:46 +00:00
[Refactor] Extend color scheme management to sequential schemes (#6150)
* refactor color scheme * Update data structure * Update color scheme files * wip * convert all sequential schemes * Update how color schemes are managed. Extend it for sequential schemes * extract color setup into separate file * Update imports * update imports * Add new functions to Registry * Update ColorSchemeManager to extends Registry and update unit tests * Add test for Registry * Rename ColorSchemeManager to ColorSchemeRegistry * Fix unit tests * Update API * Fix imports * Add label field * Fix reference to colors * update SequentialScheme contructor * Fix controls * rename manager to registry * Split sequential schemes into multiple files * update sequential color labels * add values and valuesAsPromise() * use .values()
This commit is contained in:
committed by
Chris Williams
parent
a71e6eb0a3
commit
b9257b2a09
@@ -7,7 +7,8 @@ import { SketchPicker } from 'react-color';
|
||||
import ColorPickerControl from
|
||||
'../../../../src/explore/components/controls/ColorPickerControl';
|
||||
import ControlHeader from '../../../../src/explore/components/ControlHeader';
|
||||
import { registerScheme } from '../../../../src/modules/ColorSchemeManager';
|
||||
import getCategoricalSchemeRegistry from '../../../../src/modules/colors/CategoricalSchemeRegistrySingleton';
|
||||
import CategoricalScheme from '../../../../src/modules/colors/CategoricalScheme';
|
||||
|
||||
const defaultProps = {
|
||||
value: { },
|
||||
@@ -17,7 +18,11 @@ describe('ColorPickerControl', () => {
|
||||
let wrapper;
|
||||
let inst;
|
||||
beforeEach(() => {
|
||||
registerScheme('test', ['red', 'green', 'blue'])
|
||||
getCategoricalSchemeRegistry()
|
||||
.registerValue('test', new CategoricalScheme({
|
||||
name: 'test',
|
||||
colors: ['red', 'green', 'blue'],
|
||||
}))
|
||||
.setDefaultSchemeName('test');
|
||||
wrapper = shallow(<ColorPickerControl {...defaultProps} />);
|
||||
inst = wrapper.instance();
|
||||
|
||||
@@ -5,10 +5,10 @@ import { Creatable } from 'react-select';
|
||||
|
||||
import ColorSchemeControl from
|
||||
'../../../../src/explore/components/controls/ColorSchemeControl';
|
||||
import { getAllSchemes } from '../../../../src/modules/ColorSchemeManager';
|
||||
import getCategoricalSchemeRegistry from '../../../../src/modules/colors/CategoricalSchemeRegistrySingleton';
|
||||
|
||||
const defaultProps = {
|
||||
options: Object.keys(getAllSchemes()).map(s => ([s, s])),
|
||||
options: getCategoricalSchemeRegistry().keys().map(s => ([s, s])),
|
||||
};
|
||||
|
||||
describe('ColorSchemeControl', () => {
|
||||
|
||||
Reference in New Issue
Block a user