superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccwilli...@apache.org
Subject [incubator-superset] branch master updated: Deprecate getColorFromSchem (#5937)
Date Sun, 23 Sep 2018 19:47:42 GMT
This is an automated email from the ASF dual-hosted git repository.

ccwilliams pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 6b89b7f  Deprecate getColorFromSchem (#5937)
6b89b7f is described below

commit 6b89b7f8b522e7226f3f5a61ed7f29b3e7d9013a
Author: Krist Wongsuphasawat <krist.wongz@gmail.com>
AuthorDate: Sun Sep 23 12:47:32 2018 -0700

    Deprecate getColorFromSchem (#5937)
---
 .../spec/javascripts/modules/colors_spec.jsx       | 42 +---------------------
 superset/assets/src/modules/colors.js              | 21 -----------
 2 files changed, 1 insertion(+), 62 deletions(-)

diff --git a/superset/assets/spec/javascripts/modules/colors_spec.jsx b/superset/assets/spec/javascripts/modules/colors_spec.jsx
index a91c74f..d1084f5 100644
--- a/superset/assets/spec/javascripts/modules/colors_spec.jsx
+++ b/superset/assets/spec/javascripts/modules/colors_spec.jsx
@@ -1,47 +1,7 @@
 import { expect } from 'chai';
-import { getColorFromScheme, hexToRGB } from '../../../src/modules/colors';
-import { getInstance } from '../../../src/modules/ColorSchemeManager';
-import airbnb from '../../../src/modules/colorSchemes/airbnb';
-import categoricalSchemes from '../../../src/modules/colorSchemes/categorical';
+import { hexToRGB } from '../../../src/modules/colors';
 
 describe('colors', () => {
-  before(() => {
-    // Register color schemes
-    getInstance()
-      .registerScheme('bnbColors', airbnb.bnbColors)
-      .registerMultipleSchemes(categoricalSchemes)
-      .setDefaultSchemeName('bnbColors');
-  });
-  it('default to bnbColors', () => {
-    const color1 = getColorFromScheme('CA');
-    expect(airbnb.bnbColors).to.include(color1);
-  });
-  it('getColorFromScheme series with same scheme should have the same color', () => {
-    const color1 = getColorFromScheme('CA', 'bnbColors');
-    const color2 = getColorFromScheme('CA', 'googleCategory20c');
-    const color3 = getColorFromScheme('CA', 'bnbColors');
-    const color4 = getColorFromScheme('NY', 'bnbColors');
-
-    expect(color1).to.equal(color3);
-    expect(color1).to.not.equal(color2);
-    expect(color1).to.not.equal(color4);
-  });
-  it('getColorFromScheme forcing colors persists through calls', () => {
-    expect(getColorFromScheme('boys', 'bnbColors', 'blue')).to.equal('blue');
-    expect(getColorFromScheme('boys', 'bnbColors')).to.equal('blue');
-    expect(getColorFromScheme('boys', 'googleCategory20c')).to.not.equal('blue');
-
-    expect(getColorFromScheme('girls', 'bnbColors', 'pink')).to.equal('pink');
-    expect(getColorFromScheme('girls', 'bnbColors')).to.equal('pink');
-    expect(getColorFromScheme('girls', 'googleCategory20c')).to.not.equal('pink');
-  });
-  it('getColorFromScheme is not case sensitive', () => {
-    const c1 = getColorFromScheme('girls', 'bnbColors');
-    const c2 = getColorFromScheme('Girls', 'bnbColors');
-    const c3 = getColorFromScheme('GIRLS', 'bnbColors');
-    expect(c1).to.equal(c2);
-    expect(c3).to.equal(c2);
-  });
   it('hexToRGB converts properly', () => {
     expect(hexToRGB('#FFFFFF')).to.have.same.members([255, 255, 255, 255]);
     expect(hexToRGB('#000000')).to.have.same.members([0, 0, 0, 255]);
diff --git a/superset/assets/src/modules/colors.js b/superset/assets/src/modules/colors.js
index 43025dc..0c23d40 100644
--- a/superset/assets/src/modules/colors.js
+++ b/superset/assets/src/modules/colors.js
@@ -1,5 +1,4 @@
 import d3 from 'd3';
-import { getScale } from './CategoricalColorNamespace';
 import sequentialSchemes from './colorSchemes/sequential';
 import airbnb from './colorSchemes/airbnb';
 import lyft from './colorSchemes/lyft';
@@ -19,26 +18,6 @@ export function hexToRGB(hex, alpha = 255) {
   return [r, g, b, alpha];
 }
 
-/**
- * Get a color from a scheme specific palette (scheme)
- * The function cycles through the palette while memoizing labels
- * association to colors. If the function is called twice with the
- * same string, it will return the same color.
- *
- * @param {string} s - The label for which we want to get a color
- * @param {string} scheme - The palette name, or "scheme"
- * @param {string} forcedColor - A color that the caller wants to
- forcibly associate to a label.
- */
-export function getColorFromScheme(value, schemeName, forcedColor) {
-  const scale = getScale(schemeName);
-  if (forcedColor) {
-    scale.setColor(value, forcedColor);
-    return forcedColor;
-  }
-  return scale.getColor(value);
-}
-
 export const colorScalerFactory = function (colors, data, accessor, extents, outputRGBA =
false) {
   // Returns a linear scaler our of an array of color
   if (!Array.isArray(colors)) {


Mime
View raw message