You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/02/16 18:18:00 UTC

[GitHub] [superset] geido commented on a change in pull request #17792: feat: improve color consistency

geido commented on a change in pull request #17792:
URL: https://github.com/apache/superset/pull/17792#discussion_r808305389



##########
File path: superset-frontend/packages/superset-ui-core/src/color/SharedLabelColorSingleton.ts
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { CategoricalColorNamespace } from '.';
+import makeSingleton from '../utils/makeSingleton';
+
+export class SharedLabelColor {
+  values: string[];
+
+  valueSliceMap: Record<string, number[]>;
+
+  constructor() {
+    // save all shared label value
+    this.values = [];
+    // { value1: [sliceId1, sliceId2], value2: [sliceId], ...}
+    this.valueSliceMap = {};
+  }
+
+  getColorMap(colorNamespace?: string, colorScheme?: string) {
+    if (colorScheme) {
+      const categoricalNamespace = CategoricalColorNamespace.getNamespace(
+        colorNamespace || '',

Review comment:
       I think I saw in the CategoricalColorNamespace that the default namespace in use is `GLOBAL`. I think we should use that instead of empty string here.

##########
File path: superset-frontend/src/dashboard/actions/dashboardState.js
##########
@@ -474,6 +480,21 @@ export function addSliceToDashboard(id, component) {
       if (selectedSlice && selectedSlice.viz_type === 'filter_box') {
         dispatch(addFilter(id, component, selectedSlice.form_data));
       }
+
+      setTimeout(() => {

Review comment:
       You told me about this timeout but the more I think about it the more I am concerned that it might fail in a few instances, especially in large dashboards. We should probably look into how the dashboard should signal that all charts have finished querying. I think this is important for other use cases as well. @rusackas what do you think?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org