@cdc/chart 4.23.5 → 4.23.6
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/dist/cdcchart.js +29056 -27475
- package/examples/feature/__data__/planet-example-data.json +15 -16
- package/examples/feature/bar/new.json +561 -0
- package/examples/feature/combo/right-issues.json +190 -0
- package/examples/feature/forecasting/combo-forecasting.json +245 -0
- package/examples/feature/forecasting/forecasting.json +5325 -0
- package/examples/feature/forecasting/index.json +203 -0
- package/examples/feature/line/line-chart.json +1 -1
- package/examples/gallery/line/line.json +173 -1
- package/index.html +12 -6
- package/package.json +2 -2
- package/src/CdcChart.jsx +48 -11
- package/src/components/AreaChart.jsx +8 -23
- package/src/components/BarChart.jsx +65 -3
- package/src/components/DataTable.jsx +30 -12
- package/src/components/EditorPanel.jsx +1803 -1948
- package/src/components/Forecasting.jsx +147 -0
- package/src/components/Legend.jsx +188 -274
- package/src/components/LineChart.jsx +3 -1
- package/src/components/LinearChart.jsx +145 -18
- package/src/components/Series.jsx +518 -0
- package/src/components/SparkLine.jsx +3 -3
- package/src/data/initial-state.js +7 -3
- package/src/hooks/useMinMax.js +36 -0
- package/src/hooks/useRightAxis.js +8 -2
- package/src/hooks/useScales.js +7 -13
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "chart",
|
|
3
|
+
"title": "Forecasting Chart Example",
|
|
4
|
+
"showTitle": true,
|
|
5
|
+
"theme": "theme-blue",
|
|
6
|
+
"animate": true,
|
|
7
|
+
"fontSize": "medium",
|
|
8
|
+
"lineDatapointStyle": "hover",
|
|
9
|
+
"barHasBorder": "false",
|
|
10
|
+
"isLollipopChart": false,
|
|
11
|
+
"lollipopShape": "circle",
|
|
12
|
+
"lollipopColorStyle": "two-tone",
|
|
13
|
+
"visualizationSubType": "regular",
|
|
14
|
+
"barStyle": "",
|
|
15
|
+
"roundingStyle": "standard",
|
|
16
|
+
"tipRounding": "top",
|
|
17
|
+
"padding": {
|
|
18
|
+
"left": 0,
|
|
19
|
+
"right": 0
|
|
20
|
+
},
|
|
21
|
+
"yAxis": {
|
|
22
|
+
"hideAxis": false,
|
|
23
|
+
"displayNumbersOnBar": false,
|
|
24
|
+
"hideLabel": false,
|
|
25
|
+
"hideTicks": false,
|
|
26
|
+
"size": "75",
|
|
27
|
+
"gridLines": false,
|
|
28
|
+
"enablePadding": false,
|
|
29
|
+
"min": "0",
|
|
30
|
+
"max": "900",
|
|
31
|
+
"labelColor": "#333",
|
|
32
|
+
"tickLabelColor": "#333",
|
|
33
|
+
"tickColor": "#333",
|
|
34
|
+
"rightHideAxis": false,
|
|
35
|
+
"rightAxisSize": 50,
|
|
36
|
+
"rightLabel": "",
|
|
37
|
+
"rightLabelOffsetSize": 0,
|
|
38
|
+
"rightAxisLabelColor": "#333",
|
|
39
|
+
"rightAxisTickLabelColor": "#333",
|
|
40
|
+
"rightAxisTickColor": "#333",
|
|
41
|
+
"numTicks": "",
|
|
42
|
+
"axisPadding": 0,
|
|
43
|
+
"tickRotation": 0,
|
|
44
|
+
"anchors": [],
|
|
45
|
+
"label": "Cases by Date of Report"
|
|
46
|
+
},
|
|
47
|
+
"boxplot": {
|
|
48
|
+
"plots": [],
|
|
49
|
+
"borders": "true",
|
|
50
|
+
"firstQuartilePercentage": 25,
|
|
51
|
+
"thirdQuartilePercentage": 75,
|
|
52
|
+
"boxWidthPercentage": 40,
|
|
53
|
+
"plotOutlierValues": false,
|
|
54
|
+
"plotNonOutlierValues": true,
|
|
55
|
+
"legend": {
|
|
56
|
+
"showHowToReadText": false,
|
|
57
|
+
"howToReadText": ""
|
|
58
|
+
},
|
|
59
|
+
"labels": {
|
|
60
|
+
"q1": "Lower Quartile",
|
|
61
|
+
"q2": "q2",
|
|
62
|
+
"q3": "Upper Quartile",
|
|
63
|
+
"q4": "q4",
|
|
64
|
+
"minimum": "Minimum",
|
|
65
|
+
"maximum": "Maximum",
|
|
66
|
+
"mean": "Mean",
|
|
67
|
+
"median": "Median",
|
|
68
|
+
"sd": "Standard Deviation",
|
|
69
|
+
"iqr": "Interquartile Range",
|
|
70
|
+
"count": "Count",
|
|
71
|
+
"outliers": "Outliers",
|
|
72
|
+
"values": "Values"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"topAxis": {
|
|
76
|
+
"hasLine": true
|
|
77
|
+
},
|
|
78
|
+
"isLegendValue": false,
|
|
79
|
+
"barThickness": 0.35,
|
|
80
|
+
"barHeight": 25,
|
|
81
|
+
"barSpace": 15,
|
|
82
|
+
"heights": {
|
|
83
|
+
"vertical": 300,
|
|
84
|
+
"horizontal": 750
|
|
85
|
+
},
|
|
86
|
+
"xAxis": {
|
|
87
|
+
"type": "date",
|
|
88
|
+
"showTargetLabel": true,
|
|
89
|
+
"targetLabel": "Target",
|
|
90
|
+
"hideAxis": false,
|
|
91
|
+
"hideLabel": false,
|
|
92
|
+
"hideTicks": false,
|
|
93
|
+
"size": 75,
|
|
94
|
+
"tickRotation": 30,
|
|
95
|
+
"min": "",
|
|
96
|
+
"max": "",
|
|
97
|
+
"labelColor": "#333",
|
|
98
|
+
"tickLabelColor": "#333",
|
|
99
|
+
"tickColor": "#333",
|
|
100
|
+
"numTicks": "",
|
|
101
|
+
"labelOffset": 65,
|
|
102
|
+
"axisPadding": 0,
|
|
103
|
+
"target": 0,
|
|
104
|
+
"anchors": [
|
|
105
|
+
{
|
|
106
|
+
"value": "10/19/2022",
|
|
107
|
+
"lineStyle": "dashed-md"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"label": "",
|
|
111
|
+
"dataKey": "date",
|
|
112
|
+
"dateParseFormat": "%m/%d/%Y",
|
|
113
|
+
"dateDisplayFormat": "%m/%d/%Y"
|
|
114
|
+
},
|
|
115
|
+
"table": {
|
|
116
|
+
"label": "Data Table",
|
|
117
|
+
"expanded": false,
|
|
118
|
+
"limitHeight": false,
|
|
119
|
+
"height": "",
|
|
120
|
+
"caption": "",
|
|
121
|
+
"showDownloadUrl": false,
|
|
122
|
+
"showDataTableLink": true,
|
|
123
|
+
"show": true
|
|
124
|
+
},
|
|
125
|
+
"orientation": "vertical",
|
|
126
|
+
"legend": {
|
|
127
|
+
"behavior": "isolate",
|
|
128
|
+
"singleRow": false,
|
|
129
|
+
"colorCode": "",
|
|
130
|
+
"reverseLabelOrder": false,
|
|
131
|
+
"description": "",
|
|
132
|
+
"dynamicLegend": false,
|
|
133
|
+
"dynamicLegendDefaultText": "Show All",
|
|
134
|
+
"dynamicLegendItemLimit": 5,
|
|
135
|
+
"dynamicLegendItemLimitMessage": "Dynamic Legend Item Limit Hit.",
|
|
136
|
+
"dynamicLegendChartMessage": "Select Options from the Legend",
|
|
137
|
+
"position": "right",
|
|
138
|
+
"hide": false
|
|
139
|
+
},
|
|
140
|
+
"exclusions": {
|
|
141
|
+
"active": false,
|
|
142
|
+
"keys": []
|
|
143
|
+
},
|
|
144
|
+
"palette": "sequential-green",
|
|
145
|
+
"isPaletteReversed": false,
|
|
146
|
+
"twoColor": {
|
|
147
|
+
"palette": "monochrome-1",
|
|
148
|
+
"isPaletteReversed": false
|
|
149
|
+
},
|
|
150
|
+
"labels": false,
|
|
151
|
+
"dataFormat": {
|
|
152
|
+
"commas": false,
|
|
153
|
+
"prefix": "",
|
|
154
|
+
"suffix": "",
|
|
155
|
+
"abbreviated": false,
|
|
156
|
+
"bottomSuffix": "",
|
|
157
|
+
"bottomPrefix": "",
|
|
158
|
+
"bottomAbbreviated": false,
|
|
159
|
+
"roundTo": "0"
|
|
160
|
+
},
|
|
161
|
+
"confidenceKeys": {},
|
|
162
|
+
"visual": {
|
|
163
|
+
"border": true,
|
|
164
|
+
"accent": true,
|
|
165
|
+
"background": true
|
|
166
|
+
},
|
|
167
|
+
"filterBehavior": "Filter Change",
|
|
168
|
+
"forecastingChart": {
|
|
169
|
+
"showBars": false,
|
|
170
|
+
"barColumn": "confirm",
|
|
171
|
+
"barColor": "#918e90",
|
|
172
|
+
"confidenceIntervals": [
|
|
173
|
+
{
|
|
174
|
+
"low": "lower_20",
|
|
175
|
+
"high": "upper_20"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"low": "lower_50",
|
|
179
|
+
"high": "upper_50"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"low": "lower_90",
|
|
183
|
+
"high": "upper_90"
|
|
184
|
+
}
|
|
185
|
+
],
|
|
186
|
+
"stages": "type",
|
|
187
|
+
"colors": [
|
|
188
|
+
"sequential-greenreverse",
|
|
189
|
+
"sequential-orange-(MPX)reverse",
|
|
190
|
+
"sequential-blue-2-(MPX)reverse"
|
|
191
|
+
],
|
|
192
|
+
"groups": [
|
|
193
|
+
"estimate",
|
|
194
|
+
"estimate based on partial data",
|
|
195
|
+
"forecast"
|
|
196
|
+
],
|
|
197
|
+
"showBarColumn": true
|
|
198
|
+
},
|
|
199
|
+
"dataUrl": "./examples/feature/forecasting/case_date_example.csv",
|
|
200
|
+
"animateReplay": true,
|
|
201
|
+
"visualizationType": "Forecasting",
|
|
202
|
+
"series": []
|
|
203
|
+
}
|
|
@@ -1 +1,173 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"type": "chart",
|
|
3
|
+
"title": "Example Line Chart",
|
|
4
|
+
"theme": "theme-green",
|
|
5
|
+
"animate": true,
|
|
6
|
+
"fontSize": "medium",
|
|
7
|
+
"lineDatapointStyle": "hover",
|
|
8
|
+
"barHasBorder": "false",
|
|
9
|
+
"isLollipopChart": false,
|
|
10
|
+
"lollipopShape": "circle",
|
|
11
|
+
"lollipopColorStyle": "two-tone",
|
|
12
|
+
"visualizationSubType": "regular",
|
|
13
|
+
"barStyle": "",
|
|
14
|
+
"roundingStyle": "standard",
|
|
15
|
+
"tipRounding": "top",
|
|
16
|
+
"padding": {
|
|
17
|
+
"left": 5,
|
|
18
|
+
"right": 5
|
|
19
|
+
},
|
|
20
|
+
"yAxis": {
|
|
21
|
+
"hideAxis": false,
|
|
22
|
+
"displayNumbersOnBar": false,
|
|
23
|
+
"hideLabel": false,
|
|
24
|
+
"hideTicks": false,
|
|
25
|
+
"size": "75",
|
|
26
|
+
"gridLines": false,
|
|
27
|
+
"min": "",
|
|
28
|
+
"max": "",
|
|
29
|
+
"label": "Y-Axis Example Label",
|
|
30
|
+
"numTicks": "9"
|
|
31
|
+
},
|
|
32
|
+
"barThickness": 0.35,
|
|
33
|
+
"barHeight": 25,
|
|
34
|
+
"height": "375",
|
|
35
|
+
"xAxis": {
|
|
36
|
+
"type": "date",
|
|
37
|
+
"hideAxis": false,
|
|
38
|
+
"hideLabel": false,
|
|
39
|
+
"hideTicks": false,
|
|
40
|
+
"size": "77",
|
|
41
|
+
"tickRotation": "25",
|
|
42
|
+
"min": "",
|
|
43
|
+
"max": "",
|
|
44
|
+
"dataKey": "Date",
|
|
45
|
+
"label": "X-Axis Example Label",
|
|
46
|
+
"dateParseFormat": "%d/%m/%Y",
|
|
47
|
+
"dateDisplayFormat": "%d/%m/%Y"
|
|
48
|
+
},
|
|
49
|
+
"table": {
|
|
50
|
+
"label": "Data Table",
|
|
51
|
+
"expanded": true,
|
|
52
|
+
"limitHeight": false,
|
|
53
|
+
"height": "",
|
|
54
|
+
"caption": "",
|
|
55
|
+
"download": true,
|
|
56
|
+
"show": true
|
|
57
|
+
},
|
|
58
|
+
"orientation": "vertical",
|
|
59
|
+
"legend": {
|
|
60
|
+
"behavior": "isolate",
|
|
61
|
+
"position": "right",
|
|
62
|
+
"colorCode": "",
|
|
63
|
+
"reverseLabelOrder": false,
|
|
64
|
+
"description": "",
|
|
65
|
+
"dynamicLegend": false,
|
|
66
|
+
"dynamicLegendDefaultText": "Show All",
|
|
67
|
+
"dynamicLegendItemLimit": 5,
|
|
68
|
+
"dynamicLegendItemLimitMessage": "Dynamic Legend Item Limit Hit.",
|
|
69
|
+
"dynamicLegendChartMessage": "Select Options from the Legend",
|
|
70
|
+
"label": "Type of Data"
|
|
71
|
+
},
|
|
72
|
+
"exclusions": {
|
|
73
|
+
"active": false,
|
|
74
|
+
"keys": []
|
|
75
|
+
},
|
|
76
|
+
"palette": "qualitative-bold",
|
|
77
|
+
"isPaletteReversed": false,
|
|
78
|
+
"labels": false,
|
|
79
|
+
"dataFormat": {
|
|
80
|
+
"commas": false,
|
|
81
|
+
"prefix": "",
|
|
82
|
+
"suffix": ""
|
|
83
|
+
},
|
|
84
|
+
"confidenceKeys": {},
|
|
85
|
+
"visual": {
|
|
86
|
+
"border": true,
|
|
87
|
+
"accent": true,
|
|
88
|
+
"background": true
|
|
89
|
+
},
|
|
90
|
+
"data": [
|
|
91
|
+
{
|
|
92
|
+
"Date": "1/15/2016",
|
|
93
|
+
"Data 1": "90",
|
|
94
|
+
"Data 2": "135",
|
|
95
|
+
"Data 3": "300",
|
|
96
|
+
"Data 4": "95",
|
|
97
|
+
"Data 5": "120",
|
|
98
|
+
"Data 6": "310"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"Date": "2/15/2016",
|
|
102
|
+
"Data 1": "40",
|
|
103
|
+
"Data 2": "90",
|
|
104
|
+
"Data 3": "240",
|
|
105
|
+
"Data 4": "60",
|
|
106
|
+
"Data 5": "160",
|
|
107
|
+
"Data 6": "200"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"Date": "3/15/2016",
|
|
111
|
+
"Data 1": "50",
|
|
112
|
+
"Data 2": "300",
|
|
113
|
+
"Data 3": "290",
|
|
114
|
+
"Data 4": "100",
|
|
115
|
+
"Data 5": "200",
|
|
116
|
+
"Data 6": "250"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"Date": "4/15/2016",
|
|
120
|
+
"Data 1": "120",
|
|
121
|
+
"Data 2": "160",
|
|
122
|
+
"Data 3": "230",
|
|
123
|
+
"Data 4": "180",
|
|
124
|
+
"Data 5": "160",
|
|
125
|
+
"Data 6": "220"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"Date": "5/15/2016",
|
|
129
|
+
"Data 1": "80",
|
|
130
|
+
"Data 2": "350",
|
|
131
|
+
"Data 3": "300",
|
|
132
|
+
"Data 4": "150",
|
|
133
|
+
"Data 5": "130",
|
|
134
|
+
"Data 6": "100"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"Date": "6/15/2016",
|
|
138
|
+
"Data 1": "90",
|
|
139
|
+
"Data 2": "220",
|
|
140
|
+
"Data 3": "320",
|
|
141
|
+
"Data 4": "100",
|
|
142
|
+
"Data 5": "220",
|
|
143
|
+
"Data 6": "300"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"visualizationType": "Line",
|
|
147
|
+
"series": [
|
|
148
|
+
{
|
|
149
|
+
"dataKey": "Data 1",
|
|
150
|
+
"type": "Bar"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"dataKey": "Data 2",
|
|
154
|
+
"type": "Bar"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"dataKey": "Data 3",
|
|
158
|
+
"type": "Bar"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"dataKey": "Data 4",
|
|
162
|
+
"type": "Bar"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"dataKey": "Data 5",
|
|
166
|
+
"type": "Bar"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"dataKey": "Data 6",
|
|
170
|
+
"type": "Bar"
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
package/index.html
CHANGED
|
@@ -34,22 +34,28 @@
|
|
|
34
34
|
-->
|
|
35
35
|
|
|
36
36
|
<!-- GENERIC CHART TYPES -->
|
|
37
|
-
<div class="react-container" data-config="/examples/
|
|
37
|
+
<!-- <div class="react-container" data-config="/examples/private/datatable-issue.json"></div> -->
|
|
38
|
+
<!-- <div class="react-container" data-config="/examples/feature/filters/filter-testing.json"></div> -->
|
|
38
39
|
<!-- <div class="react-container" data-config="/examples/feature/pie/planet-pie-example-config.json"></div> -->
|
|
39
40
|
<!-- <div class="react-container" data-config="/examples/feature/line/line-chart.json"></div> -->
|
|
40
|
-
<!-- <div class="react-container" data-config="/examples/feature/
|
|
41
|
-
<!-- <div class="react-container" data-config="/examples/feature/
|
|
42
|
-
<!-- <div class="react-container" data-config="/examples/feature/
|
|
41
|
+
<!-- <div class="react-container" data-config="/examples/feature/forecasting/index.json"></div> -->
|
|
42
|
+
<!-- <div class="react-container" data-config="/examples/feature/forecasting/forecasting.json"></div> -->
|
|
43
|
+
<!-- <div class="react-container" data-config="/examples/feature/forecasting/combo-forecasting.json"></div> -->
|
|
44
|
+
<!-- <div class="react-container" data-config="/examples/feature/forecasting/non-combo-forecasting.json"></div> -->
|
|
45
|
+
<!-- <div class="react-container" data-config="/examples/feature/forecasting/effective_reproduction.json"></div> -->
|
|
43
46
|
<!-- <div class="react-container" data-config="/examples/feature/area/area-chart-date.json"></div> -->
|
|
47
|
+
<!-- <div class="react-container" data-config="/examples/feature/area/area-chart-category.json"></div> -->
|
|
44
48
|
<!-- <div class="react-container" data-config="/examples/feature/scatterplot/scatterplot.json"></div> -->
|
|
45
49
|
<!-- <div class="react-container" data-config="/examples/feature/deviation/planet-deviation-config.json"></div> -->
|
|
46
50
|
<!-- <div class="react-container" data-config="/examples/feature/boxplot/boxplot.json"></div> -->
|
|
47
51
|
<!-- <div class="react-container" data-config="/examples/feature/combo/planet-combo-example-config.json"></div> -->
|
|
52
|
+
<!-- <div class="react-container" data-config="/examples/feature/combo/right-issues.json"></div> -->
|
|
48
53
|
<!-- <div class="react-container" data-config="/examples/feature/paired-bar/paired-bar-example.json"></div> -->
|
|
49
54
|
|
|
50
55
|
<!-- BAR -->
|
|
51
56
|
<!-- <div class="react-container" data-config="/examples/feature/bar/planet-example-config.json"></div> -->
|
|
52
57
|
<!-- <div class="react-container" data-config="/examples/feature/bar/planet-chart-horizontal-example-config.json"></div> -->
|
|
58
|
+
<!-- <div class="react-container" data-config="/examples/feature/bar/new.json"></div> -->
|
|
53
59
|
<!-- <div class="react-container" data-config="/examples/feature/bar/example-bar-chart.json"></div> -->
|
|
54
60
|
<!-- <div class="react-container" data-config="/examples/feature/bar/horizontal-chart-max-increase.json"></div> -->
|
|
55
61
|
<!-- <div class="react-container" data-config="/examples/feature/bar/horizontal-chart.json"></div> -->
|
|
@@ -71,10 +77,10 @@
|
|
|
71
77
|
|
|
72
78
|
<!-- TESTS NONNUMERICS -->
|
|
73
79
|
<!-- <div class="react-container" data-config="/examples/feature/tests-non-numerics/planet-pie-example-config-nonnumeric.json"></div> -->
|
|
74
|
-
|
|
80
|
+
<div class="react-container" data-config="/examples/feature/tests-non-numerics/example-combo-bar-nonnumeric.json"></div>
|
|
75
81
|
<!-- <div class="react-container" data-config="/examples/feature/tests-non-numerics/example-bar-chart-nonnumeric.json"></div> -->
|
|
76
82
|
<!-- <div class="react-container" data-config="/examples/feature/tests-non-numerics/sparkline-chart-nonnumeric.json"></div> -->
|
|
77
|
-
<div class="react-container" data-config="/examples/feature/tests-non-numerics/stacked-vertical-bar-example-nonnumerics.json"></div>
|
|
83
|
+
<!-- <div class="react-container" data-config="/examples/feature/tests-non-numerics/stacked-vertical-bar-example-nonnumerics.json"></div> -->
|
|
78
84
|
|
|
79
85
|
<!-- TESTS CUTOFF -->
|
|
80
86
|
<!-- <div class="react-container" data-config="/examples/feature/tests-cutoff/cutoff-example-config.json"></div> -->
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/chart",
|
|
3
|
-
"version": "4.23.
|
|
3
|
+
"version": "4.23.6",
|
|
4
4
|
"description": "React component for visualizing tabular data in various types of charts",
|
|
5
5
|
"moduleName": "CdcChart",
|
|
6
6
|
"main": "dist/cdcchart",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"react": "^18.2.0",
|
|
58
58
|
"react-dom": "^18.2.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "aaed0388b487adfeb3e7e278b4ce74df09cbaade",
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"resize-observer-polyfill": "^1.5.1"
|
|
63
63
|
}
|
package/src/CdcChart.jsx
CHANGED
|
@@ -31,7 +31,7 @@ import defaults from './data/initial-state'
|
|
|
31
31
|
import EditorPanel from './components/EditorPanel'
|
|
32
32
|
import Loading from '@cdc/core/components/Loading'
|
|
33
33
|
import Filters from '@cdc/core/components/Filters'
|
|
34
|
-
import
|
|
34
|
+
import MediaControls from '@cdc/core/components/MediaControls'
|
|
35
35
|
|
|
36
36
|
// Helpers
|
|
37
37
|
import numberFromString from '@cdc/core/helpers/numberFromString'
|
|
@@ -39,6 +39,7 @@ import getViewport from '@cdc/core/helpers/getViewport'
|
|
|
39
39
|
import { DataTransform } from '@cdc/core/helpers/DataTransform'
|
|
40
40
|
import cacheBustingString from '@cdc/core/helpers/cacheBustingString'
|
|
41
41
|
import isNumber from '@cdc/core/helpers/isNumber'
|
|
42
|
+
import coveUpdateWorker from '@cdc/core/helpers/coveUpdateWorker'
|
|
42
43
|
|
|
43
44
|
import './scss/main.scss'
|
|
44
45
|
// load both then config below determines which to use
|
|
@@ -72,7 +73,10 @@ const hashObj = row => {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
// * FILE REVIEW
|
|
77
|
+
// TODO: @tturnerswdev33 - remove/fix mentions of runtimeLegend that were added
|
|
78
|
+
|
|
79
|
+
export default function CdcChart({ configUrl, config: configObj, isEditor = false, isDebug = false, isDashboard = false, setConfig: setParentConfig, setEditing, hostname, link, setSharedFilter, setSharedFilterValue, dashboardConfig }) {
|
|
76
80
|
const transform = new DataTransform()
|
|
77
81
|
const [loading, setLoading] = useState(true)
|
|
78
82
|
const [colorScale, setColorScale] = useState(null)
|
|
@@ -261,10 +265,20 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
|
|
|
261
265
|
data = await fetch(response.dataUrl + `?v=${cacheBustingString()}`)
|
|
262
266
|
.then(response => response.text())
|
|
263
267
|
.then(responseText => {
|
|
268
|
+
// for every comma NOT inside quotes, replace with a pipe delimiter
|
|
269
|
+
// - this will let commas inside the quotes not be parsed as a new column
|
|
270
|
+
// - Limitation: if a delimiter other than comma is used in the csv this will break
|
|
271
|
+
// Examples of other delimiters that would break: tab
|
|
272
|
+
responseText = responseText.replace(/(".*?")|,/g, (...m) => m[1] || '|')
|
|
273
|
+
// now strip the double quotes
|
|
274
|
+
responseText = responseText.replace(/["]+/g, '')
|
|
264
275
|
const parsedCsv = Papa.parse(responseText, {
|
|
276
|
+
//quotes: "true", // dont need these
|
|
277
|
+
//quoteChar: "'", // has no effect that I can tell
|
|
265
278
|
header: true,
|
|
266
279
|
dynamicTyping: true,
|
|
267
|
-
skipEmptyLines: true
|
|
280
|
+
skipEmptyLines: true,
|
|
281
|
+
delimiter: '|' // we are using pipe symbol as delimiter so setting this explicitly for Papa.parse
|
|
268
282
|
})
|
|
269
283
|
return parsedCsv.data
|
|
270
284
|
})
|
|
@@ -302,7 +316,9 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
|
|
|
302
316
|
}
|
|
303
317
|
if (undefined === newConfig.table.show) newConfig.table.show = !isDashboard
|
|
304
318
|
|
|
305
|
-
|
|
319
|
+
const processedConfig = { ...(await coveUpdateWorker(newConfig)) }
|
|
320
|
+
|
|
321
|
+
updateConfig(processedConfig, data)
|
|
306
322
|
}
|
|
307
323
|
|
|
308
324
|
const updateConfig = (newConfig, dataOverride = undefined) => {
|
|
@@ -315,7 +331,6 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
|
|
|
315
331
|
}
|
|
316
332
|
})
|
|
317
333
|
|
|
318
|
-
// Loop through and set initial data with exclusions - this should persist through any following data transformations (ie. filters)
|
|
319
334
|
let newExcludedData
|
|
320
335
|
|
|
321
336
|
if (newConfig.exclusions && newConfig.exclusions.active) {
|
|
@@ -512,11 +527,15 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
|
|
|
512
527
|
newConfig.runtime.barSeriesKeys = []
|
|
513
528
|
newConfig.runtime.lineSeriesKeys = []
|
|
514
529
|
newConfig.runtime.areaSeriesKeys = []
|
|
530
|
+
newConfig.runtime.forecastingSeriesKeys = []
|
|
515
531
|
|
|
516
532
|
newConfig.series.forEach(series => {
|
|
517
533
|
if (series.type === 'Area Chart') {
|
|
518
534
|
newConfig.runtime.areaSeriesKeys.push(series)
|
|
519
535
|
}
|
|
536
|
+
if (series.type === 'Forecasting') {
|
|
537
|
+
newConfig.runtime.forecastingSeriesKeys.push(series)
|
|
538
|
+
}
|
|
520
539
|
if (series.type === 'Bar') {
|
|
521
540
|
newConfig.runtime.barSeriesKeys.push(series.dataKey)
|
|
522
541
|
}
|
|
@@ -525,6 +544,17 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
|
|
|
525
544
|
}
|
|
526
545
|
})
|
|
527
546
|
}
|
|
547
|
+
|
|
548
|
+
if (newConfig.visualizationType === 'Forecasting' && newConfig.series) {
|
|
549
|
+
newConfig.runtime.forecastingSeriesKeys = []
|
|
550
|
+
|
|
551
|
+
newConfig.series.forEach(series => {
|
|
552
|
+
if (series.type === 'Forecasting') {
|
|
553
|
+
newConfig.runtime.forecastingSeriesKeys.push(series)
|
|
554
|
+
}
|
|
555
|
+
})
|
|
556
|
+
}
|
|
557
|
+
|
|
528
558
|
if (newConfig.visualizationType === 'Area Chart' && newConfig.series) {
|
|
529
559
|
newConfig.runtime.areaSeriesKeys = []
|
|
530
560
|
|
|
@@ -740,7 +770,7 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
|
|
|
740
770
|
const newSeriesHighlight = []
|
|
741
771
|
|
|
742
772
|
// If we're highlighting all the series, reset them
|
|
743
|
-
if (seriesHighlight.length + 1 === config.runtime.seriesKeys.length && !config.legend.dynamicLegend) {
|
|
773
|
+
if (seriesHighlight.length + 1 === config.runtime.seriesKeys.length && !config.legend.dynamicLegend && config.visualizationType !== 'Forecasting') {
|
|
744
774
|
highlightReset()
|
|
745
775
|
return
|
|
746
776
|
}
|
|
@@ -942,6 +972,7 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
|
|
|
942
972
|
// Select appropriate chart type
|
|
943
973
|
const chartComponents = {
|
|
944
974
|
'Paired Bar': <LinearChart />,
|
|
975
|
+
Forecasting: <LinearChart />,
|
|
945
976
|
Bar: <LinearChart />,
|
|
946
977
|
Line: <LinearChart />,
|
|
947
978
|
Combo: <LinearChart />,
|
|
@@ -953,6 +984,7 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
|
|
|
953
984
|
}
|
|
954
985
|
|
|
955
986
|
const missingRequiredSections = () => {
|
|
987
|
+
if (config.visualizationType === 'Forecasting') return false // skip required checks for now.
|
|
956
988
|
if (config.visualizationType === 'Pie') {
|
|
957
989
|
if (undefined === config?.yAxis.dataKey) {
|
|
958
990
|
return true
|
|
@@ -1069,6 +1101,8 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
|
|
|
1069
1101
|
}
|
|
1070
1102
|
|
|
1071
1103
|
const clean = data => {
|
|
1104
|
+
// cleaning is deleting data we need in forecasting charts.
|
|
1105
|
+
if (config.visualizationType === 'Forecasting') return data
|
|
1072
1106
|
return config?.xAxis?.dataKey ? transform.cleanData(data, config.xAxis.dataKey) : data
|
|
1073
1107
|
}
|
|
1074
1108
|
|
|
@@ -1136,10 +1170,10 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
|
|
|
1136
1170
|
{description && config.visualizationType !== 'Spark Line' && <div className='subtext'>{parse(description)}</div>}
|
|
1137
1171
|
|
|
1138
1172
|
{/* buttons */}
|
|
1139
|
-
<
|
|
1140
|
-
{config.table.showDownloadImgButton && <
|
|
1141
|
-
{config.table.showDownloadPdfButton && <
|
|
1142
|
-
</
|
|
1173
|
+
<MediaControls.Section classes={['download-buttons']}>
|
|
1174
|
+
{config.table.showDownloadImgButton && <MediaControls.Button text='Download Image' title='Download Chart as Image' type='image' state={config} elementToCapture={imageId} />}
|
|
1175
|
+
{config.table.showDownloadPdfButton && <MediaControls.Button text='Download PDF' title='Download Chart as PDF' type='pdf' state={config} elementToCapture={imageId} />}
|
|
1176
|
+
</MediaControls.Section>
|
|
1143
1177
|
|
|
1144
1178
|
{/* Data Table */}
|
|
1145
1179
|
{config.xAxis.dataKey && config.table.show && config.visualizationType !== 'Spark Line' && (
|
|
@@ -1222,7 +1256,10 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
|
|
|
1222
1256
|
isNumber,
|
|
1223
1257
|
getTextWidth,
|
|
1224
1258
|
twoColorPalette,
|
|
1225
|
-
isDebug
|
|
1259
|
+
isDebug,
|
|
1260
|
+
setSharedFilter,
|
|
1261
|
+
setSharedFilterValue,
|
|
1262
|
+
dashboardConfig
|
|
1226
1263
|
}
|
|
1227
1264
|
|
|
1228
1265
|
const classes = ['cdc-open-viz-module', 'type-chart', `${currentViewport}`, `font-${config.fontSize}`, `${config.theme}`]
|