1 |
|
2 | import { category } from './fsw-structure';
|
3 | import { parse } from './fsw-parse';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | const colors = ['#0000CC', '#CC0000', '#FF0099', '#006600', '#000000', '#884411', '#FF9900'];
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | const colorize = (key) => {
|
23 | const parsed = parse.symbol(key);
|
24 | let color = '#000000';
|
25 | if (parsed.symbol) {
|
26 | const dec = parseInt(parsed.symbol.slice(1, 4), 16);
|
27 | const index = category.findIndex((val) => val > dec);
|
28 | color = colors[(index < 0 ? 6 : index - 1)];
|
29 | }
|
30 | return color;
|
31 | }
|
32 |
|
33 | export { colors, colorize }
|