@cdc/chart 1.3.3 → 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 (49) hide show
  1. package/dist/cdcchart.js +6 -6
  2. package/examples/cutoff-example-config.json +2 -0
  3. package/examples/cutoff-example-data.json +1 -1
  4. package/examples/dynamic-legends.json +125 -0
  5. package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart-with-numbers-on-bar.json +198 -0
  6. package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart.json +241 -0
  7. package/examples/gallery/bar-chart-horizontal/horizontal-stacked.json +248 -0
  8. package/examples/gallery/bar-chart-vertical/combo-line-chart.json +137 -0
  9. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-categorical.json +80 -0
  10. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +81 -0
  11. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-with-confidence.json +68 -0
  12. package/examples/gallery/bar-chart-vertical/vertical-bar-chart.json +111 -0
  13. package/examples/gallery/lollipop/lollipop-style-horizontal.json +220 -0
  14. package/examples/gallery/paired-bar/paired-bar-chart.json +196 -0
  15. package/examples/horizontal-chart.json +3 -0
  16. package/examples/paired-bar-data.json +1 -1
  17. package/examples/paired-bar-example.json +2 -0
  18. package/examples/planet-combo-example-config.json +2 -0
  19. package/examples/planet-example-config.json +2 -2
  20. package/examples/planet-example-data.json +1 -1
  21. package/examples/planet-pie-example-config.json +2 -0
  22. package/examples/private/line-test-data.json +22 -0
  23. package/examples/private/line-test-two.json +216 -0
  24. package/examples/private/line-test.json +102 -0
  25. package/examples/private/shawn.json +1296 -0
  26. package/examples/private/yaxis-test.json +132 -0
  27. package/examples/private/yaxis-testing.csv +27 -0
  28. package/examples/private/yaxis.json +28 -0
  29. package/examples/stacked-vertical-bar-example.json +228 -0
  30. package/package.json +3 -3
  31. package/src/CdcChart.tsx +121 -168
  32. package/src/components/BarChart.tsx +92 -40
  33. package/src/components/DataTable.tsx +28 -13
  34. package/src/components/EditorPanel.js +286 -182
  35. package/src/components/Legend.js +334 -0
  36. package/src/components/LineChart.tsx +57 -17
  37. package/src/components/LinearChart.tsx +171 -77
  38. package/src/components/PairedBarChart.tsx +139 -42
  39. package/src/components/PieChart.tsx +33 -6
  40. package/src/components/SparkLine.js +28 -27
  41. package/src/components/useIntersectionObserver.tsx +30 -0
  42. package/src/data/initial-state.js +23 -7
  43. package/src/hooks/useChartClasses.js +35 -0
  44. package/src/hooks/useLegendClasses.js +20 -0
  45. package/src/hooks/useReduceData.ts +72 -24
  46. package/src/index.html +29 -30
  47. package/src/scss/editor-panel.scss +34 -4
  48. package/src/scss/main.scss +201 -5
  49. package/src/components/BarStackVertical.js +0 -0
@@ -2,6 +2,8 @@
2
2
  "title": "Data Cutoff Example (< 0.1)",
3
3
  "theme": "theme-blue",
4
4
  "dataUrl": "/examples/cutoff-example-data.json",
5
+ "animate": true,
6
+ "animateReplay": true,
5
7
  "visualizationType": "Line",
6
8
  "series": [{"dataKey": "Value"}],
7
9
  "barThickness": 0.3,
@@ -21,7 +21,7 @@
21
21
  },
22
22
  {
23
23
  "Category": "Category 6",
24
- "Value": "0.03"
24
+ "Value": null
25
25
  },
26
26
  {
27
27
  "Category": "Category 7",
@@ -0,0 +1,125 @@
1
+ {
2
+ "type": "chart",
3
+ "title": "Example Line Chart",
4
+ "theme": "theme-green",
5
+ "fontSize": "medium",
6
+ "height": "375",
7
+ "padding": {
8
+ "left": 5,
9
+ "right": 5
10
+ },
11
+ "yAxis": {
12
+ "size": "75",
13
+ "gridLines": false,
14
+ "label": "Y-Axis Example Label",
15
+ "numTicks": "9"
16
+ },
17
+ "barThickness": 0.35,
18
+ "xAxis": {
19
+ "size": "77",
20
+ "tickRotation": "25",
21
+ "dataKey": "Date",
22
+ "label": "X-Axis Example Label",
23
+ "type": "date",
24
+ "dateParseFormat": "%d/%m/%Y",
25
+ "dateDisplayFormat": "%d/%m/%Y"
26
+ },
27
+ "table": {
28
+ "label": "Data Table",
29
+ "expanded": true,
30
+ "download": true
31
+ },
32
+ "legend": {
33
+ "behavior": "isolate",
34
+ "position": "right",
35
+ "label": "Type of Data",
36
+ "dynamicLegend": true
37
+ },
38
+ "palette": "qualitative-bold",
39
+ "labels": false,
40
+ "dataFormat": {},
41
+ "confidenceKeys": {},
42
+ "data": [
43
+ {
44
+ "Date": "1/15/2016",
45
+ "Alabama": "90",
46
+ "Alaska": "135",
47
+ "Arizona": "300",
48
+ "Arkansas": "95",
49
+ "California": "120",
50
+ "Colorado": "310"
51
+ },
52
+ {
53
+ "Date": "2/15/2016",
54
+ "Alabama": "40",
55
+ "Alaska": "90",
56
+ "Arizona": "240",
57
+ "Arkansas": "60",
58
+ "California": "160",
59
+ "Colorado": "200"
60
+ },
61
+ {
62
+ "Date": "3/15/2016",
63
+ "Alabama": "50",
64
+ "Alaska": "300",
65
+ "Arizona": "290",
66
+ "Arkansas": "100",
67
+ "California": "200",
68
+ "Colorado": "250"
69
+ },
70
+ {
71
+ "Date": "4/15/2016",
72
+ "Alabama": "120",
73
+ "Alaska": "160",
74
+ "Arizona": "230",
75
+ "Arkansas": "180",
76
+ "California": "160",
77
+ "Colorado": "220"
78
+ },
79
+ {
80
+ "Date": "5/15/2016",
81
+ "Alabama": "80",
82
+ "Alaska": "350",
83
+ "Arizona": "300",
84
+ "Arkansas": "150",
85
+ "California": "130",
86
+ "Colorado": "100"
87
+ },
88
+ {
89
+ "Date": "6/15/2016",
90
+ "Alabama": "90",
91
+ "Alaska": "220",
92
+ "Arizona": "320",
93
+ "Arkansas": "100",
94
+ "California": "220",
95
+ "Colorado": "300"
96
+ }
97
+ ],
98
+ "visualizationType": "Line",
99
+ "series": [
100
+ {
101
+ "dataKey": "Alabama",
102
+ "type": "Bar"
103
+ },
104
+ {
105
+ "dataKey": "Alaska",
106
+ "type": "Bar"
107
+ },
108
+ {
109
+ "dataKey": "Arizona",
110
+ "type": "Bar"
111
+ },
112
+ {
113
+ "dataKey": "Arkansas",
114
+ "type": "Bar"
115
+ },
116
+ {
117
+ "dataKey": "California",
118
+ "type": "Bar"
119
+ },
120
+ {
121
+ "dataKey": "Colorado",
122
+ "type": "Bar"
123
+ }
124
+ ]
125
+ }
@@ -0,0 +1,198 @@
1
+ {
2
+ "type": "chart",
3
+ "title": "Example of Horizontal Bar Chart with Numbers on Bar",
4
+ "theme": "theme-blue",
5
+ "fontSize": "medium",
6
+ "lineDatapointStyle": "hover",
7
+ "barHasBorder": "true",
8
+ "padding": {
9
+ "left": 5,
10
+ "right": 5
11
+ },
12
+ "yAxis": {
13
+ "size": 50,
14
+ "gridLines": false,
15
+ "type": "chart",
16
+ "title": "Example of Horizontal Bar Chart with Numbers on Bar",
17
+ "theme": "theme-blue",
18
+ "fontSize": "medium",
19
+ "lineDatapointStyle": "hover",
20
+ "barHasBorder": "true",
21
+ "padding": {
22
+ "left": 5,
23
+ "right": 5
24
+ },
25
+ "yAxis": {
26
+ "size": 50,
27
+ "gridLines": false,
28
+ "label": "Number of Accidents"
29
+ },
30
+ "barThickness": "0.5",
31
+ "height": 450,
32
+ "xAxis": {
33
+ "size": 75,
34
+ "tickRotation": 0,
35
+ "dataKey": "Injury Type",
36
+ "label": "Injury Type"
37
+ },
38
+ "table": {
39
+ "label": "Data Table",
40
+ "expanded": false,
41
+ "show": true
42
+ },
43
+ "legend": {
44
+ "behavior": "isolate",
45
+ "position": "right",
46
+ "label": "Accident Year"
47
+ },
48
+ "palette": "qualitative-bold",
49
+ "labels": false,
50
+ "dataFormat": {},
51
+ "confidenceKeys": {},
52
+ "data": [
53
+ {
54
+ "2017": "12",
55
+ "2018": "8",
56
+ "Injury Type": "Falling"
57
+ },
58
+ {
59
+ "2017": "25",
60
+ "2018": "10",
61
+ "Injury Type": "Machinery"
62
+ },
63
+ {
64
+ "2017": "1",
65
+ "2018": "0",
66
+ "Injury Type": "Alergic Reaction"
67
+ },
68
+ {
69
+ "2017": "3",
70
+ "2018": "4",
71
+ "Injury Type": "Chemical"
72
+ },
73
+ {
74
+ "2017": "3",
75
+ "2018": "2",
76
+ "Injury Type": "Burns"
77
+ }
78
+ ],
79
+ "dataFileName": "job_place_injury_2 years_FINAL.json",
80
+ "dataFileSourceType": "file",
81
+ "visualizationType": "Bar",
82
+ "visualizationSubType": "horizontal",
83
+ "series": [
84
+ {
85
+ "dataKey": "2017",
86
+ "type": "Bar"
87
+ },
88
+ {
89
+ "dataKey": "2018",
90
+ "type": "Bar"
91
+ }
92
+ ],
93
+ "runtime": {
94
+ "seriesLabels": {
95
+ "2017": "2017",
96
+ "2018": "2018"
97
+ },
98
+ "seriesLabelsAll": [
99
+ "2017",
100
+ "2018"
101
+ ],
102
+ "originalXAxis": {
103
+ "size": 75,
104
+ "tickRotation": 0,
105
+ "dataKey": "Injury Type",
106
+ "label": "Injury Type"
107
+ },
108
+ "seriesKeys": [
109
+ "2017",
110
+ "2018"
111
+ ],
112
+ "xAxis": {
113
+ "size": 50,
114
+ "gridLines": false,
115
+ "label": "Number of Accidents"
116
+ },
117
+ "yAxis": {
118
+ "size": 75,
119
+ "tickRotation": 0,
120
+ "dataKey": "Injury Type",
121
+ "label": "Injury Type"
122
+ },
123
+ "horizontal": true,
124
+ "uniqueId": 1635525153525,
125
+ "editorErrorMessage": ""
126
+ },
127
+ "barPadding": 40,
128
+ "barHeight": 25,
129
+ "labelPlacement": "Below Bar",
130
+ "displayNumbersOnBar": true
131
+ },
132
+ "barThickness": "0.5",
133
+ "height": 450,
134
+ "xAxis": {
135
+ "size": 75,
136
+ "tickRotation": 0,
137
+ "dataKey": "Injury Type",
138
+ "label": "Injury Type"
139
+ },
140
+ "table": {
141
+ "label": "Data Table",
142
+ "expanded": false,
143
+ "show": true
144
+ },
145
+ "legend": {
146
+ "behavior": "isolate",
147
+ "position": "right",
148
+ "label": "Accident Year"
149
+ },
150
+ "palette": "qualitative-bold",
151
+ "labels": false,
152
+ "dataFormat": {},
153
+ "confidenceKeys": {},
154
+ "data": [
155
+ {
156
+ "2017": "12",
157
+ "2018": "8",
158
+ "Injury Type": "Falling"
159
+ },
160
+ {
161
+ "2017": "25",
162
+ "2018": "10",
163
+ "Injury Type": "Machinery"
164
+ },
165
+ {
166
+ "2017": "1",
167
+ "2018": "0",
168
+ "Injury Type": "Alergic Reaction"
169
+ },
170
+ {
171
+ "2017": "3",
172
+ "2018": "4",
173
+ "Injury Type": "Chemical"
174
+ },
175
+ {
176
+ "2017": "3",
177
+ "2018": "2",
178
+ "Injury Type": "Burns"
179
+ }
180
+ ],
181
+ "dataFileName": "job_place_injury_2 years_FINAL.json",
182
+ "dataFileSourceType": "file",
183
+ "visualizationType": "Bar",
184
+ "visualizationSubType": "horizontal",
185
+ "series": [
186
+ {
187
+ "dataKey": "2017",
188
+ "type": "Bar"
189
+ },
190
+ {
191
+ "dataKey": "2018",
192
+ "type": "Bar"
193
+ }
194
+ ],
195
+ "barPadding": 40,
196
+ "barHeight": 25,
197
+ "description": " Also note that the border around the bars has been added in the Visualization Editor"
198
+ }
@@ -0,0 +1,241 @@
1
+ {
2
+ "type": "chart",
3
+ "title": "Example Horizontal Bar Chart",
4
+ "theme": "theme-teal",
5
+ "fontSize": "small",
6
+ "lineDatapointStyle": "hover",
7
+ "barHasBorder": "false",
8
+ "padding": {
9
+ "left": 5,
10
+ "right": 5
11
+ },
12
+ "yAxis": {
13
+ "size": 50,
14
+ "gridLines": false,
15
+ "type": "chart",
16
+ "title": "Example Horizontal Bar Chart",
17
+ "theme": "theme-teal",
18
+ "fontSize": "small",
19
+ "lineDatapointStyle": "hover",
20
+ "barHasBorder": "false",
21
+ "padding": {
22
+ "left": 5,
23
+ "right": 5
24
+ },
25
+ "yAxis": {
26
+ "size": 50,
27
+ "gridLines": false,
28
+ "label": "X-Axis Example Label",
29
+ "numTicks": "10"
30
+ },
31
+ "barThickness": "0.7",
32
+ "height": 560,
33
+ "xAxis": {
34
+ "type": "categorical",
35
+ "size": "0",
36
+ "tickRotation": 0,
37
+ "dataKey": "Group",
38
+ "label": ""
39
+ },
40
+ "table": {
41
+ "label": "Data Table",
42
+ "expanded": true,
43
+ "download": false,
44
+ "show": true
45
+ },
46
+ "legend": {
47
+ "behavior": "isolate",
48
+ "position": "right",
49
+ "label": "Type of Data"
50
+ },
51
+ "exclusions": {
52
+ "active": false,
53
+ "keys": []
54
+ },
55
+ "palette": "qualitative-soft",
56
+ "labels": false,
57
+ "dataFormat": {},
58
+ "confidenceKeys": {},
59
+ "data": [
60
+ {
61
+ "Group": "Combined Total of Group A",
62
+ "Vehicle": "100",
63
+ "Home": "120",
64
+ "Work": "140",
65
+ "Office": "120"
66
+ },
67
+ {
68
+ "Group": "Combined Total of Group B",
69
+ "Vehicle": "150",
70
+ "Home": "140",
71
+ "Work": "100",
72
+ "Office": "90"
73
+ },
74
+ {
75
+ "Group": "Combined Total of Group C",
76
+ "Vehicle": "90",
77
+ "Home": "90",
78
+ "Work": "80",
79
+ "Office": "80"
80
+ },
81
+ {
82
+ "Group": "Combined Total of Group D",
83
+ "Vehicle": "70",
84
+ "Home": "60",
85
+ "Work": "50",
86
+ "Office": "70"
87
+ }
88
+ ],
89
+ "visualizationType": "Bar",
90
+ "visualizationSubType": "horizontal",
91
+ "series": [
92
+ {
93
+ "dataKey": "Vehicle",
94
+ "type": "Bar"
95
+ },
96
+ {
97
+ "dataKey": "Home",
98
+ "type": "Bar"
99
+ },
100
+ {
101
+ "dataKey": "Work",
102
+ "type": "Bar"
103
+ },
104
+ {
105
+ "dataKey": "Office",
106
+ "type": "Bar"
107
+ }
108
+ ],
109
+ "description": "This example shows a horizontal bar chart created in the visualization editor in WCMS",
110
+ "runtime": {
111
+ "seriesLabels": {
112
+ "Vehicle": "Vehicle",
113
+ "Home": "Home",
114
+ "Work": "Work",
115
+ "Office": "Office"
116
+ },
117
+ "seriesLabelsAll": [
118
+ "Vehicle",
119
+ "Home",
120
+ "Work",
121
+ "Office"
122
+ ],
123
+ "originalXAxis": {
124
+ "type": "categorical",
125
+ "size": "0",
126
+ "tickRotation": 0,
127
+ "dataKey": "Group",
128
+ "label": ""
129
+ },
130
+ "seriesKeys": [
131
+ "Vehicle",
132
+ "Home",
133
+ "Work",
134
+ "Office"
135
+ ],
136
+ "xAxis": {
137
+ "size": 50,
138
+ "gridLines": false,
139
+ "label": "X-Axis Example Label",
140
+ "numTicks": "10"
141
+ },
142
+ "yAxis": {
143
+ "type": "categorical",
144
+ "size": "0",
145
+ "tickRotation": 0,
146
+ "dataKey": "Group",
147
+ "label": ""
148
+ },
149
+ "horizontal": true,
150
+ "uniqueId": 1644353484184,
151
+ "editorErrorMessage": ""
152
+ },
153
+ "barPadding": 40,
154
+ "barHeight": 25,
155
+ "labelPlacement": "Below Bar",
156
+ "label": "Accidents"
157
+ },
158
+ "barThickness": "0.7",
159
+ "height": 560,
160
+ "xAxis": {
161
+ "type": "categorical",
162
+ "size": "0",
163
+ "tickRotation": 0,
164
+ "dataKey": "Group",
165
+ "label": ""
166
+ },
167
+ "table": {
168
+ "label": "Data Table",
169
+ "expanded": true,
170
+ "download": false,
171
+ "show": true
172
+ },
173
+ "legend": {
174
+ "behavior": "isolate",
175
+ "position": "right",
176
+ "label": "Location"
177
+ },
178
+ "exclusions": {
179
+ "active": false,
180
+ "keys": []
181
+ },
182
+ "palette": "qualitative-soft",
183
+ "labels": false,
184
+ "dataFormat": {},
185
+ "confidenceKeys": {},
186
+ "data": [
187
+ {
188
+ "Group": "Group A Survey Results",
189
+ "Vehicle": "100",
190
+ "Home": "120",
191
+ "Work": "140",
192
+ "Office": "120"
193
+ },
194
+ {
195
+ "Group": "Group B Survey Results",
196
+ "Vehicle": "150",
197
+ "Home": "140",
198
+ "Work": "100",
199
+ "Office": "90"
200
+ },
201
+ {
202
+ "Group": "Group C Survey Results",
203
+ "Vehicle": "90",
204
+ "Home": "90",
205
+ "Work": "80",
206
+ "Office": "80"
207
+ },
208
+ {
209
+ "Group": "Group D Survey Results",
210
+ "Vehicle": "70",
211
+ "Home": "60",
212
+ "Work": "50",
213
+ "Office": "70"
214
+ }
215
+ ],
216
+ "visualizationType": "Bar",
217
+ "visualizationSubType": "horizontal",
218
+ "series": [
219
+ {
220
+ "dataKey": "Vehicle",
221
+ "type": "Bar"
222
+ },
223
+ {
224
+ "dataKey": "Home",
225
+ "type": "Bar"
226
+ },
227
+ {
228
+ "dataKey": "Work",
229
+ "type": "Bar"
230
+ },
231
+ {
232
+ "dataKey": "Office",
233
+ "type": "Bar"
234
+ }
235
+ ],
236
+ "description": "This example shows a horizontal bar chart created in the visualization editor in WCMS",
237
+ "barPadding": 40,
238
+ "barHeight": 25,
239
+ "dataFileName": "3-CSV_Source_Example_for_Horizontal_Bar_viz - Fixed.csv",
240
+ "dataFileSourceType": "file"
241
+ }