@cdc/chart 1.3.4 → 4.22.10

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.
Files changed (50) hide show
  1. package/LICENSE +201 -0
  2. package/dist/cdcchart.js +6 -6
  3. package/examples/cutoff-example-config.json +2 -0
  4. package/examples/cutoff-example-data.json +1 -1
  5. package/examples/dynamic-legends.json +125 -0
  6. package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart-with-numbers-on-bar.json +198 -0
  7. package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart.json +241 -0
  8. package/examples/gallery/bar-chart-horizontal/horizontal-stacked.json +248 -0
  9. package/examples/gallery/bar-chart-vertical/combo-line-chart.json +137 -0
  10. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-categorical.json +80 -0
  11. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +81 -0
  12. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-with-confidence.json +68 -0
  13. package/examples/gallery/bar-chart-vertical/vertical-bar-chart.json +111 -0
  14. package/examples/gallery/lollipop/lollipop-style-horizontal.json +220 -0
  15. package/examples/gallery/paired-bar/paired-bar-chart.json +196 -0
  16. package/examples/horizontal-chart.json +3 -0
  17. package/examples/paired-bar-data.json +1 -1
  18. package/examples/paired-bar-example.json +2 -0
  19. package/examples/planet-combo-example-config.json +2 -0
  20. package/examples/planet-example-config.json +2 -2
  21. package/examples/planet-example-data.json +1 -1
  22. package/examples/planet-pie-example-config.json +2 -0
  23. package/examples/private/line-test-data.json +22 -0
  24. package/examples/private/line-test-two.json +216 -0
  25. package/examples/private/line-test.json +102 -0
  26. package/examples/private/shawn.json +1296 -0
  27. package/examples/private/yaxis-test.json +132 -0
  28. package/examples/private/yaxis-testing.csv +27 -0
  29. package/examples/private/yaxis.json +28 -0
  30. package/examples/stacked-vertical-bar-example.json +228 -0
  31. package/package.json +2 -2
  32. package/src/CdcChart.tsx +121 -168
  33. package/src/components/BarChart.tsx +92 -40
  34. package/src/components/DataTable.tsx +28 -13
  35. package/src/components/EditorPanel.js +286 -182
  36. package/src/components/Legend.js +334 -0
  37. package/src/components/LineChart.tsx +57 -17
  38. package/src/components/LinearChart.tsx +171 -77
  39. package/src/components/PairedBarChart.tsx +139 -42
  40. package/src/components/PieChart.tsx +33 -6
  41. package/src/components/SparkLine.js +28 -27
  42. package/src/components/useIntersectionObserver.tsx +30 -0
  43. package/src/data/initial-state.js +23 -7
  44. package/src/hooks/useChartClasses.js +35 -0
  45. package/src/hooks/useLegendClasses.js +20 -0
  46. package/src/hooks/useReduceData.ts +72 -24
  47. package/src/index.html +29 -30
  48. package/src/scss/editor-panel.scss +34 -4
  49. package/src/scss/main.scss +201 -5
  50. package/src/components/BarStackVertical.js +0 -0
@@ -0,0 +1,248 @@
1
+ {
2
+ "type": "chart",
3
+ "title": "Example Stacked Horizontal Bar Chart",
4
+ "theme": "theme-blue",
5
+ "fontSize": "small",
6
+ "lineDatapointStyle": "hover",
7
+ "barHasBorder": "true",
8
+ "isLollipopChart": false,
9
+ "lollipopShape": "circle",
10
+ "lollipopColorStyle": "two-tone",
11
+ "visualizationSubType": "stacked",
12
+ "padding": {
13
+ "left": 5,
14
+ "right": 5
15
+ },
16
+ "yAxis": {
17
+ "hideAxis": true,
18
+ "hideLabel": false,
19
+ "hideTicks": false,
20
+ "size": "13",
21
+ "gridLines": false,
22
+ "type": "chart",
23
+ "title": "",
24
+ "theme": "theme-blue",
25
+ "fontSize": "medium",
26
+ "lineDatapointStyle": "hover",
27
+ "barHasBorder": "false",
28
+ "isLollipopChart": false,
29
+ "lollipopShape": "circle",
30
+ "lollipopColorStyle": "two-tone",
31
+ "visualizationSubType": "stacked",
32
+ "padding": {
33
+ "left": 5,
34
+ "right": 5
35
+ },
36
+ "yAxis": {
37
+ "hideAxis": false,
38
+ "hideLabel": false,
39
+ "hideTicks": false,
40
+ "size": 50,
41
+ "gridLines": false
42
+ },
43
+ "barThickness": 0.35,
44
+ "height": 260,
45
+ "xAxis": {
46
+ "type": "categorical",
47
+ "hideAxis": false,
48
+ "hideLabel": false,
49
+ "hideTicks": false,
50
+ "size": 75,
51
+ "tickRotation": 0,
52
+ "dataKey": "Year"
53
+ },
54
+ "table": {
55
+ "label": "Data Table",
56
+ "expanded": true,
57
+ "show": true
58
+ },
59
+ "orientation": "horizontal",
60
+ "legend": {
61
+ "behavior": "isolate",
62
+ "position": "right"
63
+ },
64
+ "exclusions": {
65
+ "active": false,
66
+ "keys": []
67
+ },
68
+ "palette": "qualitative-bold",
69
+ "isPaletteReversed": false,
70
+ "labels": false,
71
+ "dataFormat": {},
72
+ "confidenceKeys": {},
73
+ "data": [
74
+ {
75
+ "Year": "2015",
76
+ "Data 1": "25",
77
+ "Data 2": "20",
78
+ "Data 3": "55"
79
+ },
80
+ {
81
+ "Year": "2016",
82
+ "Data 1": "35",
83
+ "Data 2": "30",
84
+ "Data 3": "35"
85
+ },
86
+ {
87
+ "Year": "2017",
88
+ "Data 1": "22",
89
+ "Data 2": "38",
90
+ "Data 3": "40"
91
+ },
92
+ {
93
+ "Year": "2018",
94
+ "Data 1": "40",
95
+ "Data 2": "40",
96
+ "Data 3": "20"
97
+ }
98
+ ],
99
+ "dataFileName": "JSON_Source_Data_Example_Viz_Stacked.json",
100
+ "dataFileSourceType": "file",
101
+ "visualizationType": "Bar",
102
+ "runtime": {
103
+ "seriesLabels": {
104
+ "Data 1": "Data 1",
105
+ "Data 2": "Data 2",
106
+ "Data 3": "Data 3"
107
+ },
108
+ "seriesLabelsAll": [
109
+ "Data 1",
110
+ "Data 2",
111
+ "Data 3"
112
+ ],
113
+ "originalXAxis": {
114
+ "type": "categorical",
115
+ "hideAxis": false,
116
+ "hideLabel": false,
117
+ "hideTicks": false,
118
+ "size": 75,
119
+ "tickRotation": 0,
120
+ "dataKey": "Year"
121
+ },
122
+ "seriesKeys": [
123
+ "Data 1",
124
+ "Data 2",
125
+ "Data 3"
126
+ ],
127
+ "xAxis": {
128
+ "hideAxis": false,
129
+ "hideLabel": false,
130
+ "hideTicks": false,
131
+ "size": 50,
132
+ "gridLines": false
133
+ },
134
+ "yAxis": {
135
+ "type": "categorical",
136
+ "hideAxis": false,
137
+ "hideLabel": false,
138
+ "hideTicks": false,
139
+ "size": 75,
140
+ "tickRotation": 0,
141
+ "dataKey": "Year"
142
+ },
143
+ "horizontal": true,
144
+ "uniqueId": 1654259674387,
145
+ "editorErrorMessage": ""
146
+ },
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
+ "barHeight": 25,
162
+ "barPadding": 40,
163
+ "labelPlacement": "Below Bar",
164
+ "displayNumbersOnBar": true,
165
+ "label": ""
166
+ },
167
+ "barThickness": 0.35,
168
+ "height": 288,
169
+ "xAxis": {
170
+ "type": "categorical",
171
+ "hideAxis": true,
172
+ "hideLabel": true,
173
+ "hideTicks": true,
174
+ "size": "45",
175
+ "tickRotation": 0,
176
+ "dataKey": "Year",
177
+ "label": "Year"
178
+ },
179
+ "table": {
180
+ "label": "Data Table",
181
+ "expanded": false,
182
+ "show": true,
183
+ "indexLabel": "Data Type"
184
+ },
185
+ "orientation": "horizontal",
186
+ "legend": {
187
+ "behavior": "isolate",
188
+ "position": "right",
189
+ "reverseLabelOrder": false
190
+ },
191
+ "exclusions": {
192
+ "active": false,
193
+ "keys": []
194
+ },
195
+ "palette": "qualitative-soft",
196
+ "isPaletteReversed": false,
197
+ "labels": false,
198
+ "dataFormat": {
199
+ "suffix": "%"
200
+ },
201
+ "confidenceKeys": {},
202
+ "data": [
203
+ {
204
+ "Year": "2015",
205
+ "Data 1": "25",
206
+ "Data 2": "20",
207
+ "Data 3": "55"
208
+ },
209
+ {
210
+ "Year": "2016",
211
+ "Data 1": "35",
212
+ "Data 2": "30",
213
+ "Data 3": "35"
214
+ },
215
+ {
216
+ "Year": "2017",
217
+ "Data 1": "22",
218
+ "Data 2": "38",
219
+ "Data 3": "40"
220
+ },
221
+ {
222
+ "Year": "2018",
223
+ "Data 1": "40",
224
+ "Data 2": "40",
225
+ "Data 3": "20"
226
+ }
227
+ ],
228
+ "dataFileName": "JSON_Source_Data_Example_Viz_Stacked.json",
229
+ "dataFileSourceType": "file",
230
+ "visualizationType": "Bar",
231
+ "series": [
232
+ {
233
+ "dataKey": "Data 1",
234
+ "type": "Bar"
235
+ },
236
+ {
237
+ "dataKey": "Data 2",
238
+ "type": "Bar"
239
+ },
240
+ {
241
+ "dataKey": "Data 3",
242
+ "type": "Bar"
243
+ }
244
+ ],
245
+ "barHeight": 32,
246
+ "barPadding": 40,
247
+ "description": "Subtext"
248
+ }
@@ -0,0 +1,137 @@
1
+ {
2
+ "type": "chart",
3
+ "title": "Combo Bar-Line Chart",
4
+ "theme": "theme-purple",
5
+ "fontSize": "medium",
6
+ "height": "332",
7
+ "padding": {
8
+ "left": 5,
9
+ "right": 5
10
+ },
11
+ "yAxis": {
12
+ "size": "68",
13
+ "gridLines": true,
14
+ "label": "Y-Axis Label Example"
15
+ },
16
+ "barThickness": 0.35,
17
+ "xAxis": {
18
+ "size": "78",
19
+ "tickRotation": "25",
20
+ "dataKey": "Date",
21
+ "label": "X-Axis Example Label",
22
+ "type": "date",
23
+ "dateParseFormat": "%d/%m/%Y",
24
+ "dateDisplayFormat": "%d/%m/%Y"
25
+ },
26
+ "table": {
27
+ "label": "Data Table",
28
+ "expanded": true,
29
+ "download": true
30
+ },
31
+ "legend": {
32
+ "behavior": "highlight",
33
+ "position": "right",
34
+ "label": "Data Type"
35
+ },
36
+ "palette": "qualitative-soft",
37
+ "labels": false,
38
+ "dataFormat": {},
39
+ "confidenceKeys": {},
40
+ "data": [
41
+ {
42
+ "Date": "1/15/2016",
43
+ "Data 1": "90",
44
+ "Data 2": "110",
45
+ "Data 3": "100",
46
+ "Data 4": "90",
47
+ "Monthly-Goal": "100"
48
+ },
49
+ {
50
+ "Date": "2/15/2016",
51
+ "Data 1": "100",
52
+ "Data 2": "110",
53
+ "Data 3": "100",
54
+ "Data 4": "100",
55
+ "Monthly-Goal": "100"
56
+ },
57
+ {
58
+ "Date": "3/15/2016",
59
+ "Data 1": "80",
60
+ "Data 2": "90",
61
+ "Data 3": "100",
62
+ "Data 4": "120",
63
+ "Monthly-Goal": "110"
64
+ },
65
+ {
66
+ "Date": "4/15/2016",
67
+ "Data 1": "80",
68
+ "Data 2": "90",
69
+ "Data 3": "110",
70
+ "Data 4": "120",
71
+ "Monthly-Goal": "110"
72
+ },
73
+ {
74
+ "Date": "5/15/2016",
75
+ "Data 1": "70",
76
+ "Data 2": "90",
77
+ "Data 3": "110",
78
+ "Data 4": "130",
79
+ "Monthly-Goal": "120"
80
+ },
81
+ {
82
+ "Date": "6/15/2016",
83
+ "Data 1": "100",
84
+ "Data 2": "120",
85
+ "Data 3": "120",
86
+ "Data 4": "130",
87
+ "Monthly-Goal": "120"
88
+ },
89
+ {
90
+ "Date": "7/15/2016",
91
+ "Data 1": "110",
92
+ "Data 2": "140",
93
+ "Data 3": "120",
94
+ "Data 4": "130",
95
+ "Monthly-Goal": "130"
96
+ },
97
+ {
98
+ "Date": "8/15/2016",
99
+ "Data 1": "110",
100
+ "Data 2": "130",
101
+ "Data 3": "120",
102
+ "Data 4": "140",
103
+ "Monthly-Goal": "130"
104
+ },
105
+ {
106
+ "Date": "9/15/2016",
107
+ "Data 1": "120",
108
+ "Data 2": "130",
109
+ "Data 3": "120",
110
+ "Data 4": "150",
111
+ "Monthly-Goal": "140"
112
+ }
113
+ ],
114
+ "visualizationType": "Combo",
115
+ "series": [
116
+ {
117
+ "dataKey": "Data 1",
118
+ "type": "Bar"
119
+ },
120
+ {
121
+ "dataKey": "Data 2",
122
+ "type": "Bar"
123
+ },
124
+ {
125
+ "dataKey": "Data 3",
126
+ "type": "Bar"
127
+ },
128
+ {
129
+ "dataKey": "Data 4",
130
+ "type": "Bar"
131
+ },
132
+ {
133
+ "dataKey": "Monthly-Goal",
134
+ "type": "Line"
135
+ }
136
+ ]
137
+ }
@@ -0,0 +1,80 @@
1
+ {
2
+ "type": "chart",
3
+ "title": "Categorical Bar Chart",
4
+ "theme": "theme-blue",
5
+ "fontSize": "medium",
6
+ "height": 300,
7
+ "padding": {
8
+ "left": 5,
9
+ "right": 5
10
+ },
11
+ "yAxis": {
12
+ "size": "71",
13
+ "gridLines": true,
14
+ "label": "Y-Axis Example Label"
15
+ },
16
+ "barThickness": "0.5",
17
+ "xAxis": {
18
+ "size": "58",
19
+ "tickRotation": 0,
20
+ "dataKey": "Location",
21
+ "label": "X-Axis Example Label"
22
+ },
23
+ "table": {
24
+ "label": "Data Table",
25
+ "expanded": true
26
+ },
27
+ "legend": {
28
+ "behavior": "highlight",
29
+ "position": "right",
30
+ "label": "Sample Groups"
31
+ },
32
+ "palette": "qualitative-bold",
33
+ "labels": false,
34
+ "dataFormat": {
35
+ "suffix": " "
36
+ },
37
+ "confidenceKeys": {},
38
+ "data": [
39
+ {
40
+ "Location": "Vehicle",
41
+ "Group A": "100",
42
+ "Group B": "150",
43
+ "Group C": "90"
44
+ },
45
+ {
46
+ "Location": "Home",
47
+ "Group A": "120",
48
+ "Group B": "140",
49
+ "Group C": "90"
50
+ },
51
+ {
52
+ "Location": "Work",
53
+ "Group A": "140",
54
+ "Group B": "100",
55
+ "Group C": "80"
56
+ },
57
+ {
58
+ "Location": "Office",
59
+ "Group A": "120",
60
+ "Group B": "90",
61
+ "Group C": "80"
62
+ }
63
+ ],
64
+ "visualizationType": "Bar",
65
+ "series": [
66
+ {
67
+ "dataKey": "Group A",
68
+ "type": "Bar"
69
+ },
70
+ {
71
+ "dataKey": "Group B",
72
+ "type": "Bar"
73
+ },
74
+ {
75
+ "dataKey": "Group C",
76
+ "type": "Bar"
77
+ }
78
+ ],
79
+ "description": "This example shows a Standard Categorical (Non-Time-Based) Bar Chart created in the visualization editor in WCMS"
80
+ }
@@ -0,0 +1,81 @@
1
+ {
2
+ "type": "chart",
3
+ "title": "Example Stacked Bar Chart",
4
+ "theme": "theme-orange",
5
+ "fontSize": "medium",
6
+ "height": "375",
7
+ "padding": {
8
+ "left": 5,
9
+ "right": 5
10
+ },
11
+ "yAxis": {
12
+ "size": "64",
13
+ "gridLines": false,
14
+ "label": "Y-Axis Label Example"
15
+ },
16
+ "barThickness": 0.35,
17
+ "xAxis": {
18
+ "size": "67",
19
+ "tickRotation": "25",
20
+ "dataKey": "Year",
21
+ "label": "X-Axis Label Example"
22
+ },
23
+ "table": {
24
+ "label": "Data Table",
25
+ "expanded": true,
26
+ "download": true
27
+ },
28
+ "legend": {
29
+ "behavior": "isolate",
30
+ "position": "right",
31
+ "label": "Data Type"
32
+ },
33
+ "palette": "qualitative-bold",
34
+ "labels": false,
35
+ "dataFormat": {
36
+ "suffix": "%"
37
+ },
38
+ "confidenceKeys": {},
39
+ "data": [
40
+ {
41
+ "Year": "2015",
42
+ "Data 1": "25",
43
+ "Data 2": "20",
44
+ "Data 3": "55"
45
+ },
46
+ {
47
+ "Year": "2016",
48
+ "Data 1": "35",
49
+ "Data 2": "30",
50
+ "Data 3": "35"
51
+ },
52
+ {
53
+ "Year": "2017",
54
+ "Data 1": "22",
55
+ "Data 2": "38",
56
+ "Data 3": "40"
57
+ },
58
+ {
59
+ "Year": "2018",
60
+ "Data 1": "40",
61
+ "Data 2": "40",
62
+ "Data 3": "20"
63
+ }
64
+ ],
65
+ "visualizationType": "Bar",
66
+ "visualizationSubType": "stacked",
67
+ "series": [
68
+ {
69
+ "dataKey": "Data 1",
70
+ "type": "Bar"
71
+ },
72
+ {
73
+ "dataKey": "Data 2",
74
+ "type": "Bar"
75
+ },
76
+ {
77
+ "dataKey": "Data 3",
78
+ "type": "Bar"
79
+ }
80
+ ]
81
+ }
@@ -0,0 +1,68 @@
1
+ {
2
+ "type": "chart",
3
+ "title": "Bar Chart with Confidence Intervals",
4
+ "theme": "theme-green",
5
+ "fontSize": "medium",
6
+ "height": 300,
7
+ "padding": {
8
+ "left": 5,
9
+ "right": 5
10
+ },
11
+ "yAxis": {
12
+ "size": "75",
13
+ "gridLines": true,
14
+ "label": "Y-Axis Example Label"
15
+ },
16
+ "barThickness": 0.35,
17
+ "xAxis": {
18
+ "size": "50",
19
+ "tickRotation": 0,
20
+ "dataKey": "Date",
21
+ "label": "X-Axis Sample Label"
22
+ },
23
+ "table": {
24
+ "label": "Data Table",
25
+ "expanded": true
26
+ },
27
+ "legend": {
28
+ "behavior": "isolate",
29
+ "position": "right"
30
+ },
31
+ "palette": "qualitative-bold",
32
+ "labels": false,
33
+ "dataFormat": {},
34
+ "confidenceKeys": {
35
+ "upper": "high",
36
+ "lower": "low"
37
+ },
38
+ "data": [
39
+ {
40
+ "Data": "data1",
41
+ "Date": "1/12/2016",
42
+ "Value": "212",
43
+ "high": "220",
44
+ "low": "200"
45
+ },
46
+ {
47
+ "Data": "data2",
48
+ "Date": "1/13/2016",
49
+ "Value": "213",
50
+ "high": "230",
51
+ "low": "205"
52
+ },
53
+ {
54
+ "Data": "data3",
55
+ "Date": "1/14/2016",
56
+ "Value": "214",
57
+ "high": "240",
58
+ "low": "210"
59
+ }
60
+ ],
61
+ "visualizationType": "Bar",
62
+ "series": [
63
+ {
64
+ "dataKey": "Value",
65
+ "type": "Bar"
66
+ }
67
+ ]
68
+ }