Skip to content

Commit cf4f821

Browse files
authored
Rename ColorScheme field 'name' to 'id' (apache-superset#35)
BREAKING CHANGE: Rename ColorScheme field 'name' to 'id'
1 parent 8008606 commit cf4f821

File tree

12 files changed

+72
-77
lines changed

12 files changed

+72
-77
lines changed

packages/superset-ui-color/src/CategoricalColorNamespace.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ export default class CategoricalColorNamespace {
99
this.forcedItems = {};
1010
}
1111

12-
getScale(schemeName) {
13-
const name = schemeName || getCategoricalSchemeRegistry().getDefaultKey();
14-
const scale = this.scales[name];
12+
getScale(schemeId) {
13+
const id = schemeId || getCategoricalSchemeRegistry().getDefaultKey();
14+
const scale = this.scales[id];
1515
if (scale) {
1616
return scale;
1717
}
1818
const newScale = new CategoricalColorScale(
19-
getCategoricalSchemeRegistry().get(name).colors,
19+
getCategoricalSchemeRegistry().get(id).colors,
2020
this.forcedItems,
2121
);
22-
this.scales[name] = newScale;
22+
this.scales[id] = newScale;
2323

2424
return newScale;
2525
}
@@ -52,9 +52,9 @@ export function getNamespace(name = DEFAULT_NAMESPACE) {
5252
return newInstance;
5353
}
5454

55-
export function getColor(value, scheme, namespace) {
55+
export function getColor(value, schemeId, namespace) {
5656
return getNamespace(namespace)
57-
.getScale(scheme)
57+
.getScale(schemeId)
5858
.getColor(value);
5959
}
6060

packages/superset-ui-color/src/ColorScheme.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import { isRequired } from '@superset-ui/core';
22

33
export default class ColorScheme {
4-
constructor({
5-
name = isRequired('name'),
6-
label,
7-
colors = isRequired('colors'),
8-
description = '',
9-
}) {
10-
this.name = name;
11-
this.label = label || name;
4+
constructor({ colors = isRequired('colors'), description = '', id = isRequired('id'), label }) {
5+
this.id = id;
6+
this.label = label || id;
127
this.colors = colors;
138
this.description = description;
149
}

packages/superset-ui-color/src/colorSchemes/categorical/airbnb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import CategoricalScheme from '../../CategoricalScheme';
44

55
const schemes = [
66
{
7-
name: 'bnbColors',
7+
id: 'bnbColors',
88
colors: [
99
'#ff5a5f', // rausch
1010
'#7b0051', // hackb

packages/superset-ui-color/src/colorSchemes/categorical/d3.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import CategoricalScheme from '../../CategoricalScheme';
44

55
const schemes = [
66
{
7-
name: 'd3Category10',
7+
id: 'd3Category10',
88
colors: [
99
'#1f77b4',
1010
'#ff7f0e',
@@ -19,7 +19,7 @@ const schemes = [
1919
],
2020
},
2121
{
22-
name: 'd3Category20',
22+
id: 'd3Category20',
2323
colors: [
2424
'#1f77b4',
2525
'#aec7e8',
@@ -44,7 +44,7 @@ const schemes = [
4444
],
4545
},
4646
{
47-
name: 'd3Category20b',
47+
id: 'd3Category20b',
4848
colors: [
4949
'#393b79',
5050
'#5254a3',
@@ -69,7 +69,7 @@ const schemes = [
6969
],
7070
},
7171
{
72-
name: 'd3Category20c',
72+
id: 'd3Category20c',
7373
colors: [
7474
'#3182bd',
7575
'#6baed6',

packages/superset-ui-color/src/colorSchemes/categorical/google.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import CategoricalScheme from '../../CategoricalScheme';
44

55
const schemes = [
66
{
7-
name: 'googleCategory10c',
7+
id: 'googleCategory10c',
88
colors: [
99
'#3366cc',
1010
'#dc3912',
@@ -19,7 +19,7 @@ const schemes = [
1919
],
2020
},
2121
{
22-
name: 'googleCategory20c',
22+
id: 'googleCategory20c',
2323
colors: [
2424
'#3366cc',
2525
'#dc3912',

packages/superset-ui-color/src/colorSchemes/categorical/lyft.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import CategoricalScheme from '../../CategoricalScheme';
44

55
const schemes = [
66
{
7-
name: 'lyftColors',
7+
id: 'lyftColors',
88
colors: [
99
'#EA0B8C',
1010
'#6C838E',

packages/superset-ui-color/src/colorSchemes/sequential/common.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,61 @@ import SequentialScheme from '../../SequentialScheme';
44

55
const schemes = [
66
{
7-
name: 'blue_white_yellow',
7+
id: 'blue_white_yellow',
88
label: 'blue/white/yellow',
99
colors: ['#00d1c1', 'white', '#ffb400'],
1010
},
1111
{
12-
name: 'fire',
12+
id: 'fire',
1313
colors: ['white', 'yellow', 'red', 'black'],
1414
},
1515
{
16-
name: 'white_black',
16+
id: 'white_black',
1717
label: 'white/black',
1818
colors: ['white', 'black'],
1919
},
2020
{
21-
name: 'black_white',
21+
id: 'black_white',
2222
label: 'black/white',
2323
colors: ['black', 'white'],
2424
},
2525
{
26-
name: 'dark_blue',
26+
id: 'dark_blue',
2727
label: 'dark blues',
2828
colors: ['#EBF5F8', '#6BB1CC', '#357E9B', '#1B4150', '#092935'],
2929
},
3030
{
31-
name: 'pink_grey',
31+
id: 'pink_grey',
3232
label: 'pink/grey',
3333
isDiverging: true,
3434
colors: ['#E70B81', '#FAFAFA', '#666666'],
3535
},
3636
{
37-
name: 'greens',
37+
id: 'greens',
3838
colors: ['#ffffcc', '#78c679', '#006837'],
3939
},
4040
{
41-
name: 'purples',
41+
id: 'purples',
4242
colors: ['#f2f0f7', '#9e9ac8', '#54278f'],
4343
},
4444
{
45-
name: 'oranges',
45+
id: 'oranges',
4646
colors: ['#fef0d9', '#fc8d59', '#b30000'],
4747
},
4848
{
49-
name: 'red_yellow_blue',
49+
id: 'red_yellow_blue',
5050
label: 'red/yellow/blue',
5151
isDiverging: true,
5252
colors: ['#d7191c', '#fdae61', '#ffffbf', '#abd9e9', '#2c7bb6'],
5353
},
5454
{
55-
name: 'brown_white_green',
55+
id: 'brown_white_green',
5656
label: 'brown/white/green',
5757
isDiverging: true,
5858
colors: ['#a6611a', '#dfc27d', '#f5f5f5', '#80cdc1', '#018571'],
5959
},
6060
{
61-
name: 'purple_white_green',
61+
id: 'purple_white_green',
6262
label: 'purple/white/green',
6363
isDiverging: true,
6464
colors: ['#7b3294', '#c2a5cf', '#f7f7f7', '#a6dba0', '#008837'],

0 commit comments

Comments
 (0)