Skip to content

Commit 9ae09d4

Browse files
Merge pull request #352 from davidwatkins73/waltz-351-pie-colors
Fixing awful pie color schemes
2 parents 4613b05 + d389737 commit 9ae09d4

2 files changed

Lines changed: 104 additions & 12 deletions

File tree

waltz-ng/client/applications/components/app-summary.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from "lodash";
22
import {tallyBy} from "../../common/tally-utils";
3-
import {lifecyclePhaseColorScale, variableScale} from "../../common/colors";
3+
import {lifecyclePhaseColorScale, riskRatingColorScale, variableScale} from "../../common/colors";
44
import {
55
riskRatingDisplayNames,
66
lifecyclePhaseDisplayNames,
@@ -32,6 +32,7 @@ const applicationKindLabelProvider = d => applicationKindDisplayNames[d.key] ||
3232

3333
const randomColorProvider = d => variableScale(d.data.key);
3434
const lifecycleColorProvider = d => lifecyclePhaseColorScale(d.data.key);
35+
const riskRatingColorProvider = d => riskRatingColorScale(d.data.key);
3536

3637

3738
function mkChartData(data,
@@ -81,7 +82,7 @@ function mkCharts(apps = [], endUserApps = []) {
8182
endUserApps,
8283
'riskRating',
8384
PIE_SIZE,
84-
randomColorProvider,
85+
riskRatingColorProvider,
8586
riskRatingLabelProvider)
8687
}
8788
};

waltz-ng/client/common/colors.js

Lines changed: 101 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
*/
1313

1414
import d3 from "d3";
15+
import _ from 'lodash';
1516

16-
export const amber = d3.rgb('#ff7f0e');
17-
export const green = d3.rgb('#2ca02c');
18-
export const red = d3.rgb('#d62728');
19-
export const grey = d3.rgb('#999');
20-
export const blue = d3.rgb('#28a1b6');
17+
18+
export const amber = d3.rgb('#D9923F');
19+
export const green = d3.rgb('#5BB65D');
20+
export const red = d3.rgb('#DA524B');
21+
export const grey = d3.rgb('#939393');
22+
export const blue = d3.rgb('#5271CC');
2123

2224

2325
export const ragColorScale = d3.scale.ordinal()
@@ -72,16 +74,105 @@ export const lifecyclePhaseColorScale = d3.scale.ordinal()
7274

7375
export const riskRatingColorScale = d3.scale.ordinal()
7476
.domain(['LOW', 'MEDIUM', 'HIGH', 'VERY_HIGH'])
75-
.range([blue, green, amber, red]);
77+
.range([green, amber, red, red.darker()]);
7678

7779

7880
export const flowDirectionColorScale = d3.scale.ordinal()
7981
.domain(['Inbound', 'Outbound', 'Intra', 'UNKNOWN'])
8082
.range([green, amber, blue, grey]);
8183

8284

83-
const underlyingVariableScale = d3.scale.category20c();
8485

85-
export const variableScale = (x) => x != "Other"
86-
? d3.rgb(underlyingVariableScale(JSON.stringify(x)))
87-
: grey;
86+
87+
const variableColorList = [
88+
{
89+
color: red,
90+
keys: [
91+
'NO',
92+
'FAIL',
93+
'DISINVEST',
94+
'UNSUPPORTED',
95+
'RESTRICTED',
96+
'DISCOURAGED',
97+
'NON_STRATEGIC',
98+
'NON_COMPLIANT',
99+
'R',
100+
'RED',
101+
'OVERDUE',
102+
'LATE',
103+
'BAD'
104+
]
105+
}, {
106+
color: green,
107+
keys: [
108+
'YES',
109+
'PASS',
110+
'COMPLETED',
111+
'SUCCESS',
112+
'INVEST',
113+
'SUPPORTED',
114+
'PRIMARY',
115+
'COMPLIANT',
116+
'ENCOURAGED',
117+
'STRATEGIC',
118+
'G',
119+
'GREEN',
120+
'GOOD'
121+
]
122+
}, {
123+
color: amber,
124+
keys: [
125+
'MAYBE',
126+
'PARTIAL',
127+
'HOLD',
128+
'IN_PROGRESS',
129+
'SECONDARY',
130+
'STRATEGIC_WITH_ISSUES',
131+
'PART_COMPLIANT',
132+
'PARTIALLY_COMPLIANT',
133+
'A',
134+
'AMBER',
135+
'YELLOW',
136+
'OKAY'
137+
]
138+
}, {
139+
color: blue,
140+
keys: [
141+
'PLANNED',
142+
'OTHER',
143+
'CONCEPTUAL',
144+
'B',
145+
'NOT_STARTED',
146+
'BLUE'
147+
]
148+
}, {
149+
color: grey,
150+
keys: [
151+
'UNKNOWN',
152+
'EXEMPT',
153+
'RETIRED',
154+
'GREY',
155+
'GRAY',
156+
'POSTPONED',
157+
'N/A',
158+
'NA',
159+
'NOT_APPLICABLE',
160+
'MEH'
161+
]
162+
}
163+
];
164+
165+
const variableScaleMap = _.reduce(
166+
variableColorList,
167+
(acc, colorSet) => {
168+
_.each(colorSet.keys, k => acc[k] = colorSet.color);
169+
return acc;
170+
},
171+
{});
172+
173+
const randomColorScale = d3.scale.category20();
174+
175+
176+
export const variableScale = (x) => variableScaleMap[x.toUpperCase()] || d3.rgb(randomColorScale(x));
177+
178+

0 commit comments

Comments
 (0)