|
12 | 12 | */ |
13 | 13 |
|
14 | 14 | import d3 from "d3"; |
| 15 | +import _ from 'lodash'; |
15 | 16 |
|
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'); |
21 | 23 |
|
22 | 24 |
|
23 | 25 | export const ragColorScale = d3.scale.ordinal() |
@@ -72,16 +74,105 @@ export const lifecyclePhaseColorScale = d3.scale.ordinal() |
72 | 74 |
|
73 | 75 | export const riskRatingColorScale = d3.scale.ordinal() |
74 | 76 | .domain(['LOW', 'MEDIUM', 'HIGH', 'VERY_HIGH']) |
75 | | - .range([blue, green, amber, red]); |
| 77 | + .range([green, amber, red, red.darker()]); |
76 | 78 |
|
77 | 79 |
|
78 | 80 | export const flowDirectionColorScale = d3.scale.ordinal() |
79 | 81 | .domain(['Inbound', 'Outbound', 'Intra', 'UNKNOWN']) |
80 | 82 | .range([green, amber, blue, grey]); |
81 | 83 |
|
82 | 84 |
|
83 | | -const underlyingVariableScale = d3.scale.category20c(); |
84 | 85 |
|
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