@cdc/chart 1.3.4 → 4.22.11

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 (75) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +5 -5
  3. package/dist/cdcchart.js +6 -6
  4. package/examples/age-adjusted-rates.json +1486 -1218
  5. package/examples/case-rate-example-config.json +1 -1
  6. package/examples/covid-confidence-example-config.json +33 -33
  7. package/examples/covid-example-config.json +34 -34
  8. package/examples/covid-example-data-confidence.json +30 -30
  9. package/examples/covid-example-data.json +20 -20
  10. package/examples/cutoff-example-config.json +36 -34
  11. package/examples/cutoff-example-data.json +36 -36
  12. package/examples/date-exclusions-config.json +1 -1
  13. package/examples/dynamic-legends.json +125 -0
  14. package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart-with-numbers-on-bar.json +192 -0
  15. package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart.json +231 -0
  16. package/examples/gallery/bar-chart-horizontal/horizontal-stacked.json +240 -0
  17. package/examples/gallery/bar-chart-vertical/combo-line-chart.json +137 -0
  18. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-categorical.json +80 -0
  19. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +81 -0
  20. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-with-confidence.json +68 -0
  21. package/examples/gallery/bar-chart-vertical/vertical-bar-chart.json +111 -0
  22. package/examples/gallery/lollipop/lollipop-style-horizontal.json +216 -0
  23. package/examples/gallery/paired-bar/paired-bar-chart.json +196 -0
  24. package/examples/horizontal-chart.json +36 -33
  25. package/examples/horizontal-stacked-bar-chart.json +34 -34
  26. package/examples/line-chart.json +75 -75
  27. package/examples/paired-bar-data.json +16 -14
  28. package/examples/paired-bar-example.json +48 -46
  29. package/examples/paired-bar-formatted.json +36 -36
  30. package/examples/planet-chart-horizontal-example-config.json +33 -33
  31. package/examples/planet-combo-example-config.json +34 -29
  32. package/examples/planet-example-config.json +35 -33
  33. package/examples/planet-example-data.json +56 -56
  34. package/examples/planet-pie-example-config.json +28 -26
  35. package/examples/private/filters.json +170 -0
  36. package/examples/private/line-test-data.json +22 -0
  37. package/examples/private/line-test-two.json +210 -0
  38. package/examples/private/line-test.json +102 -0
  39. package/examples/private/new.json +48800 -0
  40. package/examples/private/shawn.json +1106 -0
  41. package/examples/private/test.json +10123 -10123
  42. package/examples/private/yaxis-test.json +133 -0
  43. package/examples/private/yaxis-testing.csv +27 -0
  44. package/examples/private/yaxis.json +28 -0
  45. package/examples/stacked-vertical-bar-example.json +228 -0
  46. package/examples/temp-example-config.json +61 -54
  47. package/examples/temp-example-data.json +1 -1
  48. package/package.json +2 -2
  49. package/src/CdcChart.tsx +370 -458
  50. package/src/components/BarChart.tsx +449 -441
  51. package/src/components/DataTable.tsx +164 -180
  52. package/src/components/EditorPanel.js +1066 -663
  53. package/src/components/Legend.js +284 -0
  54. package/src/components/LineChart.tsx +114 -63
  55. package/src/components/LinearChart.tsx +394 -358
  56. package/src/components/PairedBarChart.tsx +216 -135
  57. package/src/components/PieChart.tsx +106 -135
  58. package/src/components/SparkLine.js +184 -205
  59. package/src/components/useIntersectionObserver.tsx +27 -0
  60. package/src/context.tsx +3 -3
  61. package/src/data/initial-state.js +44 -7
  62. package/src/hooks/useActiveElement.js +13 -13
  63. package/src/hooks/useChartClasses.js +41 -0
  64. package/src/hooks/useColorPalette.ts +56 -63
  65. package/src/hooks/useLegendClasses.js +28 -0
  66. package/src/hooks/useReduceData.ts +69 -37
  67. package/src/hooks/useRightAxis.js +25 -0
  68. package/src/hooks/useTopAxis.js +6 -0
  69. package/src/index.html +54 -55
  70. package/src/index.tsx +13 -16
  71. package/src/scss/DataTable.scss +5 -4
  72. package/src/scss/editor-panel.scss +103 -71
  73. package/src/scss/main.scss +277 -38
  74. package/src/scss/variables.scss +1 -1
  75. package/src/components/BarStackVertical.js +0 -0
@@ -1,14 +1,16 @@
1
1
  @import '~@cdc/core/styles/base';
2
- @import "~@cdc/core/styles/heading-colors";
2
+ @import '~@cdc/core/styles/heading-colors';
3
3
  @import 'mixins';
4
4
  @import 'variables';
5
5
  @import '~@cdc/core/styles/v2/themes/color-definitions';
6
6
 
7
7
  .form-container {
8
- overflow: scroll;
8
+ overflow-y: auto;
9
9
  }
10
10
 
11
- .d-flex { display: flex; }
11
+ .d-flex {
12
+ display: flex;
13
+ }
12
14
  .flex-column-reverse {
13
15
  flex-direction: column-reverse;
14
16
  }
@@ -19,6 +21,14 @@
19
21
 
20
22
  border-radius: 3px;
21
23
 
24
+ .checkbox-group {
25
+ padding: 16px;
26
+ border: 1px solid #c4c4c4;
27
+ border-radius: 8px;
28
+ margin-top: 8px;
29
+ margin-bottom: 24px;
30
+ }
31
+
22
32
  .visually-hidden {
23
33
  position: fixed;
24
34
  left: -10000px;
@@ -39,10 +49,10 @@
39
49
  background: #005eaa;
40
50
  color: #fff !important;
41
51
  border: 0;
42
- padding: .4em .8em;
52
+ padding: 0.4em 0.8em;
43
53
  display: block;
44
54
  border-radius: 5px;
45
- transition: .1s all;
55
+ transition: 0.1s all;
46
56
  cursor: pointer;
47
57
 
48
58
  &[disabled] {
@@ -66,7 +76,7 @@
66
76
 
67
77
  .chart-title {
68
78
  position: relative;
69
- padding: .6em .8em;
79
+ padding: 0.6em 0.8em;
70
80
  margin: 0;
71
81
  color: #fff;
72
82
  font-size: 1.1em;
@@ -86,7 +96,7 @@
86
96
 
87
97
  &:not(:empty) {
88
98
  margin: 0 0 1rem 0 !important;
89
- padding: .6em .8em;
99
+ padding: 0.6em 0.8em;
90
100
  border-bottom-width: 3px;
91
101
  border-bottom-style: solid;
92
102
  }
@@ -96,31 +106,67 @@
96
106
  margin-bottom: 20px;
97
107
  }
98
108
 
109
+ .section-subtext {
110
+ padding: 15px;
111
+ }
112
+
99
113
  .legend-container {
100
114
  background: #fff;
101
115
  width: 100%;
102
116
  padding: 15px;
103
117
  vertical-align: top;
104
- text-align: center;
118
+ text-align: left;
105
119
  border: 1px solid $lightGray;
106
120
  order: 1;
107
121
  position: relative;
108
122
 
123
+ &__inner{
124
+ &.bottom{
125
+ display: grid;
126
+ grid-template-columns: auto auto;
127
+ }
128
+
129
+ &.single-row{
130
+ display: flex;
131
+ flex-direction: row;
132
+ flex-wrap: wrap;
133
+ justify-content: flex-start;
134
+
135
+ & >div{
136
+ padding:0 1.2em 1em 0;
137
+ }
138
+
139
+ & div>span {
140
+ margin-right: 0!important;
141
+ }
142
+
143
+ & >div.legend-item{
144
+ margin: 0 !important;
145
+ }
146
+ }
147
+ }
148
+
109
149
  .legend-reset {
110
- font-size: .7em;
150
+ font-size: 0.7em;
111
151
  color: rgba(0, 0, 0, 0.6);
112
152
  position: absolute;
113
153
  right: 1em;
114
154
  background: rgba(0, 0, 0, 0.1);
115
155
  text-transform: uppercase;
116
- transition: .3s all;
117
- padding: .375rem;
156
+ transition: 0.3s all;
157
+ padding: 0.375rem;
118
158
  top: 1em;
119
159
  border-radius: 3px;
120
160
 
161
+ &--dynamic {
162
+ position: relative;
163
+ float: right;
164
+ right: unset;
165
+ }
166
+
121
167
  &:hover {
122
- background: rgba(0, 0, 0, .15);
123
- transition: .3s all;
168
+ background: rgba(0, 0, 0, 0.15);
169
+ transition: 0.3s all;
124
170
  }
125
171
  }
126
172
 
@@ -132,30 +178,62 @@
132
178
 
133
179
  .legend-item > .legend-item {
134
180
  display: inline-block;
135
- margin-right: .5rem;
181
+ margin-right: 0.5rem;
136
182
  flex: 0 0 auto;
137
183
  }
138
184
 
139
185
  h2 {
140
186
  font-size: 1.3em;
141
- margin-bottom: .3em;
187
+ }
188
+
189
+ h2,p{
190
+ margin-bottom: 0.8em;
191
+ }
192
+ & div.legend-item{
193
+ margin-bottom: 0.5em !important;
194
+
195
+ &:last-child{
196
+ margin: 0 !important;
197
+ }
142
198
  }
143
199
 
144
200
  .legend-item {
145
201
  cursor: pointer;
146
- transition: .2s all;
202
+ transition: 0.2s all;
147
203
 
148
204
  &.inactive {
149
- opacity: .5;
150
- transition: .2s all;
205
+ opacity: 0.5;
206
+ transition: 0.2s all;
207
+ }
208
+ }
209
+ }
210
+
211
+ .dynamic-legend-list {
212
+ // overide traditional legend item that uses !important
213
+ .legend-item {
214
+ align-items: flex-end !important;
215
+ justify-content: space-between;
216
+
217
+ .btn-wrapper {
218
+ background: transparent;
151
219
  }
152
220
  }
221
+
222
+ .visx-legend-label {
223
+ width: auto !important;
224
+ display: inline-block !important;
225
+ }
226
+
227
+ button {
228
+ width: auto;
229
+ display: inline-block;
230
+ }
153
231
  }
154
232
 
155
233
  .tooltip {
156
234
  background-color: #fff;
157
235
  border: rgba(0, 0, 0, 0.3) 1px solid !important;
158
- box-shadow: rgba(0, 0, 0, .1) 3px 3px 7px;
236
+ box-shadow: rgba(0, 0, 0, 0.1) 3px 3px 7px;
159
237
  line-height: 1.4em;
160
238
  font-size: 1em !important;
161
239
  border-radius: 4px !important;
@@ -173,6 +251,10 @@
173
251
  flex-wrap: wrap;
174
252
  margin-bottom: 1em;
175
253
 
254
+ &.bottom{
255
+ flex-wrap: nowrap;
256
+ flex-direction: column;
257
+ }
176
258
  &.legend-hidden > svg {
177
259
  width: 100% !important;
178
260
  }
@@ -205,6 +287,32 @@
205
287
  > svg circle {
206
288
  opacity: 1;
207
289
  }
290
+
291
+ // Animations for line chart and data points
292
+ > svg.animated {
293
+ circle {
294
+ opacity: 0;
295
+ animation: revealLolly 0.25s linear forwards;
296
+ animation-delay: 0.75s;
297
+ animation-play-state: paused;
298
+ }
299
+
300
+ &.animate {
301
+ circle {
302
+ animation-play-state: running;
303
+ }
304
+ }
305
+ }
306
+ }
307
+
308
+ @keyframes revealLolly {
309
+ from {
310
+ opacity: 0;
311
+ }
312
+
313
+ to {
314
+ opacity: 1;
315
+ }
208
316
  }
209
317
 
210
318
  &.chart-bar--no-border {
@@ -215,24 +323,27 @@
215
323
  }
216
324
 
217
325
  .filters-section {
218
- display: inline-block;
326
+ @include breakpoint(md) {
327
+ display: flex;
328
+ gap: 30px;
329
+ }
219
330
 
220
331
  label:not(:empty) {
221
- margin-right: .4em;
332
+ margin-right: 0.4em;
222
333
  }
223
334
 
224
335
  select {
225
336
  font-size: 1em;
226
337
  }
227
338
 
228
- .single-filter + .single-filter {
229
- margin-left: 1em;
339
+ .single-filter {
340
+ margin-bottom: 0.5em;
230
341
  }
231
342
  }
232
343
 
233
344
  @include breakpointClass(xs) {
234
345
  &.font-small {
235
- font-size: .8em;
346
+ font-size: 0.8em;
236
347
 
237
348
  .chart-container > svg {
238
349
  font-size: 12px;
@@ -240,7 +351,7 @@
240
351
  }
241
352
 
242
353
  &.font-medium {
243
- font-size: .9em;
354
+ font-size: 0.9em;
244
355
 
245
356
  .chart-container > svg {
246
357
  font-size: 14px;
@@ -257,7 +368,8 @@
257
368
  }
258
369
 
259
370
  @include breakpointClass(md) {
260
- .filters-section, .chart-container:not(.sparkline) {
371
+ .filters-section,
372
+ .chart-container:not(.sparkline) {
261
373
  margin-left: 1em;
262
374
  margin-right: 1em;
263
375
  }
@@ -275,6 +387,10 @@
275
387
  margin-right: 1em;
276
388
  order: 0;
277
389
  }
390
+ &.bottom{
391
+ width: 100%;
392
+ margin-left: 0;
393
+ }
278
394
  }
279
395
 
280
396
  > svg {
@@ -283,14 +399,14 @@
283
399
  order: 1;
284
400
 
285
401
  circle {
286
- filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, .5));
402
+ filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.5));
287
403
  transform-origin: 50% 50%;
288
404
  }
289
405
  }
290
406
  }
291
407
 
292
408
  &.font-small {
293
- font-size: .9em;
409
+ font-size: 0.9em;
294
410
 
295
411
  .chart-container > svg {
296
412
  font-size: 14px;
@@ -306,6 +422,8 @@
306
422
  }
307
423
  }
308
424
 
425
+
426
+
309
427
  @include breakpointClass(lg) {
310
428
  &.font-small {
311
429
  font-size: 1em;
@@ -331,13 +449,137 @@
331
449
  }
332
450
  }
333
451
  }
452
+
334
453
  [tabindex]:focus-visible {
335
454
  outline: 2px solid rgb(0, 95, 204) !important;
336
455
  }
456
+
457
+ // ANIMATIONS
458
+ // Pie Chart Animations
459
+ .animated-pie {
460
+ transition: all 0.4s ease-in-out;
461
+ opacity: 0;
462
+ transform-origin: center;
463
+ transform: scale(0, 0);
464
+
465
+ &.animated {
466
+ opacity: 1;
467
+ transform-origin: center;
468
+ transform: scale(1, 1);
469
+ }
470
+
471
+ path,
472
+ text {
473
+ border: rgba(0, 0, 0, 0.3) 1px solid !important;
474
+ box-shadow: rgba(0, 0, 0, 0.1) 3px 3px 7px;
475
+ opacity: 1;
476
+ line-height: 1.4em;
477
+ font-size: 1em;
478
+ border-radius: 4px;
479
+ padding: 8px 12px;
480
+ }
481
+
482
+ .animated-pie-text {
483
+ opacity: 0;
484
+ transition: opacity 0.5s ease-in-out;
485
+ transition-delay: 0.4s;
486
+
487
+ &.animated {
488
+ opacity: 1;
489
+ }
490
+ }
491
+ }
492
+
493
+ // Line/Combo Chart Animations
494
+ .linear,
495
+ .Line,
496
+ .Combo {
497
+ &.animated path {
498
+ opacity: 0;
499
+ }
500
+ &.animate {
501
+ path {
502
+ opacity: 1;
503
+ stroke-dasharray: 2000;
504
+ stroke-dashoffset: 2000;
505
+ animation: dash 2s ease-in-out forwards;
506
+ }
507
+ @keyframes dash {
508
+ to {
509
+ stroke-dashoffset: 0;
510
+ }
511
+ }
512
+ }
513
+ }
514
+
515
+ // Bar/Combo Chart Animations
516
+ .linear,
517
+ .Bar,
518
+ .Combo {
519
+ .visx-group {
520
+ position: relative;
521
+ }
522
+
523
+ &.animated {
524
+ .vertical rect,
525
+ .vertical foreignObject {
526
+ opacity: 0;
527
+ animation: growBar 0.5s linear forwards;
528
+ animation-play-state: paused;
529
+ }
530
+
531
+ .horizontal rect,
532
+ .horizontal foreignObject {
533
+ animation: growBarH 0.5s linear forwards;
534
+ animation-play-state: paused;
535
+ }
536
+
537
+ &.animate {
538
+ rect,
539
+ foreignObject {
540
+ animation-play-state: running;
541
+ }
542
+ }
543
+
544
+ .group-1,
545
+ .group-2 {
546
+ transform-origin: center;
547
+ }
548
+ }
549
+ }
550
+
551
+ @keyframes growBar {
552
+ from {
553
+ opacity: 1;
554
+ transform: scale(1, 0);
555
+ }
556
+
557
+ to {
558
+ opacity: 1;
559
+ transform: scale(1);
560
+ }
561
+ }
562
+
563
+ @keyframes growBarH {
564
+ from {
565
+ transform: scale(0, 1);
566
+ }
567
+
568
+ to {
569
+ transform: scale(1);
570
+ }
571
+ }
337
572
  }
338
573
 
339
- #paired-bar-legend {
574
+ .cdc-visualization__paired-bar-chart {
575
+ text-align: center;
576
+ transform: scale(1);
577
+ > .visx-group[style] {
578
+ transform: scale(1);
579
+ }
580
+ }
340
581
 
582
+ #paired-bar-legend {
341
583
  text-align: center;
342
584
 
343
585
  div {
@@ -353,10 +595,9 @@
353
595
  }
354
596
  }
355
597
 
356
-
357
598
  .isEditor.type-sparkline .cdc-chart-inner-container {
358
- margin: 3em auto 0;
359
- max-width: 60%;
599
+ margin: 3em auto 0;
600
+ max-width: 60%;
360
601
  }
361
602
 
362
603
  .cdc-open-viz-module.type-chart.lg.type-sparkline .chart-container > svg {
@@ -369,9 +610,8 @@
369
610
  }
370
611
 
371
612
  .cdc-open-viz-module.type-chart.type-sparkline {
372
-
373
613
  .cove-component__content {
374
- background: #F2F2F2;
614
+ background: #f2f2f2;
375
615
  }
376
616
 
377
617
  .cove-component__content.component--hideBackgroundColor {
@@ -387,7 +627,7 @@
387
627
  }
388
628
 
389
629
  .cove-component__content:not(.no-borders) {
390
- border: 1px solid $lightGray
630
+ border: 1px solid $lightGray;
391
631
  }
392
632
 
393
633
  .cove-component__header ~ .cove-component__content:not(.no-borders) {
@@ -405,7 +645,6 @@
405
645
  .subtext {
406
646
  margin-bottom: 15px;
407
647
  }
408
-
409
648
  }
410
649
 
411
650
  .cdc-open-viz-module .cove-component__content.sparkline {
@@ -417,10 +656,10 @@
417
656
  border-bottom-right-radius: 3px;
418
657
 
419
658
  .visx-axis-tick:first-of-type {
420
- transform: translate(20px, 0)
659
+ transform: translate(20px, 0);
421
660
  }
422
661
 
423
662
  .visx-axis-tick:last-of-type {
424
- transform: translate(-20px, 0)
663
+ transform: translate(-20px, 0);
425
664
  }
426
665
  }
@@ -1 +1 @@
1
- $editorWidth: 350px;
1
+ $editorWidth: 350px;
File without changes