@cdc/core 1.1.4 → 4.22.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +1 -1
- package/assets/filtered-text.svg +1 -0
- package/assets/icon-caret-down.svg +3 -0
- package/assets/icon-caret-filled-down.svg +3 -0
- package/assets/icon-caret-filled-up.svg +3 -0
- package/assets/icon-caret-up.svg +3 -0
- package/assets/icon-chart-bar-paired.svg +15 -0
- package/assets/icon-chart-bar-stacked.svg +10 -0
- package/assets/icon-chart-bar.svg +3 -0
- package/assets/icon-chart-line.svg +3 -0
- package/assets/icon-chart-pie.svg +3 -0
- package/assets/icon-check.svg +3 -0
- package/assets/icon-close.svg +3 -1
- package/assets/icon-code.svg +2 -2
- package/assets/icon-dashboard.svg +34 -0
- package/assets/icon-databite.svg +3 -0
- package/assets/icon-edit.svg +3 -0
- package/assets/icon-file-upload.svg +3 -0
- package/assets/icon-filter-bars.svg +5 -0
- package/assets/icon-gear.svg +6 -0
- package/assets/icon-grid.svg +2 -3
- package/assets/icon-info.svg +1 -1
- package/assets/icon-link.svg +3 -0
- package/assets/{alabama-graphic.svg → icon-map-alabama.svg} +2 -2
- package/assets/icon-map-usa.svg +3 -0
- package/assets/icon-map-world.svg +3 -0
- package/assets/icon-minus.svg +3 -0
- package/assets/icon-move.svg +8 -0
- package/assets/icon-plus.svg +3 -0
- package/assets/icon-question-circle.svg +3 -0
- package/assets/icon-tools.svg +8 -0
- package/assets/icon-upload.svg +3 -0
- package/assets/icon-warning-circle.svg +3 -0
- package/assets/{icon-warning.svg → icon-warning-triangle.svg} +1 -1
- package/components/AdvancedEditor.js +52 -67
- package/components/{ErrorBoundary.js → ErrorBoundary.jsx} +10 -11
- package/components/GlobalContext.jsx +2 -6
- package/components/{LegendCircle.js → LegendCircle.jsx} +4 -4
- package/components/Loading.jsx +17 -0
- package/components/Waiting.jsx +20 -0
- package/components/elements/Button.jsx +111 -3
- package/components/elements/Card.jsx +13 -0
- package/components/inputs/InputCheckbox.jsx +43 -38
- package/components/inputs/InputGroup.jsx +71 -0
- package/components/inputs/InputSelect.jsx +28 -24
- package/components/inputs/InputText.jsx +20 -37
- package/components/inputs/InputToggle.jsx +39 -43
- package/components/managers/DataDesigner.jsx +194 -0
- package/components/ui/Accordion.jsx +18 -30
- package/components/ui/Icon.jsx +59 -20
- package/components/ui/LoadSpin.jsx +19 -0
- package/components/ui/Modal.jsx +40 -39
- package/components/ui/Overlay.jsx +15 -24
- package/components/ui/OverlayFrame.jsx +1 -5
- package/components/ui/Tooltip.jsx +20 -31
- package/data/colorPalettes.js +36 -227
- package/data/dataDesignerTables.js +148 -0
- package/data/themes.js +13 -13
- package/helpers/DataTransform.js +162 -0
- package/helpers/cacheBustingString.js +5 -0
- package/helpers/events.js +5 -6
- package/helpers/fetchRemoteData.js +41 -0
- package/helpers/getViewport.js +15 -15
- package/helpers/numberFromString.js +7 -7
- package/helpers/updatePaletteNames.js +15 -17
- package/helpers/useDataVizClasses.js +40 -0
- package/helpers/validateFipsCodeLength.js +41 -56
- package/package.json +3 -2
- package/styles/_data-table.scss +45 -40
- package/styles/_global.scss +41 -22
- package/styles/_mixins.scss +12 -12
- package/styles/_reset.scss +95 -16
- package/styles/_variables.scss +5 -5
- package/styles/base.scss +104 -37
- package/styles/heading-colors.scss +6 -2
- package/styles/loading.scss +62 -60
- package/styles/v2/base/_file-selector.scss +20 -0
- package/styles/v2/base/_general.scss +9 -22
- package/styles/v2/base/_heading.scss +20 -0
- package/styles/v2/base/_reset.scss +4 -3
- package/styles/v2/base/index.scss +7 -3
- package/styles/v2/components/accordion.scss +13 -13
- package/styles/v2/components/button.scss +29 -68
- package/styles/v2/components/card.scss +7 -0
- package/styles/v2/components/data-designer.scss +101 -0
- package/styles/v2/components/editor.scss +52 -50
- package/styles/v2/components/guidance-block.scss +74 -0
- package/styles/v2/components/icon.scss +0 -4
- package/styles/v2/components/input/_input-check-radio.scss +97 -0
- package/styles/v2/components/input/_input-group.scss +74 -0
- package/styles/v2/components/input/_input-slider.scss +183 -0
- package/styles/v2/components/input/_input.scss +66 -0
- package/styles/v2/components/input/index.scss +7 -0
- package/styles/v2/components/loadspin.scss +100 -0
- package/styles/v2/components/modal.scss +15 -8
- package/styles/v2/components/overlay.scss +6 -4
- package/styles/v2/layout/_alert.scss +15 -14
- package/styles/v2/layout/_component.scss +8 -1
- package/styles/v2/layout/_data-table.scss +78 -156
- package/styles/v2/layout/_progression.scss +12 -8
- package/styles/v2/layout/index.scss +5 -7
- package/styles/v2/main.scss +52 -2
- package/styles/v2/themes/_color-definitions.scss +103 -20
- package/styles/v2/themes/index.scss +1 -1
- package/styles/v2/utils/_align.scss +17 -0
- package/styles/v2/utils/_animations.scss +2 -2
- package/styles/v2/utils/_breakpoints.scss +59 -0
- package/styles/v2/utils/_grid.scss +47 -0
- package/styles/v2/utils/_mixins.scss +0 -16
- package/styles/v2/utils/_spacers.scss +31 -0
- package/styles/v2/utils/_variables.scss +7 -0
- package/styles/v2/utils/index.scss +9 -4
- package/styles/waiting.scss +22 -23
- package/assets/asc.svg +0 -1
- package/assets/chart-bar-solid.svg +0 -1
- package/assets/chart-line-solid.svg +0 -1
- package/assets/chart-pie-solid.svg +0 -1
- package/assets/check.svg +0 -3
- package/assets/dashboard.svg +0 -11
- package/assets/data-bite-graphic.svg +0 -3
- package/assets/desc.svg +0 -1
- package/assets/file-upload-solid.svg +0 -1
- package/assets/horizontal-stacked-bar.svg +0 -1
- package/assets/link.svg +0 -1
- package/assets/minus.svg +0 -1
- package/assets/paired-bar.svg +0 -11
- package/assets/plus.svg +0 -1
- package/assets/question-circle.svg +0 -1
- package/assets/upload-solid.svg +0 -1
- package/assets/usa-graphic.svg +0 -3
- package/assets/world-graphic.svg +0 -3
- package/components/DataTransform.js +0 -162
- package/components/Loading.js +0 -15
- package/components/Waiting.js +0 -11
- package/styles/v2/components/input.scss +0 -372
- package/styles/v2/layout/_header.scss +0 -13
- package/styles/v2/layout/_link.scss +0 -46
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export const DATA_TABLE_VERTICAL = (
|
|
4
|
+
<>
|
|
5
|
+
<table>
|
|
6
|
+
<tbody>
|
|
7
|
+
<tr>
|
|
8
|
+
<th>Date</th>
|
|
9
|
+
<th>Value</th>
|
|
10
|
+
<th>...</th>
|
|
11
|
+
</tr>
|
|
12
|
+
<tr>
|
|
13
|
+
<td>01/01/2020</td>
|
|
14
|
+
<td>150</td>
|
|
15
|
+
<td>...</td>
|
|
16
|
+
</tr>
|
|
17
|
+
<tr>
|
|
18
|
+
<td>02/01/2020</td>
|
|
19
|
+
<td>150</td>
|
|
20
|
+
<td>...</td>
|
|
21
|
+
</tr>
|
|
22
|
+
</tbody>
|
|
23
|
+
</table>
|
|
24
|
+
<table>
|
|
25
|
+
<tbody>
|
|
26
|
+
<tr>
|
|
27
|
+
<th>State</th>
|
|
28
|
+
<th>Value</th>
|
|
29
|
+
<th>...</th>
|
|
30
|
+
</tr>
|
|
31
|
+
<tr>
|
|
32
|
+
<td>Georgia</td>
|
|
33
|
+
<td>150</td>
|
|
34
|
+
<td>...</td>
|
|
35
|
+
</tr>
|
|
36
|
+
<tr>
|
|
37
|
+
<td>Florida</td>
|
|
38
|
+
<td>150</td>
|
|
39
|
+
<td>...</td>
|
|
40
|
+
</tr>
|
|
41
|
+
</tbody>
|
|
42
|
+
</table>
|
|
43
|
+
</>
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
export const DATA_TABLE_HORIZONTAL = (
|
|
47
|
+
<>
|
|
48
|
+
<table>
|
|
49
|
+
<tbody>
|
|
50
|
+
<tr>
|
|
51
|
+
<th>Date</th>
|
|
52
|
+
<td>01/01/2020</td>
|
|
53
|
+
<td>02/01/2020</td>
|
|
54
|
+
<td>...</td>
|
|
55
|
+
</tr>
|
|
56
|
+
<tr>
|
|
57
|
+
<th>Value</th>
|
|
58
|
+
<td>100</td>
|
|
59
|
+
<td>150</td>
|
|
60
|
+
<td>...</td>
|
|
61
|
+
</tr>
|
|
62
|
+
</tbody>
|
|
63
|
+
</table>
|
|
64
|
+
<table>
|
|
65
|
+
<tbody>
|
|
66
|
+
<tr>
|
|
67
|
+
<th>State</th>
|
|
68
|
+
<td>Georgia</td>
|
|
69
|
+
<td>Florida</td>
|
|
70
|
+
<td>...</td>
|
|
71
|
+
</tr>
|
|
72
|
+
<tr>
|
|
73
|
+
<th>Value</th>
|
|
74
|
+
<td>100</td>
|
|
75
|
+
<td>150</td>
|
|
76
|
+
<td>...</td>
|
|
77
|
+
</tr>
|
|
78
|
+
</tbody>
|
|
79
|
+
</table>
|
|
80
|
+
</>
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
export const DATA_TABLE_SINGLE_ROW = (
|
|
84
|
+
<table>
|
|
85
|
+
<tbody>
|
|
86
|
+
<tr>
|
|
87
|
+
<th>Date</th>
|
|
88
|
+
<th>Virus 1</th>
|
|
89
|
+
<th>Virus 2</th>
|
|
90
|
+
<th>...</th>
|
|
91
|
+
</tr>
|
|
92
|
+
<tr>
|
|
93
|
+
<td>01/01/2020</td>
|
|
94
|
+
<td>100</td>
|
|
95
|
+
<td>150</td>
|
|
96
|
+
<td>...</td>
|
|
97
|
+
</tr>
|
|
98
|
+
<tr>
|
|
99
|
+
<td>02/01/2020</td>
|
|
100
|
+
<td>15</td>
|
|
101
|
+
<td>20</td>
|
|
102
|
+
<td>...</td>
|
|
103
|
+
</tr>
|
|
104
|
+
</tbody>
|
|
105
|
+
</table>
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
export const DATA_TABLE_MULTI_ROW = (
|
|
109
|
+
<table>
|
|
110
|
+
<tbody>
|
|
111
|
+
<tr>
|
|
112
|
+
<th>Virus</th>
|
|
113
|
+
<th>Date</th>
|
|
114
|
+
<th>Value</th>
|
|
115
|
+
</tr>
|
|
116
|
+
<tr>
|
|
117
|
+
<td>Virus 1</td>
|
|
118
|
+
<td>01/01/2020</td>
|
|
119
|
+
<td>100</td>
|
|
120
|
+
</tr>
|
|
121
|
+
<tr>
|
|
122
|
+
<td>Virus 1</td>
|
|
123
|
+
<td>02/01/2020</td>
|
|
124
|
+
<td>150</td>
|
|
125
|
+
</tr>
|
|
126
|
+
<tr>
|
|
127
|
+
<td>...</td>
|
|
128
|
+
<td>...</td>
|
|
129
|
+
<td>...</td>
|
|
130
|
+
</tr>
|
|
131
|
+
<tr>
|
|
132
|
+
<td>Virus 2</td>
|
|
133
|
+
<td>01/01/2020</td>
|
|
134
|
+
<td>15</td>
|
|
135
|
+
</tr>
|
|
136
|
+
<tr>
|
|
137
|
+
<td>Virus 2</td>
|
|
138
|
+
<td>02/01/2020</td>
|
|
139
|
+
<td>20</td>
|
|
140
|
+
</tr>
|
|
141
|
+
<tr>
|
|
142
|
+
<td>...</td>
|
|
143
|
+
<td>...</td>
|
|
144
|
+
<td>...</td>
|
|
145
|
+
</tr>
|
|
146
|
+
</tbody>
|
|
147
|
+
</table>
|
|
148
|
+
)
|
package/data/themes.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
const themes = {
|
|
2
2
|
'theme-blue': {
|
|
3
|
-
primary:
|
|
3
|
+
primary: '#005eaa',
|
|
4
4
|
secondary: '#88c3ea',
|
|
5
|
-
tertiary:
|
|
5
|
+
tertiary: '#c0e9ff',
|
|
6
6
|
quaternary: '#edf9ff'
|
|
7
7
|
},
|
|
8
8
|
'theme-purple': {
|
|
9
9
|
primary: '#712177',
|
|
10
10
|
secondary: '#b890bb',
|
|
11
11
|
tertiary: '#e3d3e4',
|
|
12
|
-
quaternary: '#f7f2f7'
|
|
12
|
+
quaternary: '#f7f2f7'
|
|
13
13
|
},
|
|
14
14
|
'theme-brown': {
|
|
15
15
|
primary: '#705043',
|
|
16
16
|
secondary: '#ad907b',
|
|
17
17
|
tertiary: '#d7ccc8',
|
|
18
|
-
quaternary: '#f2ebe8'
|
|
18
|
+
quaternary: '#f2ebe8'
|
|
19
19
|
},
|
|
20
20
|
'theme-teal': {
|
|
21
21
|
primary: '#00695c',
|
|
22
22
|
secondary: '#4ebaaa',
|
|
23
23
|
tertiary: '#ceece7',
|
|
24
|
-
quaternary: '#ebf7f5'
|
|
24
|
+
quaternary: '#ebf7f5'
|
|
25
25
|
},
|
|
26
26
|
'theme-pink': {
|
|
27
27
|
primary: '#af4448',
|
|
28
28
|
secondary: '#e57373',
|
|
29
29
|
tertiary: '#ffc2c2',
|
|
30
|
-
quaternary: '#ffe7e7'
|
|
30
|
+
quaternary: '#ffe7e7'
|
|
31
31
|
},
|
|
32
32
|
'theme-orange': {
|
|
33
33
|
primary: '#bb4d00',
|
|
34
34
|
secondary: '#ffad42',
|
|
35
35
|
tertiary: '#ffe97d',
|
|
36
|
-
quaternary: '#fff4cf'
|
|
36
|
+
quaternary: '#fff4cf'
|
|
37
37
|
},
|
|
38
38
|
'theme-slate': {
|
|
39
39
|
primary: '#29434e',
|
|
40
40
|
secondary: '#7e9ba5',
|
|
41
41
|
tertiary: '#b6c6d2',
|
|
42
|
-
quaternary: '#e2e8ed'
|
|
42
|
+
quaternary: '#e2e8ed'
|
|
43
43
|
},
|
|
44
44
|
'theme-indigo': {
|
|
45
45
|
primary: '#26418f',
|
|
46
46
|
secondary: '#92a6dd',
|
|
47
47
|
tertiary: '#dee8ff',
|
|
48
|
-
quaternary: '#f2f6ff'
|
|
48
|
+
quaternary: '#f2f6ff'
|
|
49
49
|
},
|
|
50
50
|
'theme-cyan': {
|
|
51
51
|
primary: '#006778',
|
|
52
52
|
secondary: '#65b0bd',
|
|
53
53
|
tertiary: '#cce5e9',
|
|
54
|
-
quaternary: '#ebf5f6'
|
|
54
|
+
quaternary: '#ebf5f6'
|
|
55
55
|
},
|
|
56
56
|
'theme-green': {
|
|
57
57
|
primary: '#4b830d',
|
|
58
58
|
secondary: '#84bc49',
|
|
59
59
|
tertiary: '#dcedc8',
|
|
60
|
-
quaternary: '#f1f8e9'
|
|
60
|
+
quaternary: '#f1f8e9'
|
|
61
61
|
},
|
|
62
62
|
'theme-amber': {
|
|
63
63
|
primary: '#fbab18',
|
|
64
64
|
secondary: '#ffd54f',
|
|
65
65
|
tertiary: '#ffecb3',
|
|
66
66
|
quaternary: '#fff7e1'
|
|
67
|
-
}
|
|
67
|
+
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export default themes
|
|
70
|
+
export default themes
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
export class DataTransform {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.constants = {
|
|
4
|
+
errorMessageEmtpyData: 'Your data file is empty.',
|
|
5
|
+
errorMessageFormat: 'Your datatype is not supported.',
|
|
6
|
+
descriptionHeader: 1,
|
|
7
|
+
descriptionRoot: 2,
|
|
8
|
+
descriptionSeriesFilter: 3
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//Performs standardizations that can be completed automatically without use input
|
|
13
|
+
autoStandardize(data) {
|
|
14
|
+
const errorsFound = []
|
|
15
|
+
|
|
16
|
+
// Empty data
|
|
17
|
+
if (0 === data.length) {
|
|
18
|
+
errorsFound.push(this.constants.errorMessageEmptyData)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Does it have the correct data structure?
|
|
22
|
+
if (!data.filter || data.filter(row => typeof row !== 'object').length > 0) {
|
|
23
|
+
errorsFound.push(this.constants.errorMessageFormat)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (errorsFound.length > 0) {
|
|
27
|
+
console.error(errorsFound)
|
|
28
|
+
return undefined
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//Convert array of arrays, to array of objects
|
|
32
|
+
if (data.filter(row => row.constructor !== Object).length > 0) {
|
|
33
|
+
let standardizedData = []
|
|
34
|
+
for (let row = 1; row < data.length; row++) {
|
|
35
|
+
let standardizedRow = {}
|
|
36
|
+
data[row].forEach((datum, col) => {
|
|
37
|
+
standardizedRow[data[0][col]] = datum
|
|
38
|
+
})
|
|
39
|
+
standardizedData.push(standardizedRow)
|
|
40
|
+
}
|
|
41
|
+
data = standardizedData
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return data
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//Performs standardizations based on developer provided description of the data
|
|
48
|
+
developerStandardize(data, description) {
|
|
49
|
+
//Validate the description object
|
|
50
|
+
if (!description) {
|
|
51
|
+
return undefined
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (description.horizontal === undefined || description.series === undefined) {
|
|
55
|
+
return undefined
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (description.series === true && description.horizontal === false && description.singleRow === undefined) {
|
|
59
|
+
return undefined
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (description.horizontal === true) {
|
|
63
|
+
if (description.series === true) {
|
|
64
|
+
if (!description.seriesKey) {
|
|
65
|
+
return undefined
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let standardizedMapped = {}
|
|
69
|
+
let standardized = []
|
|
70
|
+
data.forEach(row => {
|
|
71
|
+
let nonNumericKeys = []
|
|
72
|
+
Object.keys(row).forEach(key => {
|
|
73
|
+
if (key !== description.seriesKey && isNaN(parseFloat(row[key]))) {
|
|
74
|
+
nonNumericKeys.push(key)
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
Object.keys(row).forEach(key => {
|
|
79
|
+
if (key !== description.seriesKey && nonNumericKeys.indexOf(key) === -1) {
|
|
80
|
+
let uniqueKey = key + '|' + nonNumericKeys.map(nonNumericKey => nonNumericKey + '=' + row[nonNumericKey])
|
|
81
|
+
if (!standardizedMapped[uniqueKey]) {
|
|
82
|
+
standardizedMapped[uniqueKey] = { [row[description.seriesKey]]: row[key], key }
|
|
83
|
+
nonNumericKeys.forEach(nonNumericKey => {
|
|
84
|
+
standardizedMapped[uniqueKey][nonNumericKey] = row[nonNumericKey]
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
standardizedMapped[uniqueKey][row[description.seriesKey]] = row[key]
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
Object.keys(standardizedMapped).forEach(key => {
|
|
93
|
+
standardized.push(standardizedMapped[key])
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
return standardized
|
|
97
|
+
} else {
|
|
98
|
+
let standardized = []
|
|
99
|
+
|
|
100
|
+
data.forEach(row => {
|
|
101
|
+
let nonNumericKeys = []
|
|
102
|
+
Object.keys(row).forEach(key => {
|
|
103
|
+
if (isNaN(parseFloat(row[key]))) {
|
|
104
|
+
nonNumericKeys.push(key)
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
Object.keys(row).forEach(key => {
|
|
109
|
+
if (nonNumericKeys.indexOf(key) === -1) {
|
|
110
|
+
let newRow = { key, value: row[key] }
|
|
111
|
+
|
|
112
|
+
nonNumericKeys.forEach(nonNumericKey => {
|
|
113
|
+
newRow[nonNumericKey] = row[nonNumericKey]
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
standardized.push(newRow)
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
return standardized
|
|
122
|
+
}
|
|
123
|
+
} else if (description.series === true && description.singleRow === false) {
|
|
124
|
+
if (description.seriesKey !== undefined && description.xKey !== undefined && description.valueKey !== undefined) {
|
|
125
|
+
let standardizedMapped = {}
|
|
126
|
+
let standardized = []
|
|
127
|
+
|
|
128
|
+
data.forEach(row => {
|
|
129
|
+
let extraKeys = []
|
|
130
|
+
let uniqueKey = row[description.xKey]
|
|
131
|
+
Object.keys(row).forEach(key => {
|
|
132
|
+
if (key !== description.xKey && key !== description.seriesKey && key !== description.valueKey) {
|
|
133
|
+
uniqueKey += '|' + key + '=' + row[key]
|
|
134
|
+
extraKeys.push(key)
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
if (standardizedMapped[uniqueKey]) {
|
|
139
|
+
standardizedMapped[uniqueKey][row[description.seriesKey]] = row[description.valueKey]
|
|
140
|
+
} else {
|
|
141
|
+
standardizedMapped[uniqueKey] = { [description.xKey]: row[description.xKey], [row[description.seriesKey]]: row[description.valueKey] }
|
|
142
|
+
extraKeys.forEach(key => {
|
|
143
|
+
standardizedMapped[uniqueKey][key] = row[key]
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
Object.keys(standardizedMapped).forEach(key => {
|
|
149
|
+
standardized.push(standardizedMapped[key])
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
return standardized
|
|
153
|
+
} else {
|
|
154
|
+
return undefined
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return data
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export default DataTransform
|
package/helpers/events.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
1
|
function subscribe(eventName, listener) {
|
|
3
|
-
document.addEventListener(eventName, listener)
|
|
2
|
+
document.addEventListener(eventName, listener)
|
|
4
3
|
}
|
|
5
4
|
|
|
6
5
|
function unsubscribe(eventName, listener) {
|
|
7
|
-
document.removeEventListener(eventName, listener)
|
|
6
|
+
document.removeEventListener(eventName, listener)
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
function publish(eventName, data) {
|
|
11
|
-
const event = new CustomEvent(eventName, { detail: data })
|
|
12
|
-
document.dispatchEvent(event)
|
|
10
|
+
const event = new CustomEvent(eventName, { detail: data })
|
|
11
|
+
document.dispatchEvent(event)
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
export { publish, subscribe, unsubscribe}
|
|
14
|
+
export { publish, subscribe, unsubscribe }
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Papa from 'papaparse'
|
|
2
|
+
|
|
3
|
+
export default async function (url) {
|
|
4
|
+
try {
|
|
5
|
+
// Using URL Object to get pathname without URL paramaters on regex.
|
|
6
|
+
url = new URL(url)
|
|
7
|
+
|
|
8
|
+
const path = url.pathname
|
|
9
|
+
const regex = /(?:\.([^.]+))?$/
|
|
10
|
+
const ext = regex.exec(path)[1]
|
|
11
|
+
|
|
12
|
+
let data = []
|
|
13
|
+
|
|
14
|
+
if ('csv' === ext) {
|
|
15
|
+
data = await fetch(url.href)
|
|
16
|
+
.then(response => response.text())
|
|
17
|
+
.then(responseText => {
|
|
18
|
+
const parsedCsv = Papa.parse(responseText, {
|
|
19
|
+
header: true,
|
|
20
|
+
dynamicTyping: true,
|
|
21
|
+
skipEmptyLines: true
|
|
22
|
+
})
|
|
23
|
+
return parsedCsv.data
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if ('json' === ext) {
|
|
28
|
+
data = await fetch(url.href).then(response => response.json())
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return data
|
|
32
|
+
} catch {
|
|
33
|
+
// If we can't parse it, still attempt to fetch it
|
|
34
|
+
try {
|
|
35
|
+
let response = await (await fetch(url)).json()
|
|
36
|
+
return response
|
|
37
|
+
} catch {
|
|
38
|
+
console.error(`Cannot parse URL: ${url}`)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
package/helpers/getViewport.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
export default function getViewport(size) {
|
|
2
|
-
|
|
2
|
+
let result = 'lg'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const viewports = {
|
|
5
|
+
lg: 1200,
|
|
6
|
+
md: 992,
|
|
7
|
+
sm: 768,
|
|
8
|
+
xs: 576,
|
|
9
|
+
xxs: 350
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
if (size > 1200) return result
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
14
|
+
for (let viewport in viewports) {
|
|
15
|
+
if (size <= viewports[viewport]) {
|
|
16
|
+
result = viewport
|
|
18
17
|
}
|
|
18
|
+
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
}
|
|
20
|
+
return result
|
|
21
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export default function numberFromString(value = '', state = null) {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
// Only do this to values that are ONLY numbers - without this parseFloat strips all the other text
|
|
3
|
+
if (typeof value === 'string' && state?.legend?.type === 'category') return value
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
let nonNumeric = /[^\d.-]/g
|
|
6
|
+
if (false === Number.isNaN(parseFloat(value)) && null === String(value).match(nonNumeric)) {
|
|
7
|
+
return parseFloat(value)
|
|
8
|
+
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
return value
|
|
11
11
|
}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
+
export function updatePaletteNames(colorPalettes) {
|
|
2
|
+
// this function adds REVERSE keyword to each palette
|
|
3
|
+
delete colorPalettes.qualitative9 // delete palette before reversing
|
|
4
|
+
let palettereversed = {}
|
|
5
|
+
for (const [paletteName, hexCodeArr] of Object.entries(colorPalettes)) {
|
|
6
|
+
const paletteStr = String(paletteName)
|
|
1
7
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
let palette = paletteStr.concat('reverse'); // add to the end of the string "reverse"
|
|
12
|
-
palettereversed[palette] = [...hexCodeArr].reverse(); // reverses arrays elements and create new keys on object
|
|
13
|
-
}else{
|
|
14
|
-
palettereversed = {...colorPalettes}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return {...palettereversed,...colorPalettes}
|
|
18
|
-
}
|
|
8
|
+
if (!paletteStr.endsWith('reverse')) {
|
|
9
|
+
let palette = paletteStr.concat('reverse') // add to the end of the string "reverse"
|
|
10
|
+
palettereversed[palette] = [...hexCodeArr].reverse() // reverses arrays elements and create new keys on object
|
|
11
|
+
} else {
|
|
12
|
+
palettereversed = { ...colorPalettes }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return { ...palettereversed, ...colorPalettes }
|
|
16
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export default function useDataVizClasses(config) {
|
|
2
|
+
let lineDatapointClass = ''
|
|
3
|
+
let barBorderClass = ''
|
|
4
|
+
|
|
5
|
+
if (config.lineDatapointStyle === 'hover') {
|
|
6
|
+
lineDatapointClass = ' chart-line--hover'
|
|
7
|
+
}
|
|
8
|
+
if (config.lineDatapointStyle === 'always show') {
|
|
9
|
+
lineDatapointClass = ' chart-line--always'
|
|
10
|
+
}
|
|
11
|
+
if (config.barHasBorder === 'false') {
|
|
12
|
+
barBorderClass = ' chart-bar--no-border'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let innerContainerClasses = ['cove-component__inner']
|
|
16
|
+
let contentClasses = ['cove-component__content']
|
|
17
|
+
|
|
18
|
+
config.title && innerContainerClasses.push('component--has-title')
|
|
19
|
+
config.subtext && innerContainerClasses.push('component--has-subtext')
|
|
20
|
+
config.biteStyle && innerContainerClasses.push(`bite__style--${config.biteStyle}`)
|
|
21
|
+
config.general?.isCompactStyle && innerContainerClasses.push(`component--isCompactStyle`)
|
|
22
|
+
|
|
23
|
+
!config.visual?.border && contentClasses.push('no-borders')
|
|
24
|
+
config.visualizationType === 'Spark Line' && contentClasses.push('sparkline')
|
|
25
|
+
config.visual?.borderColorTheme && contentClasses.push('component--has-borderColorTheme')
|
|
26
|
+
config.visual?.accent && contentClasses.push('component--has-accent')
|
|
27
|
+
config.visual?.background && contentClasses.push('component--has-background')
|
|
28
|
+
config.visual?.hideBackgroundColor && contentClasses.push('component--hideBackgroundColor')
|
|
29
|
+
|
|
30
|
+
// ! these two will be retired.
|
|
31
|
+
config.shadow && innerContainerClasses.push('shadow')
|
|
32
|
+
config?.visual?.roundedBorders && innerContainerClasses.push('bite--has-rounded-borders')
|
|
33
|
+
|
|
34
|
+
let sparkLineStyles = {
|
|
35
|
+
width: '100%',
|
|
36
|
+
height: '100px'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return { innerContainerClasses, contentClasses, barBorderClass, lineDatapointClass, sparkLineStyles }
|
|
40
|
+
}
|