@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
@@ -0,0 +1,111 @@
1
+ {
2
+ "type": "chart",
3
+ "title": "Example 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": "76",
13
+ "gridLines": false,
14
+ "label": "Y Axis Example Label"
15
+ },
16
+ "barThickness": "0.6",
17
+ "xAxis": {
18
+ "size": "59",
19
+ "tickRotation": 0,
20
+ "dataKey": "Date",
21
+ "label": "X Axis Example Label"
22
+ },
23
+ "table": {
24
+ "label": "Data Type by Date",
25
+ "expanded": true
26
+ },
27
+ "legend": {
28
+ "behavior": "isolate",
29
+ "position": "right",
30
+ "label": "Type of Data"
31
+ },
32
+ "palette": "qualitative-bold",
33
+ "labels": false,
34
+ "dataFormat": {
35
+ "suffix": " units"
36
+ },
37
+ "confidenceKeys": {},
38
+ "data": [
39
+ {
40
+ "Date": "1/15/2016",
41
+ "Data 1": "90",
42
+ "Data 2": "135",
43
+ "Data 3": "300",
44
+ "Data 4": "95",
45
+ "Data 5": "120",
46
+ "Data 6": "310"
47
+ },
48
+ {
49
+ "Date": "2/15/2016",
50
+ "Data 1": "40",
51
+ "Data 2": "90",
52
+ "Data 3": "240",
53
+ "Data 4": "60",
54
+ "Data 5": "160",
55
+ "Data 6": "200"
56
+ },
57
+ {
58
+ "Date": "3/15/2016",
59
+ "Data 1": "50",
60
+ "Data 2": "300",
61
+ "Data 3": "290",
62
+ "Data 4": "100",
63
+ "Data 5": "200",
64
+ "Data 6": "250"
65
+ },
66
+ {
67
+ "Date": "4/15/2016",
68
+ "Data 1": "120",
69
+ "Data 2": "160",
70
+ "Data 3": "230",
71
+ "Data 4": "180",
72
+ "Data 5": "160",
73
+ "Data 6": "220"
74
+ },
75
+ {
76
+ "Date": "5/15/2016",
77
+ "Data 1": "80",
78
+ "Data 2": "350",
79
+ "Data 3": "300",
80
+ "Data 4": "150",
81
+ "Data 5": "130",
82
+ "Data 6": "100"
83
+ },
84
+ {
85
+ "Date": "6/15/2016",
86
+ "Data 1": "90",
87
+ "Data 2": "220",
88
+ "Data 3": "320",
89
+ "Data 4": "100",
90
+ "Data 5": "220",
91
+ "Data 6": "300"
92
+ }
93
+ ],
94
+ "visualizationType": "Bar",
95
+ "series": [
96
+ {
97
+ "dataKey": "Data 1",
98
+ "type": "Bar"
99
+ },
100
+ {
101
+ "dataKey": "Data 2",
102
+ "type": "Bar"
103
+ },
104
+ {
105
+ "dataKey": "Data 3",
106
+ "type": "Bar"
107
+ }
108
+ ],
109
+ "description": "This example shows a bar chart created in the visualization editor in WCMS",
110
+ "dataCutoff": "0"
111
+ }
@@ -0,0 +1,220 @@
1
+ {
2
+ "type": "chart",
3
+ "title": "Lollipop Style Horizontal Bar Chart - Number of Spills Occurring in the Home",
4
+ "theme": "theme-blue",
5
+ "fontSize": "medium",
6
+ "lineDatapointStyle": "hover",
7
+ "barHasBorder": "false",
8
+ "isLollipopChart": true,
9
+ "lollipopShape": "circle",
10
+ "lollipopColorStyle": "two-tone",
11
+ "visualizationSubType": "horizontal",
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": "Lollipop Style Horizontal Bar Chart",
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": "horizontal",
32
+ "padding": {
33
+ "left": 5,
34
+ "right": 5
35
+ },
36
+ "yAxis": {
37
+ "size": 50,
38
+ "gridLines": false
39
+ },
40
+ "barThickness": 0.35,
41
+ "height": 260,
42
+ "xAxis": {
43
+ "type": "categorical",
44
+ "size": 75,
45
+ "tickRotation": 0,
46
+ "dataKey": "Vehicle"
47
+ },
48
+ "table": {
49
+ "label": "Data Table",
50
+ "expanded": true,
51
+ "show": true
52
+ },
53
+ "legend": {
54
+ "behavior": "isolate",
55
+ "position": "right"
56
+ },
57
+ "exclusions": {
58
+ "active": false,
59
+ "keys": []
60
+ },
61
+ "palette": "qualitative-bold",
62
+ "labels": false,
63
+ "dataFormat": {},
64
+ "confidenceKeys": {},
65
+ "data": [
66
+ {
67
+ "Group": "Combined Total of Group A",
68
+ "Vehicle": "100",
69
+ "Home": "120",
70
+ "Work": "140",
71
+ "Office": "120"
72
+ },
73
+ {
74
+ "Group": "Combined Total of Group B",
75
+ "Vehicle": "150",
76
+ "Home": "140",
77
+ "Work": "100",
78
+ "Office": "90"
79
+ },
80
+ {
81
+ "Group": "Combined Total of Group C",
82
+ "Vehicle": "90",
83
+ "Home": "90",
84
+ "Work": "80",
85
+ "Office": "80"
86
+ },
87
+ {
88
+ "Group": "Combined Total of Group D",
89
+ "Vehicle": "70",
90
+ "Home": "60",
91
+ "Work": "50",
92
+ "Office": "70"
93
+ }
94
+ ],
95
+ "dataFileName": "CSV_Source_Example_for_Horizontal_Bar_viz-cdcwp1619811744363.csv",
96
+ "dataFileSourceType": "file",
97
+ "visualizationType": "Bar",
98
+ "runtime": {
99
+ "seriesLabels": {
100
+ "Vehicle": "Vehicle"
101
+ },
102
+ "seriesLabelsAll": [
103
+ "Vehicle"
104
+ ],
105
+ "originalXAxis": {
106
+ "type": "categorical",
107
+ "size": 75,
108
+ "tickRotation": 0,
109
+ "dataKey": "Vehicle"
110
+ },
111
+ "seriesKeys": [
112
+ "Vehicle"
113
+ ],
114
+ "xAxis": {
115
+ "size": 50,
116
+ "gridLines": false
117
+ },
118
+ "yAxis": {
119
+ "type": "categorical",
120
+ "size": 75,
121
+ "tickRotation": 0,
122
+ "dataKey": "Vehicle"
123
+ },
124
+ "horizontal": true,
125
+ "uniqueId": 1651765968212,
126
+ "editorErrorMessage": ""
127
+ },
128
+ "description": "Subtext can be added here for options like citing data sources or insight into reading the bar chart.",
129
+ "series": [
130
+ {
131
+ "dataKey": "Vehicle",
132
+ "type": "Bar"
133
+ }
134
+ ],
135
+ "barHeight": 25,
136
+ "barPadding": 40,
137
+ "labelPlacement": "Below Bar",
138
+ "displayNumbersOnBar": true,
139
+ "numTicks": "9",
140
+ "label": "Number of Accidents"
141
+ },
142
+ "barThickness": 0.35,
143
+ "height": 212,
144
+ "xAxis": {
145
+ "type": "categorical",
146
+ "hideAxis": true,
147
+ "hideLabel": true,
148
+ "hideTicks": true,
149
+ "size": "16",
150
+ "tickRotation": 0,
151
+ "max": "160",
152
+ "dataKey": "Group"
153
+ },
154
+ "table": {
155
+ "label": "Data Table",
156
+ "expanded": false,
157
+ "show": true
158
+ },
159
+ "orientation": "horizontal",
160
+ "legend": {
161
+ "behavior": "isolate",
162
+ "position": "right",
163
+ "hide": true,
164
+ "label": "Accident Location",
165
+ "reverseLabelOrder": false
166
+ },
167
+ "exclusions": {
168
+ "active": false,
169
+ "keys": []
170
+ },
171
+ "palette": "qualitative-bold",
172
+ "isPaletteReversed": false,
173
+ "labels": false,
174
+ "dataFormat": {},
175
+ "confidenceKeys": {},
176
+ "data": [
177
+ {
178
+ "Group": "Combined Total of Group A",
179
+ "Vehicle": "100",
180
+ "Home": "120",
181
+ "Work": "140",
182
+ "Office": "120"
183
+ },
184
+ {
185
+ "Group": "Combined Total of Group B",
186
+ "Vehicle": "150",
187
+ "Home": "140",
188
+ "Work": "100",
189
+ "Office": "90"
190
+ },
191
+ {
192
+ "Group": "Combined Total of Group C",
193
+ "Vehicle": "90",
194
+ "Home": "90",
195
+ "Work": "80",
196
+ "Office": "80"
197
+ },
198
+ {
199
+ "Group": "Combined Total of Group D",
200
+ "Vehicle": "70",
201
+ "Home": "60",
202
+ "Work": "50",
203
+ "Office": "70"
204
+ }
205
+ ],
206
+ "dataFileName": "CSV_Source_Example_for_Horizontal_Bar_viz-cdcwp1619811744363.csv",
207
+ "dataFileSourceType": "file",
208
+ "visualizationType": "Bar",
209
+ "description": "Subtext can be added here for options like citing data sources or insight into reading the bar chart.",
210
+ "series": [
211
+ {
212
+ "dataKey": "Home",
213
+ "type": "Bar"
214
+ }
215
+ ],
216
+ "barHeight": 6,
217
+ "barPadding": 47,
218
+ "filters": [],
219
+ "lollipopSize": "medium"
220
+ }
@@ -0,0 +1,196 @@
1
+ {
2
+ "type": "chart",
3
+ "title": "Example Paired Bar Chart",
4
+ "theme": "theme-slate",
5
+ "fontSize": "small",
6
+ "lineDatapointStyle": "hover",
7
+ "barHasBorder": "false",
8
+ "isLollipopChart": false,
9
+ "lollipopShape": "circle",
10
+ "lollipopColorStyle": "two-tone",
11
+ "visualizationSubType": null,
12
+ "padding": {
13
+ "left": 5,
14
+ "right": 5
15
+ },
16
+ "yAxis": {
17
+ "hideAxis": true,
18
+ "hideLabel": false,
19
+ "hideTicks": false,
20
+ "size": "75",
21
+ "gridLines": false,
22
+ "label": "Value Axis",
23
+ "numTicks": "6"
24
+ },
25
+ "barThickness": 0.35,
26
+ "height": "400",
27
+ "xAxis": {
28
+ "type": "categorical",
29
+ "hideAxis": false,
30
+ "hideLabel": false,
31
+ "hideTicks": false,
32
+ "size": "56",
33
+ "tickRotation": "0",
34
+ "max": "15000",
35
+ "dataKey": "Age Group",
36
+ "label": "Age Group"
37
+ },
38
+ "table": {
39
+ "label": "Data Table",
40
+ "expanded": false,
41
+ "show": true,
42
+ "indexLabel": "Region"
43
+ },
44
+ "orientation": "horizontal",
45
+ "legend": {
46
+ "behavior": "isolate",
47
+ "position": "right",
48
+ "reverseLabelOrder": false,
49
+ "hide": false,
50
+ "label": "Region "
51
+ },
52
+ "exclusions": {
53
+ "active": false,
54
+ "keys": []
55
+ },
56
+ "palette": "qualitative-soft",
57
+ "isPaletteReversed": false,
58
+ "labels": false,
59
+ "dataFormat": {
60
+ "commas": true,
61
+ "suffix": " per 100k"
62
+ },
63
+ "confidenceKeys": {},
64
+ "data": [
65
+ {
66
+ "Region": "West Coast",
67
+ "Age Group": "<15",
68
+ "Cases Per 100K": "7428"
69
+ },
70
+ {
71
+ "Region": "West Coast",
72
+ "Age Group": "15-24",
73
+ "Cases Per 100K": "5176"
74
+ },
75
+ {
76
+ "Region": "West Coast",
77
+ "Age Group": "25-34",
78
+ "Cases Per 100K": "5624"
79
+ },
80
+ {
81
+ "Region": "West Coast",
82
+ "Age Group": "35-44",
83
+ "Cases Per 100K": "10756"
84
+ },
85
+ {
86
+ "Region": "West Coast",
87
+ "Age Group": "45-54",
88
+ "Cases Per 100K": "8256"
89
+ },
90
+ {
91
+ "Region": "West Coast",
92
+ "Age Group": "55-64",
93
+ "Cases Per 100K": "1235"
94
+ },
95
+ {
96
+ "Region": "West Coast",
97
+ "Age Group": "65+",
98
+ "Cases Per 100K": "730"
99
+ },
100
+ {
101
+ "Region": "East Coast",
102
+ "Age Group": "<15",
103
+ "Cases Per 100K": "5714"
104
+ },
105
+ {
106
+ "Region": "East Coast",
107
+ "Age Group": "15-24",
108
+ "Cases Per 100K": "3588"
109
+ },
110
+ {
111
+ "Region": "East Coast",
112
+ "Age Group": "25-34",
113
+ "Cases Per 100K": "3410"
114
+ },
115
+ {
116
+ "Region": "East Coast",
117
+ "Age Group": "35-44",
118
+ "Cases Per 100K": "7478"
119
+ },
120
+ {
121
+ "Region": "East Coast",
122
+ "Age Group": "45-54",
123
+ "Cases Per 100K": "5633"
124
+ },
125
+ {
126
+ "Region": "East Coast",
127
+ "Age Group": "55-64",
128
+ "Cases Per 100K": "810"
129
+ },
130
+ {
131
+ "Region": "East Coast",
132
+ "Age Group": "65+",
133
+ "Cases Per 100K": "402"
134
+ }
135
+ ],
136
+ "dataFileName": "Paired-Bar-Chart-Example-Data.csv",
137
+ "dataFileSourceType": "file",
138
+ "dataDescription": {
139
+ "horizontal": false,
140
+ "series": true,
141
+ "singleRow": false,
142
+ "seriesKey": "Region",
143
+ "xKey": "Age Group",
144
+ "valueKey": "Cases Per 100K"
145
+ },
146
+ "formattedData": [
147
+ {
148
+ "Age Group": "<15",
149
+ "West Coast": "7428",
150
+ "East Coast": "5714"
151
+ },
152
+ {
153
+ "Age Group": "15-24",
154
+ "West Coast": "5176",
155
+ "East Coast": "3588"
156
+ },
157
+ {
158
+ "Age Group": "25-34",
159
+ "West Coast": "5624",
160
+ "East Coast": "3410"
161
+ },
162
+ {
163
+ "Age Group": "35-44",
164
+ "West Coast": "10756",
165
+ "East Coast": "7478"
166
+ },
167
+ {
168
+ "Age Group": "45-54",
169
+ "West Coast": "8256",
170
+ "East Coast": "5633"
171
+ },
172
+ {
173
+ "Age Group": "55-64",
174
+ "West Coast": "1235",
175
+ "East Coast": "810"
176
+ },
177
+ {
178
+ "Age Group": "65+",
179
+ "West Coast": "730",
180
+ "East Coast": "402"
181
+ }
182
+ ],
183
+ "visualizationType": "Paired Bar",
184
+ "series": [
185
+ {
186
+ "dataKey": "West Coast",
187
+ "type": "Bar"
188
+ },
189
+ {
190
+ "dataKey": "East Coast",
191
+ "type": "Bar"
192
+ }
193
+ ],
194
+ "filters": [],
195
+ "barHeight": "23"
196
+ }
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "title": "Planet Radius (Combo Example)",
3
3
  "dataUrl": "/examples/planet-example-data.json",
4
+ "animate": true,
5
+ "animateReplay": true,
6
+
4
7
  "visualizationType": "Bar",
5
8
  "visualizationSubType": "horizontal",
6
9
  "isLollipopChart": false,
@@ -1,7 +1,7 @@
1
1
  [{"Sex":"Male","Age Group":"<15","Cases per 100K":"7428"},
2
2
  {"Sex":"Male","Age Group":"15-24","Cases per 100K":"5176"},
3
3
  {"Sex":"Male","Age Group":"25-34","Cases per 100K":"5624"},
4
- {"Sex":"Male","Age Group":"35-44","Cases per 100K":"10756"},
4
+ {"Sex":"Male","Age Group":"35-44","Cases per 100K":"10756.75"},
5
5
  {"Sex":"Male","Age Group":"45-54","Cases per 100K":"8259"},
6
6
  {"Sex":"Male","Age Group":"55-64","Cases per 100K":"1235"},
7
7
  {"Sex":"Male","Age Group":"65","Cases per 100K":"730"},
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "title": "Paired Bar Chart Example",
3
3
  "dataUrl": "/examples/paired-bar-data.json",
4
+ "animate": true,
5
+ "animateReplay": true,
4
6
  "visualizationType": "Paired Bar",
5
7
  "series": [
6
8
  {"dataKey": "Male","type": "Paired Bar"},
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "title": "Planet Radius (Combo Example)",
3
3
  "dataUrl": "/examples/planet-example-data.json",
4
+ "animate": true,
5
+ "animateReplay": true,
4
6
  "visualizationType": "Combo",
5
7
  "series": [{"dataKey":"Radius", "type":"Line"}, {"dataKey":"Diameter", "type":"Bar"}],
6
8
  "dataFormat": {
@@ -2,8 +2,8 @@
2
2
  "title": "Planet Radius (Bar Example)",
3
3
  "dataUrl": "/examples/planet-example-data.json",
4
4
  "visualizationType": "Bar",
5
- "visualizationSubType": "stacked",
6
- "series": [{"dataKey": "Radius"}, {"dataKey": "Diameter"}],
5
+ "visualizationSubType": "regular",
6
+ "series": [{"dataKey": "Radius"}],
7
7
  "fontSize": "medium",
8
8
  "dataCutoff": "0.5",
9
9
  "orientation": "horizontal",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  {
15
15
  "name": "Uranus",
16
- "Radius": "3.98",
16
+ "Radius": "",
17
17
  "Diameter": "8",
18
18
  "distance": "0"
19
19
  },
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "title": "Planet Radius (Pie Example)",
3
3
  "dataUrl": "/examples/planet-example-data.json",
4
+ "animate": true,
5
+ "animateReplay": true,
4
6
  "visualizationType": "Pie",
5
7
  "palette": "qualitative-soft",
6
8
  "aspectRatio": 1,
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "Number": "11.0",
4
+ "Date": "9/1/2022"
5
+ },
6
+ {
7
+ "Number": "12.2",
8
+ "Date": "9/2/2022"
9
+ },
10
+ {
11
+ "Number": "13.6",
12
+ "Date": "9/4/2022"
13
+ },
14
+ {
15
+ "Number": "",
16
+ "Date": "9/5/2022"
17
+ },
18
+ {
19
+ "Number": "6.4",
20
+ "Date": "9/6/2022"
21
+ }
22
+ ]