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 2019/09/03 09:28:48 UTC

[GitHub] [incubator-superset] breizh24 commented on issue #5420: Superset how to support custom add Color Scheme?

breizh24 commented on issue #5420: Superset how to support custom add Color Scheme?
URL: https://github.com/apache/incubator-superset/issues/5420#issuecomment-527380844
 
 
   @ilyakam To add custom schemes, in case of a "Categorical Scheme" you need to import the CategoricalScheme class from the module "@superset-ui/color", here is an example:
   
   ```javascript
   import { CategoricalScheme } from '@superset-ui/color';
   
   const schemes = [
     {
       id: 'testColors',
       label: 'Test Colors',
       colors: ['#2d51a3', '#7d7f82', '#2061e0', '000000'],
     },
   ].map(s => new CategoricalScheme(s));
   
   export default schemes;
   ```
   
   then you need to import this into /superset/assets/src/setup/setupColors.js and add it to the already existing schemes, you should end up with something like this:
   
   ```javascript
   import testColors from '../myColors/myColorSchemes';
   
   export default function setupColors() {
     // Register color schemes
     const categoricalSchemeRegistry = getCategoricalSchemeRegistry();
     [airbnb, categoricalD3, google, lyft, testColors].forEach((group) => {
       group.forEach((scheme) => {
         categoricalSchemeRegistry.registerValue(scheme.id, scheme);
       });
     });
     categoricalSchemeRegistry.setDefaultKey('bnbColors');
   
   ```
   
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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