fix(colors): fix color schemes (#13945)
* fix: fix color schemes * fix: tests case
This commit is contained in:
parent
abd4051f7a
commit
e06290663a
|
|
@ -113,7 +113,7 @@ describe('PropertiesModal', () => {
|
|||
const spy = jest.spyOn(modalInstance, 'onMetadataChange');
|
||||
modalInstance.onColorSchemeChange('SUPERSET_DEFAULT');
|
||||
expect(spy).toHaveBeenCalledWith(
|
||||
'{"color_scheme": "SUPERSET_DEFAULT"}',
|
||||
'{"color_scheme": "SUPERSET_DEFAULT", "label_colors": {}}',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import {
|
|||
t,
|
||||
SupersetClient,
|
||||
getCategoricalSchemeRegistry,
|
||||
CategoricalColorNamespace,
|
||||
} from '@superset-ui/core';
|
||||
|
||||
import Modal from 'src/common/components/Modal';
|
||||
|
|
@ -158,6 +159,15 @@ class PropertiesModal extends React.PureComponent {
|
|||
Object.keys(jsonMetadataObj).includes('color_scheme')
|
||||
) {
|
||||
jsonMetadataObj.color_scheme = value;
|
||||
jsonMetadataObj.label_colors = Object.keys(
|
||||
jsonMetadataObj.label_colors ?? {},
|
||||
).reduce(
|
||||
(prev, next) => ({
|
||||
...prev,
|
||||
[next]: CategoricalColorNamespace.getScale(value)(next),
|
||||
}),
|
||||
{},
|
||||
);
|
||||
this.onMetadataChange(jsonStringify(jsonMetadataObj));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue