Skip to content

Commit

Permalink
rename sharedForcedColors to parentForcedColors
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw committed Sep 12, 2018
1 parent 527e244 commit 1cb5d61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ describe('CategoricalColorScale', () => {
expect(CategoricalColorScale !== undefined).to.equal(true);
});

describe('new CategoricalColorScale(colors, sharedForcedColors)', () => {
it('can create new scale when sharedForcedColors is not given', () => {
describe('new CategoricalColorScale(colors, parentForcedColors)', () => {
it('can create new scale when parentForcedColors is not given', () => {
const scale = new CategoricalColorScale(['blue', 'red', 'green']);
expect(scale).to.be.instanceOf(CategoricalColorScale);
});
it('can create new scale when sharedForcedColors is given', () => {
const sharedForcedColors = {};
const scale = new CategoricalColorScale(['blue', 'red', 'green'], sharedForcedColors);
it('can create new scale when parentForcedColors is given', () => {
const parentForcedColors = {};
const scale = new CategoricalColorScale(['blue', 'red', 'green'], parentForcedColors);
expect(scale).to.be.instanceOf(CategoricalColorScale);
expect(scale.sharedForcedColors).to.equal(sharedForcedColors);
expect(scale.parentForcedColors).to.equal(parentForcedColors);
});
});
describe('.getColor(value)', () => {
Expand Down Expand Up @@ -72,7 +72,7 @@ describe('CategoricalColorScale', () => {
scale.setColor('pig', 'pink');
expect(scale.getColor('pig')).to.equal('pink');
});
it('does not override sharedForcedColors', () => {
it('does not override parentForcedColors', () => {
const scale1 = new CategoricalColorScale(['blue', 'red', 'green']);
scale1.setColor('pig', 'black');
const scale2 = new CategoricalColorScale(['blue', 'red', 'green'], scale1.forcedColors);
Expand Down
12 changes: 6 additions & 6 deletions superset/assets/src/modules/CategoricalColorScale.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export default class CategoricalColorScale {
/**
* Constructor
* @param {*} colors an array of colors
* @param {*} sharedForcedColors optional parameter that comes from parent
* @param {*} parentForcedColors optional parameter that comes from parent
* (usually CategoricalColorNamespace) and supersede this.forcedColors
*/
constructor(colors, sharedForcedColors) {
constructor(colors, parentForcedColors) {
this.colors = colors;
this.sharedForcedColors = sharedForcedColors;
this.parentForcedColors = parentForcedColors;
this.forcedColors = {};
this.seen = {};
this.fn = value => this.getColor(value);
Expand All @@ -27,9 +27,9 @@ export default class CategoricalColorScale {
getColor(value) {
const cleanedValue = cleanValue(value);

const sharedColor = this.sharedForcedColors && this.sharedForcedColors[cleanedValue];
if (sharedColor) {
return sharedColor;
const parentColor = this.parentForcedColors && this.parentForcedColors[cleanedValue];
if (parentColor) {
return parentColor;
}

const forcedColor = this.forcedColors[cleanedValue];
Expand Down

0 comments on commit 1cb5d61

Please sign in to comment.