@cdc/chart 1.3.1 → 1.3.3

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 (56) hide show
  1. package/dist/cdcchart.js +85 -0
  2. package/examples/age-adjusted-rates.json +1218 -0
  3. package/examples/case-rate-example-config.json +36 -0
  4. package/examples/case-rate-example-data.json +33602 -0
  5. package/examples/covid-confidence-example-config.json +35 -0
  6. package/examples/covid-example-config.json +36 -0
  7. package/examples/covid-example-data-confidence.json +32 -0
  8. package/examples/covid-example-data.json +22 -0
  9. package/examples/cutoff-example-config.json +36 -0
  10. package/examples/cutoff-example-data.json +38 -0
  11. package/examples/date-exclusions-config.json +62 -0
  12. package/examples/date-exclusions-data.json +162 -0
  13. package/examples/horizontal-chart.json +35 -0
  14. package/examples/horizontal-stacked-bar-chart.json +36 -0
  15. package/examples/line-chart.json +76 -0
  16. package/examples/paired-bar-data.json +14 -0
  17. package/examples/paired-bar-example.json +48 -0
  18. package/examples/paired-bar-formatted.json +37 -0
  19. package/examples/planet-chart-horizontal-example-config.json +35 -0
  20. package/examples/planet-combo-example-config.json +31 -0
  21. package/examples/planet-example-config.json +35 -0
  22. package/examples/planet-example-data.json +56 -0
  23. package/examples/planet-pie-example-config.json +28 -0
  24. package/examples/private/newtest.csv +101 -0
  25. package/examples/private/test.json +10124 -0
  26. package/examples/temp-example-config.json +57 -0
  27. package/examples/temp-example-data.json +130 -0
  28. package/package.json +9 -8
  29. package/src/CdcChart.tsx +836 -0
  30. package/src/components/BarChart.tsx +571 -0
  31. package/src/components/BarStackVertical.js +0 -0
  32. package/src/components/DataTable.tsx +229 -0
  33. package/src/components/EditorPanel.js +1319 -0
  34. package/src/components/LineChart.tsx +76 -0
  35. package/src/components/LinearChart.tsx +459 -0
  36. package/src/components/PairedBarChart.tsx +144 -0
  37. package/src/components/PieChart.tsx +189 -0
  38. package/src/components/SparkLine.js +206 -0
  39. package/src/context.tsx +5 -0
  40. package/src/data/initial-state.js +61 -0
  41. package/src/hooks/useActiveElement.js +19 -0
  42. package/src/hooks/useColorPalette.ts +83 -0
  43. package/src/hooks/useReduceData.ts +43 -0
  44. package/src/images/active-checkmark.svg +1 -0
  45. package/src/images/asc.svg +1 -0
  46. package/src/images/desc.svg +1 -0
  47. package/src/images/inactive-checkmark.svg +1 -0
  48. package/src/images/warning.svg +1 -0
  49. package/src/index.html +68 -0
  50. package/src/index.tsx +21 -0
  51. package/src/scss/DataTable.scss +23 -0
  52. package/src/scss/LinearChart.scss +0 -0
  53. package/src/scss/editor-panel.scss +693 -0
  54. package/src/scss/main.scss +426 -0
  55. package/src/scss/mixins.scss +0 -0
  56. package/src/scss/variables.scss +1 -0
@@ -0,0 +1,426 @@
1
+ @import '~@cdc/core/styles/base';
2
+ @import "~@cdc/core/styles/heading-colors";
3
+ @import 'mixins';
4
+ @import 'variables';
5
+ @import '~@cdc/core/styles/v2/themes/color-definitions';
6
+
7
+ .form-container {
8
+ overflow: scroll;
9
+ }
10
+
11
+ .d-flex { display: flex; }
12
+ .flex-column-reverse {
13
+ flex-direction: column-reverse;
14
+ }
15
+
16
+ .cdc-open-viz-module.type-chart {
17
+ @import 'DataTable';
18
+ @import 'editor-panel';
19
+
20
+ border-radius: 3px;
21
+
22
+ .visually-hidden {
23
+ position: fixed;
24
+ left: -10000px;
25
+ }
26
+
27
+ .loader {
28
+ width: 100%;
29
+ text-align: center;
30
+ display: inline-block;
31
+ animation: spin 1s linear infinite;
32
+
33
+ &::before {
34
+ content: '\21BB';
35
+ }
36
+ }
37
+
38
+ .btn {
39
+ background: #005eaa;
40
+ color: #fff !important;
41
+ border: 0;
42
+ padding: .4em .8em;
43
+ display: block;
44
+ border-radius: 5px;
45
+ transition: .1s all;
46
+ cursor: pointer;
47
+
48
+ &[disabled] {
49
+ opacity: 0.5;
50
+ z-index: -1;
51
+ position: relative;
52
+ }
53
+ }
54
+
55
+ .warning-icon {
56
+ position: relative;
57
+ top: 2px;
58
+ width: 15px;
59
+ height: 15px;
60
+ margin-left: 5px;
61
+
62
+ path {
63
+ fill: #d8000c;
64
+ }
65
+ }
66
+
67
+ .chart-title {
68
+ position: relative;
69
+ padding: .6em .8em;
70
+ margin: 0;
71
+ color: #fff;
72
+ font-size: 1.1em;
73
+ border-bottom-width: 3px;
74
+ border-bottom-style: solid;
75
+
76
+ border-top-left-radius: 3px;
77
+ border-top-right-radius: 3px;
78
+
79
+ em {
80
+ font-style: italic;
81
+ }
82
+
83
+ strong {
84
+ font-weight: bold;
85
+ }
86
+
87
+ &:not(:empty) {
88
+ margin: 0 0 1rem 0 !important;
89
+ padding: .6em .8em;
90
+ border-bottom-width: 3px;
91
+ border-bottom-style: solid;
92
+ }
93
+ }
94
+
95
+ .chart-description {
96
+ margin-bottom: 20px;
97
+ }
98
+
99
+ .legend-container {
100
+ background: #fff;
101
+ width: 100%;
102
+ padding: 15px;
103
+ vertical-align: top;
104
+ text-align: center;
105
+ border: 1px solid $lightGray;
106
+ order: 1;
107
+ position: relative;
108
+
109
+ .legend-reset {
110
+ font-size: .7em;
111
+ color: rgba(0, 0, 0, 0.6);
112
+ position: absolute;
113
+ right: 1em;
114
+ background: rgba(0, 0, 0, 0.1);
115
+ text-transform: uppercase;
116
+ transition: .3s all;
117
+ padding: .375rem;
118
+ top: 1em;
119
+ border-radius: 3px;
120
+
121
+ &:hover {
122
+ background: rgba(0, 0, 0, .15);
123
+ transition: .3s all;
124
+ }
125
+ }
126
+
127
+ .legend-item {
128
+ text-align: left;
129
+ align-items: flex-start !important;
130
+ user-select: none;
131
+ }
132
+
133
+ .legend-item > .legend-item {
134
+ display: inline-block;
135
+ margin-right: .5rem;
136
+ flex: 0 0 auto;
137
+ }
138
+
139
+ h2 {
140
+ font-size: 1.3em;
141
+ margin-bottom: .3em;
142
+ }
143
+
144
+ .legend-item {
145
+ cursor: pointer;
146
+ transition: .2s all;
147
+
148
+ &.inactive {
149
+ opacity: .5;
150
+ transition: .2s all;
151
+ }
152
+ }
153
+ }
154
+
155
+ .tooltip {
156
+ background-color: #fff;
157
+ border: rgba(0, 0, 0, 0.3) 1px solid !important;
158
+ box-shadow: rgba(0, 0, 0, .1) 3px 3px 7px;
159
+ line-height: 1.4em;
160
+ font-size: 1em !important;
161
+ border-radius: 4px !important;
162
+ padding: 8px 12px !important;
163
+ opacity: 1;
164
+ }
165
+
166
+ .region-table {
167
+ margin-top: 15px;
168
+ }
169
+
170
+ .chart-container {
171
+ display: flex;
172
+ align-items: flex-start;
173
+ flex-wrap: wrap;
174
+ margin-bottom: 1em;
175
+
176
+ &.legend-hidden > svg {
177
+ width: 100% !important;
178
+ }
179
+
180
+ > svg {
181
+ overflow: visible;
182
+ font-size: 14px;
183
+ margin: 1rem 0 2rem;
184
+
185
+ .visx-linepath {
186
+ pointer-events: none;
187
+ }
188
+
189
+ circle {
190
+ opacity: 0;
191
+ }
192
+ }
193
+
194
+ &.chart-line--hover {
195
+ > svg circle {
196
+ opacity: 0;
197
+
198
+ &:hover {
199
+ opacity: 1;
200
+ }
201
+ }
202
+ }
203
+
204
+ &.chart-line--always {
205
+ > svg circle {
206
+ opacity: 1;
207
+ }
208
+ }
209
+
210
+ &.chart-bar--no-border {
211
+ .visx-group:not(.visx-axis) rect {
212
+ stroke: none;
213
+ }
214
+ }
215
+ }
216
+
217
+ .filters-section {
218
+ display: inline-block;
219
+
220
+ label:not(:empty) {
221
+ margin-right: .4em;
222
+ }
223
+
224
+ select {
225
+ font-size: 1em;
226
+ }
227
+
228
+ .single-filter + .single-filter {
229
+ margin-left: 1em;
230
+ }
231
+ }
232
+
233
+ @include breakpointClass(xs) {
234
+ &.font-small {
235
+ font-size: .8em;
236
+
237
+ .chart-container > svg {
238
+ font-size: 12px;
239
+ }
240
+ }
241
+
242
+ &.font-medium {
243
+ font-size: .9em;
244
+
245
+ .chart-container > svg {
246
+ font-size: 14px;
247
+ }
248
+ }
249
+
250
+ &.font-large {
251
+ font-size: 1em;
252
+
253
+ .chart-container > svg {
254
+ font-size: 16px;
255
+ }
256
+ }
257
+ }
258
+
259
+ @include breakpointClass(md) {
260
+ .filters-section, .chart-container:not(.sparkline) {
261
+ margin-left: 1em;
262
+ margin-right: 1em;
263
+ }
264
+
265
+ .chart-container {
266
+ flex-wrap: nowrap;
267
+
268
+ .legend-container {
269
+ width: 25%;
270
+ margin-left: 1em;
271
+ order: 2;
272
+
273
+ &.left {
274
+ margin-left: 0;
275
+ margin-right: 1em;
276
+ order: 0;
277
+ }
278
+ }
279
+
280
+ > svg {
281
+ font-size: 16px;
282
+ width: 75%;
283
+ order: 1;
284
+
285
+ circle {
286
+ filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, .5));
287
+ transform-origin: 50% 50%;
288
+ }
289
+ }
290
+ }
291
+
292
+ &.font-small {
293
+ font-size: .9em;
294
+
295
+ .chart-container > svg {
296
+ font-size: 14px;
297
+ }
298
+ }
299
+
300
+ &.font-large {
301
+ font-size: 1.1em;
302
+
303
+ .chart-container > svg {
304
+ font-size: 18px;
305
+ }
306
+ }
307
+ }
308
+
309
+ @include breakpointClass(lg) {
310
+ &.font-small {
311
+ font-size: 1em;
312
+
313
+ .chart-container > svg {
314
+ font-size: 16px;
315
+ }
316
+ }
317
+
318
+ &.font-medium {
319
+ font-size: 1.1em;
320
+
321
+ .chart-container > svg {
322
+ font-size: 18px;
323
+ }
324
+ }
325
+
326
+ &.font-large {
327
+ font-size: 1.2em;
328
+
329
+ .chart-container > svg {
330
+ font-size: 20px;
331
+ }
332
+ }
333
+ }
334
+ [tabindex]:focus-visible {
335
+ outline: 2px solid rgb(0, 95, 204) !important;
336
+ }
337
+ }
338
+
339
+ #paired-bar-legend {
340
+
341
+ text-align: center;
342
+
343
+ div {
344
+ margin: 0 0.5em;
345
+ display: flex;
346
+ }
347
+
348
+ .indicator {
349
+ width: 1em;
350
+ height: 1em;
351
+ vertical-align: middle;
352
+ margin: 0.25em;
353
+ }
354
+ }
355
+
356
+
357
+ .isEditor.type-sparkline .cdc-chart-inner-container {
358
+ margin: 3em auto 0;
359
+ max-width: 60%;
360
+ }
361
+
362
+ .cdc-open-viz-module.type-chart.lg.type-sparkline .chart-container > svg {
363
+ width: 100%;
364
+ }
365
+
366
+ .chart-container.sparkline {
367
+ display: flex !important;
368
+ flex-wrap: wrap !important;
369
+ }
370
+
371
+ .cdc-open-viz-module.type-chart.type-sparkline {
372
+
373
+ .cove-component__content {
374
+ background: #F2F2F2;
375
+ }
376
+
377
+ .cove-component__content.component--hideBackgroundColor {
378
+ background: transparent;
379
+ }
380
+
381
+ .chart-title:not(:empty) {
382
+ margin-bottom: 0 !important;
383
+ }
384
+
385
+ .cove-component__content .chart-container {
386
+ padding: 1em;
387
+ }
388
+
389
+ .cove-component__content:not(.no-borders) {
390
+ border: 1px solid $lightGray
391
+ }
392
+
393
+ .cove-component__header ~ .cove-component__content:not(.no-borders) {
394
+ border-top: none !important;
395
+ }
396
+
397
+ .subtext {
398
+ margin-top: 0px;
399
+ }
400
+
401
+ .isEditor {
402
+ position: relative;
403
+ }
404
+
405
+ .subtext {
406
+ margin-bottom: 15px;
407
+ }
408
+
409
+ }
410
+
411
+ .cdc-open-viz-module .cove-component__content.sparkline {
412
+ padding: 1em;
413
+ }
414
+
415
+ .cove-component__content.sparkline {
416
+ border-bottom-left-radius: 3px;
417
+ border-bottom-right-radius: 3px;
418
+
419
+ .visx-axis-tick:first-of-type {
420
+ transform: translate(20px, 0)
421
+ }
422
+
423
+ .visx-axis-tick:last-of-type {
424
+ transform: translate(-20px, 0)
425
+ }
426
+ }
File without changes
@@ -0,0 +1 @@
1
+ $editorWidth: 350px;