Skip to content

Commit

Permalink
fix(colors): fix color schemes (#13945)
Browse files Browse the repository at this point in the history
* fix: fix color schemes

* fix: tests case
  • Loading branch information
simcha90 authored Apr 4, 2021
1 parent abd4051 commit e062906
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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": {}}',
);
});
});
Expand Down
10 changes: 10 additions & 0 deletions superset-frontend/src/dashboard/components/PropertiesModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
t,
SupersetClient,
getCategoricalSchemeRegistry,
CategoricalColorNamespace,
} from '@superset-ui/core';

import Modal from 'src/common/components/Modal';
Expand Down Expand Up @@ -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));
}

Expand Down

0 comments on commit e062906

Please sign in to comment.