villebro commented on a change in pull request #12210:
URL:
https://github.com/apache/incubator-superset/pull/12210#discussion_r551863593
##########
File path: docs/src/pages/docs/frequently-asked-questions-page.mdx
##########
@@ -232,6 +232,29 @@ Metadata attribute using the `label_colors` key.
}
```
+### Is there a way to add custom color schemes?
+
+It is possible to override SETUP_EXTRA with COLOR_SCHEMES to register new
color schemes
+
+```
+SETUP_EXTRA = {"COLOR_SCHEMES": [
+ {
+ "id": 'myCustomColors',
+ "schemeType": 'Categorical', //Categorical or Sequential
+ "description": '',
+ "label": 'My custom Colors',
+ "colors": ['#6BD3B3', '#6BD3B3', '#6BD3B3', '#66CBE2']
+ }]
+}
+.
+.
+.
+schemes.forEach(scheme => {
+ categoricalSchemeRegistry.registerValue(scheme.id, scheme);
+});
Review comment:
Is this needed here? The FAQ should probably explain that the change
should be done in `superset_config.py`.
##########
File path: docs/src/pages/docs/frequently-asked-questions-page.mdx
##########
@@ -232,6 +232,29 @@ Metadata attribute using the `label_colors` key.
}
```
+### Is there a way to add custom color schemes?
+
+It is possible to override SETUP_EXTRA with COLOR_SCHEMES to register new
color schemes
+
+```
+SETUP_EXTRA = {"COLOR_SCHEMES": [
+ {
+ "id": 'myCustomColors',
+ "schemeType": 'Categorical', //Categorical or Sequential
+ "description": '',
+ "label": 'My custom Colors',
+ "colors": ['#6BD3B3', '#6BD3B3', '#6BD3B3', '#66CBE2']
+ }]
+}
Review comment:
`SETUP_EXTRA` feels ambiguous, and will be difficult/disruptive to
change once introduced. Perhaps break this up into `EXTRA_COLOR_SCHEMES` or
even `EXTRA_CATEGORICAL_COLOR_SCHEMES` and `EXTRA_SEQUENTIAL_COLOR_SCEHEMES`
would make sense?
##########
File path: superset-frontend/src/preamble.ts
##########
@@ -20,6 +20,7 @@ import { setConfig as setHotLoaderConfig } from
'react-hot-loader';
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';
import moment from 'moment';
import { configure } from '@superset-ui/core';
+import ColorScheme from '@superset-ui/core/lib/color/ColorScheme';
Review comment:
We should probably export this (and other related ones) in
`@superset-ui/core`.
##########
File path: superset-frontend/src/preamble.ts
##########
@@ -49,7 +52,17 @@ if (typeof window !== 'undefined') {
setupClient();
// Setup color palettes
-setupColors();
+let color_schemas: ColorScheme[] = [];
+
+if (
+ bootstrapData.common &&
+ bootstrapData.common.setup_extra &&
+ bootstrapData.common.setup_extra.COLOR_SCHEMES
+) {
+ color_schemas = bootstrapData.common.setup_extra.COLOR_SCHEMES;
+}
+
+setupColors(color_schemas);
Review comment:
Nit:
```suggestion
let color_schemes: ColorScheme[] = [];
if (
bootstrapData.common &&
bootstrapData.common.setup_extra &&
bootstrapData.common.setup_extra.COLOR_SCHEMES
) {
color_schemes = bootstrapData.common.setup_extra.COLOR_SCHEMES;
}
setupColors(color_schemes);
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]