@cdc/chart 4.22.10 → 4.23.1

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 (80) hide show
  1. package/README.md +5 -5
  2. package/dist/495.js +3 -0
  3. package/dist/703.js +1 -0
  4. package/dist/cdcchart.js +723 -6
  5. package/examples/age-adjusted-rates.json +1486 -1218
  6. package/examples/box-plot-data.json +71 -0
  7. package/examples/box-plot.csv +5 -0
  8. package/examples/{private/yaxis-test.json → box-plot.json} +46 -54
  9. package/examples/case-rate-example-config.json +1 -1
  10. package/examples/covid-confidence-example-config.json +33 -33
  11. package/examples/covid-example-config.json +34 -34
  12. package/examples/covid-example-data-confidence.json +30 -30
  13. package/examples/covid-example-data.json +20 -20
  14. package/examples/cutoff-example-config.json +36 -36
  15. package/examples/cutoff-example-data.json +36 -36
  16. package/examples/date-exclusions-config.json +1 -1
  17. package/examples/dynamic-legends.json +124 -124
  18. package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart-with-numbers-on-bar.json +191 -197
  19. package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart.json +230 -240
  20. package/examples/gallery/bar-chart-horizontal/horizontal-stacked.json +239 -247
  21. package/examples/gallery/bar-chart-vertical/combo-line-chart.json +138 -136
  22. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-categorical.json +79 -79
  23. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +80 -80
  24. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-with-confidence.json +67 -67
  25. package/examples/gallery/bar-chart-vertical/vertical-bar-chart.json +179 -110
  26. package/examples/gallery/lollipop/lollipop-style-horizontal.json +215 -219
  27. package/examples/gallery/paired-bar/paired-bar-chart.json +195 -195
  28. package/examples/horizontal-chart.json +35 -35
  29. package/examples/horizontal-stacked-bar-chart.json +34 -34
  30. package/examples/line-chart.json +75 -75
  31. package/examples/new-data.csv +17 -0
  32. package/examples/newdata.json +90 -0
  33. package/examples/paired-bar-data.json +16 -14
  34. package/examples/paired-bar-example.json +48 -48
  35. package/examples/paired-bar-formatted.json +36 -36
  36. package/examples/planet-chart-horizontal-example-config.json +33 -33
  37. package/examples/planet-combo-example-config.json +34 -31
  38. package/examples/planet-example-config.json +35 -33
  39. package/examples/planet-example-data.json +56 -56
  40. package/examples/planet-pie-example-config.json +28 -28
  41. package/examples/stacked-vertical-bar-example.json +1 -1
  42. package/examples/temp-example-config.json +61 -54
  43. package/examples/temp-example-data.json +1 -1
  44. package/package.json +3 -2
  45. package/src/CdcChart.tsx +449 -434
  46. package/src/components/BarChart.tsx +383 -497
  47. package/src/components/BoxPlot.js +92 -0
  48. package/src/components/DataTable.tsx +182 -197
  49. package/src/components/EditorPanel.js +1068 -722
  50. package/src/components/Filters.js +131 -0
  51. package/src/components/Legend.js +286 -329
  52. package/src/components/LineChart.tsx +143 -81
  53. package/src/components/LinearChart.tsx +432 -451
  54. package/src/components/PairedBarChart.tsx +197 -213
  55. package/src/components/PieChart.tsx +105 -151
  56. package/src/components/SparkLine.js +179 -201
  57. package/src/components/useIntersectionObserver.tsx +19 -20
  58. package/src/context.tsx +3 -3
  59. package/src/data/initial-state.js +44 -17
  60. package/src/hooks/useActiveElement.js +13 -13
  61. package/src/hooks/useChartClasses.js +34 -28
  62. package/src/hooks/useColorPalette.ts +56 -63
  63. package/src/hooks/useLegendClasses.js +18 -10
  64. package/src/hooks/useReduceData.ts +64 -77
  65. package/src/hooks/useRightAxis.js +25 -0
  66. package/src/hooks/useTopAxis.js +6 -0
  67. package/src/index.html +19 -19
  68. package/src/index.tsx +13 -16
  69. package/src/scss/DataTable.scss +6 -5
  70. package/src/scss/editor-panel.scss +71 -69
  71. package/src/scss/main.scss +188 -114
  72. package/src/scss/variables.scss +1 -1
  73. package/examples/private/line-test-data.json +0 -22
  74. package/examples/private/line-test-two.json +0 -216
  75. package/examples/private/line-test.json +0 -102
  76. package/examples/private/newtest.csv +0 -101
  77. package/examples/private/shawn.json +0 -1296
  78. package/examples/private/test.json +0 -10124
  79. package/examples/private/yaxis-testing.csv +0 -27
  80. package/examples/private/yaxis.json +0 -28
@@ -1,5 +1,5 @@
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';
@@ -8,7 +8,9 @@
8
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
  }
@@ -24,7 +26,7 @@
24
26
  border: 1px solid #c4c4c4;
25
27
  border-radius: 8px;
26
28
  margin-top: 8px;
27
- margin-bottom: 24px;
29
+ margin-bottom: 24px;
28
30
  }
29
31
 
30
32
  .visually-hidden {
@@ -47,10 +49,10 @@
47
49
  background: #005eaa;
48
50
  color: #fff !important;
49
51
  border: 0;
50
- padding: .4em .8em;
52
+ padding: 0.4em 0.8em;
51
53
  display: block;
52
54
  border-radius: 5px;
53
- transition: .1s all;
55
+ transition: 0.1s all;
54
56
  cursor: pointer;
55
57
 
56
58
  &[disabled] {
@@ -74,7 +76,7 @@
74
76
 
75
77
  .chart-title {
76
78
  position: relative;
77
- padding: .6em .8em;
79
+ padding: 0.6em 0.8em;
78
80
  margin: 0;
79
81
  color: #fff;
80
82
  font-size: 1.1em;
@@ -94,7 +96,7 @@
94
96
 
95
97
  &:not(:empty) {
96
98
  margin: 0 0 1rem 0 !important;
97
- padding: .6em .8em;
99
+ padding: 0.6em 0.8em;
98
100
  border-bottom-width: 3px;
99
101
  border-bottom-style: solid;
100
102
  }
@@ -113,24 +115,49 @@
113
115
  width: 100%;
114
116
  padding: 15px;
115
117
  vertical-align: top;
116
- text-align: center;
118
+ text-align: left;
117
119
  border: 1px solid $lightGray;
118
120
  order: 1;
119
121
  position: relative;
120
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
+
121
149
  .legend-reset {
122
- font-size: .7em;
150
+ font-size: 0.7em;
123
151
  color: rgba(0, 0, 0, 0.6);
124
152
  position: absolute;
125
153
  right: 1em;
126
154
  background: rgba(0, 0, 0, 0.1);
127
155
  text-transform: uppercase;
128
- transition: .3s all;
129
- padding: .375rem;
156
+ transition: 0.3s all;
157
+ padding: 0.375rem;
130
158
  top: 1em;
131
159
  border-radius: 3px;
132
160
 
133
-
134
161
  &--dynamic {
135
162
  position: relative;
136
163
  float: right;
@@ -138,8 +165,8 @@
138
165
  }
139
166
 
140
167
  &:hover {
141
- background: rgba(0, 0, 0, .15);
142
- transition: .3s all;
168
+ background: rgba(0, 0, 0, 0.15);
169
+ transition: 0.3s all;
143
170
  }
144
171
  }
145
172
 
@@ -151,28 +178,38 @@
151
178
 
152
179
  .legend-item > .legend-item {
153
180
  display: inline-block;
154
- margin-right: .5rem;
181
+ margin-right: 0.5rem;
155
182
  flex: 0 0 auto;
156
183
  }
157
184
 
158
185
  h2 {
159
186
  font-size: 1.3em;
160
- margin-bottom: .3em;
187
+ }
188
+
189
+ h2,
190
+ p {
191
+ margin-bottom: 0.8em;
192
+ }
193
+ & div.legend-item {
194
+ margin-bottom: 0.5em !important;
195
+
196
+ &:last-child {
197
+ margin: 0 !important;
198
+ }
161
199
  }
162
200
 
163
201
  .legend-item {
164
202
  cursor: pointer;
165
- transition: .2s all;
203
+ transition: 0.2s all;
166
204
 
167
205
  &.inactive {
168
- opacity: .5;
169
- transition: .2s all;
206
+ opacity: 0.5;
207
+ transition: 0.2s all;
170
208
  }
171
209
  }
172
210
  }
173
211
 
174
212
  .dynamic-legend-list {
175
-
176
213
  // overide traditional legend item that uses !important
177
214
  .legend-item {
178
215
  align-items: flex-end !important;
@@ -197,7 +234,7 @@
197
234
  .tooltip {
198
235
  background-color: #fff;
199
236
  border: rgba(0, 0, 0, 0.3) 1px solid !important;
200
- box-shadow: rgba(0, 0, 0, .1) 3px 3px 7px;
237
+ box-shadow: rgba(0, 0, 0, 0.1) 3px 3px 7px;
201
238
  line-height: 1.4em;
202
239
  font-size: 1em !important;
203
240
  border-radius: 4px !important;
@@ -213,8 +250,11 @@
213
250
  display: flex;
214
251
  align-items: flex-start;
215
252
  flex-wrap: wrap;
216
- margin-bottom: 1em;
217
253
 
254
+ &.bottom {
255
+ flex-wrap: nowrap;
256
+ flex-direction: column;
257
+ }
218
258
  &.legend-hidden > svg {
219
259
  width: 100% !important;
220
260
  }
@@ -283,27 +323,50 @@
283
323
  }
284
324
 
285
325
  .filters-section {
326
+ margin-left: 1rem;
327
+ margin-right: 1rem;
328
+
329
+ &__title {
330
+ margin: 15px 0;
331
+ }
332
+
333
+ &__wrapper {
334
+ margin-bottom: 40px;
335
+
336
+ hr {
337
+ margin-bottom: 20px;
338
+ }
339
+
340
+ label {
341
+ display: inherit;
342
+ margin-bottom: 5px;
343
+ font-weight: 600;
344
+ font-size: 16px;
345
+ }
346
+ }
347
+
286
348
  @include breakpoint(md) {
287
349
  display: flex;
288
350
  gap: 30px;
289
351
  }
290
352
 
291
353
  label:not(:empty) {
292
- margin-right: .4em;
354
+ margin-right: 0.4em;
293
355
  }
294
356
 
295
357
  select {
296
358
  font-size: 1em;
359
+ padding-right: 5px;
297
360
  }
298
361
 
299
362
  .single-filter {
300
- margin-bottom: .5em;
363
+ margin-bottom: 0.5em;
301
364
  }
302
365
  }
303
366
 
304
367
  @include breakpointClass(xs) {
305
368
  &.font-small {
306
- font-size: .8em;
369
+ font-size: 0.8em;
307
370
 
308
371
  .chart-container > svg {
309
372
  font-size: 12px;
@@ -311,7 +374,7 @@
311
374
  }
312
375
 
313
376
  &.font-medium {
314
- font-size: .9em;
377
+ font-size: 0.9em;
315
378
 
316
379
  .chart-container > svg {
317
380
  font-size: 14px;
@@ -328,7 +391,8 @@
328
391
  }
329
392
 
330
393
  @include breakpointClass(md) {
331
- .filters-section, .chart-container:not(.sparkline) {
394
+ .filters-section,
395
+ .chart-container:not(.sparkline) {
332
396
  margin-left: 1em;
333
397
  margin-right: 1em;
334
398
  }
@@ -336,6 +400,10 @@
336
400
  .chart-container {
337
401
  flex-wrap: nowrap;
338
402
 
403
+ .no-wrap {
404
+ flex-wrap: nowrap;
405
+ }
406
+
339
407
  .legend-container {
340
408
  width: 25%;
341
409
  margin-left: 1em;
@@ -346,6 +414,10 @@
346
414
  margin-right: 1em;
347
415
  order: 0;
348
416
  }
417
+ &.bottom {
418
+ width: 100%;
419
+ margin-left: 0;
420
+ }
349
421
  }
350
422
 
351
423
  > svg {
@@ -354,14 +426,14 @@
354
426
  order: 1;
355
427
 
356
428
  circle {
357
- filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, .5));
429
+ filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.5));
358
430
  transform-origin: 50% 50%;
359
431
  }
360
432
  }
361
433
  }
362
434
 
363
435
  &.font-small {
364
- font-size: .9em;
436
+ font-size: 0.9em;
365
437
 
366
438
  .chart-container > svg {
367
439
  font-size: 14px;
@@ -407,120 +479,125 @@
407
479
  outline: 2px solid rgb(0, 95, 204) !important;
408
480
  }
409
481
 
410
- // ANIMATIONS
411
- // Pie Chart Animations
412
- .animated-pie {
413
- transition: all .4s ease-in-out;
414
- opacity: 0;
482
+ // ANIMATIONS
483
+ // Pie Chart Animations
484
+ .animated-pie {
485
+ margin: auto !important;
486
+ transition: all 0.4s ease-in-out;
487
+ opacity: 0;
488
+ transform-origin: center;
489
+ transform: scale(0, 0);
490
+
491
+ &.animated {
492
+ opacity: 1;
415
493
  transform-origin: center;
416
- transform: scale(0, 0);
494
+ transform: scale(1, 1);
495
+ }
496
+
497
+ path,
498
+ text {
499
+ border: rgba(0, 0, 0, 0.3) 1px solid !important;
500
+ box-shadow: rgba(0, 0, 0, 0.1) 3px 3px 7px;
501
+ opacity: 1;
502
+ line-height: 1.4em;
503
+ font-size: 1em;
504
+ border-radius: 4px;
505
+ padding: 8px 12px;
506
+ }
507
+
508
+ .animated-pie-text {
509
+ opacity: 0;
510
+ transition: opacity 0.5s ease-in-out;
511
+ transition-delay: 0.4s;
417
512
 
418
513
  &.animated {
419
514
  opacity: 1;
420
- transform-origin: center;
421
- transform: scale(1, 1);
422
515
  }
516
+ }
517
+ }
423
518
 
424
- path,
425
- text {
426
- border: rgba(0,0,0,.3) 1px solid !important;
427
- box-shadow: rgba(0,0,0,.1) 3px 3px 7px;
519
+ // Line/Combo Chart Animations
520
+ .linear,
521
+ .Line,
522
+ .Combo {
523
+ &.animated path.animation {
524
+ opacity: 0;
525
+ }
526
+ &.animate {
527
+ path.animation {
428
528
  opacity: 1;
429
- line-height: 1.4em;
430
- font-size: 1em;
431
- border-radius: 4px;
432
- padding: 8px 12px;
529
+ stroke-dasharray: 2000;
530
+ stroke-dashoffset: 4000;
531
+ animation: dash 2s ease-in-out forwards;
433
532
  }
434
-
435
- .animated-pie-text {
436
- opacity: 0;
437
- transition: opacity .5s ease-in-out;
438
- transition-delay: .4s;
439
-
440
- &.animated {
441
- opacity: 1;
533
+ @keyframes dash {
534
+ to {
535
+ stroke-dashoffset: 0;
536
+ opacity: 0;
442
537
  }
443
538
  }
444
539
  }
540
+ }
445
541
 
446
- // Line/Combo Chart Animations
447
- .linear,
448
- .Line,
449
- .Combo {
450
- &.animated path {
451
- opacity: 0;
452
- }
453
- &.animate {
454
- path {
455
- opacity: 1;
456
- stroke-dasharray: 2000;
457
- stroke-dashoffset: 2000;
458
- animation: dash 2s ease-in-out forwards;
459
- }
460
- @keyframes dash {
461
- to {
462
- stroke-dashoffset: 0;
463
- }
464
- }
465
- }
542
+ // Bar/Combo Chart Animations
543
+ .linear,
544
+ .Bar,
545
+ .Combo {
546
+ .visx-group {
547
+ position: relative;
466
548
  }
467
549
 
468
- // Bar/Combo Chart Animations
469
- .linear,
470
- .Bar,
471
- .Combo {
472
- .visx-group {
473
- position: relative;
550
+ &.animated {
551
+ .vertical rect,
552
+ .vertical foreignObject {
553
+ opacity: 0;
554
+ animation: growBar 0.5s linear forwards;
555
+ animation-play-state: paused;
474
556
  }
475
557
 
476
- &.animated {
477
- .vertical rect ,
478
- .vertical foreignObject {
479
- opacity: 0;
480
- animation: growBar 0.5s linear forwards;
481
- animation-play-state: paused;
482
- }
558
+ .horizontal rect,
559
+ .horizontal foreignObject {
560
+ animation: growBarH 0.5s linear forwards;
561
+ animation-play-state: paused;
562
+ }
483
563
 
484
- .horizontal rect,
485
- .horizontal foreignObject {
486
- animation: growBarH 0.5s linear forwards;
487
- animation-play-state: paused;
564
+ &.animate {
565
+ rect,
566
+ foreignObject {
567
+ animation-play-state: running;
488
568
  }
569
+ }
489
570
 
490
- &.animate {
491
- rect,
492
- foreignObject {
493
- animation-play-state: running;
494
- }
495
- }
571
+ .group-1,
572
+ .group-2 {
573
+ transform-origin: center;
574
+ }
496
575
 
497
- .group-1,
498
- .group-2 {
499
- transform-origin: center;
500
- }
576
+ .visx-linepath .animation {
577
+ opacity: 0;
501
578
  }
502
579
  }
503
-
580
+ }
504
581
 
505
582
  @keyframes growBar {
506
583
  from {
507
584
  opacity: 1;
508
- transform: scale(1, 0) ;
585
+ transform: scale(1, 0);
509
586
  }
510
587
 
511
588
  to {
512
589
  opacity: 1;
513
- transform: scale(1) ;
590
+ transform: scale(1);
514
591
  }
515
592
  }
516
593
 
517
594
  @keyframes growBarH {
518
595
  from {
519
- transform: scale(0, 1) ;
596
+ transform: scale(0, 1);
520
597
  }
521
598
 
522
599
  to {
523
- transform: scale(1) ;
600
+ transform: scale(1);
524
601
  }
525
602
  }
526
603
  }
@@ -534,7 +611,6 @@
534
611
  }
535
612
 
536
613
  #paired-bar-legend {
537
-
538
614
  text-align: center;
539
615
 
540
616
  div {
@@ -551,8 +627,8 @@
551
627
  }
552
628
 
553
629
  .isEditor.type-sparkline .cdc-chart-inner-container {
554
- margin: 3em auto 0;
555
- max-width: 60%;
630
+ margin: 3em auto 0;
631
+ max-width: 60%;
556
632
  }
557
633
 
558
634
  .cdc-open-viz-module.type-chart.lg.type-sparkline .chart-container > svg {
@@ -565,9 +641,8 @@
565
641
  }
566
642
 
567
643
  .cdc-open-viz-module.type-chart.type-sparkline {
568
-
569
644
  .cove-component__content {
570
- background: #F2F2F2;
645
+ background: #f2f2f2;
571
646
  }
572
647
 
573
648
  .cove-component__content.component--hideBackgroundColor {
@@ -583,7 +658,7 @@
583
658
  }
584
659
 
585
660
  .cove-component__content:not(.no-borders) {
586
- border: 1px solid $lightGray
661
+ border: 1px solid $lightGray;
587
662
  }
588
663
 
589
664
  .cove-component__header ~ .cove-component__content:not(.no-borders) {
@@ -601,7 +676,6 @@
601
676
  .subtext {
602
677
  margin-bottom: 15px;
603
678
  }
604
-
605
679
  }
606
680
 
607
681
  .cdc-open-viz-module .cove-component__content.sparkline {
@@ -613,10 +687,10 @@
613
687
  border-bottom-right-radius: 3px;
614
688
 
615
689
  .visx-axis-tick:first-of-type {
616
- transform: translate(20px, 0)
690
+ transform: translate(20px, 0);
617
691
  }
618
692
 
619
693
  .visx-axis-tick:last-of-type {
620
- transform: translate(-20px, 0)
694
+ transform: translate(-20px, 0);
621
695
  }
622
696
  }
@@ -1 +1 @@
1
- $editorWidth: 350px;
1
+ $editorWidth: 350px;
@@ -1,22 +0,0 @@
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
- ]