feat: improve color consistency (save all labels) (#19038)

This commit is contained in:
Stephen Liu
2022-03-21 15:20:04 +08:00
committed by GitHub
parent e1d0b83885
commit dc575080d7
68 changed files with 690 additions and 137 deletions

View File

@@ -156,13 +156,23 @@ export class ExploreChartHeader extends React.PureComponent {
if (dashboard && dashboard.json_metadata) {
// setting the chart to use the dashboard custom label colors if any
const labelColors =
JSON.parse(dashboard.json_metadata).label_colors || {};
const metadata = JSON.parse(dashboard.json_metadata);
const sharedLabelColors = metadata.shared_label_colors || {};
const customLabelColors = metadata.label_colors || {};
const mergedLabelColors = {
...sharedLabelColors,
...customLabelColors,
};
const categoricalNamespace =
CategoricalColorNamespace.getNamespace();
Object.keys(labelColors).forEach(label => {
categoricalNamespace.setColor(label, labelColors[label]);
Object.keys(mergedLabelColors).forEach(label => {
categoricalNamespace.setColor(
label,
mergedLabelColors[label],
metadata.color_scheme,
);
});
}
}