@cdc/chart 4.22.10 → 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 (72) hide show
  1. package/README.md +5 -5
  2. package/dist/cdcchart.js +4 -4
  3. package/examples/age-adjusted-rates.json +1486 -1218
  4. package/examples/case-rate-example-config.json +1 -1
  5. package/examples/covid-confidence-example-config.json +33 -33
  6. package/examples/covid-example-config.json +34 -34
  7. package/examples/covid-example-data-confidence.json +30 -30
  8. package/examples/covid-example-data.json +20 -20
  9. package/examples/cutoff-example-config.json +36 -36
  10. package/examples/cutoff-example-data.json +36 -36
  11. package/examples/date-exclusions-config.json +1 -1
  12. package/examples/dynamic-legends.json +124 -124
  13. package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart-with-numbers-on-bar.json +191 -197
  14. package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart.json +230 -240
  15. package/examples/gallery/bar-chart-horizontal/horizontal-stacked.json +239 -247
  16. package/examples/gallery/bar-chart-vertical/combo-line-chart.json +136 -136
  17. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-categorical.json +79 -79
  18. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +80 -80
  19. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-with-confidence.json +67 -67
  20. package/examples/gallery/bar-chart-vertical/vertical-bar-chart.json +110 -110
  21. package/examples/gallery/lollipop/lollipop-style-horizontal.json +215 -219
  22. package/examples/gallery/paired-bar/paired-bar-chart.json +195 -195
  23. package/examples/horizontal-chart.json +35 -35
  24. package/examples/horizontal-stacked-bar-chart.json +34 -34
  25. package/examples/line-chart.json +75 -75
  26. package/examples/paired-bar-data.json +16 -14
  27. package/examples/paired-bar-example.json +48 -48
  28. package/examples/paired-bar-formatted.json +36 -36
  29. package/examples/planet-chart-horizontal-example-config.json +33 -33
  30. package/examples/planet-combo-example-config.json +34 -31
  31. package/examples/planet-example-config.json +35 -33
  32. package/examples/planet-example-data.json +56 -56
  33. package/examples/planet-pie-example-config.json +28 -28
  34. package/examples/private/filters.json +170 -0
  35. package/examples/private/line-test-data.json +21 -21
  36. package/examples/private/line-test-two.json +209 -215
  37. package/examples/private/line-test.json +101 -101
  38. package/examples/private/new.json +48800 -0
  39. package/examples/private/shawn.json +1105 -1295
  40. package/examples/private/test.json +10123 -10123
  41. package/examples/private/yaxis-test.json +4 -3
  42. package/examples/private/yaxis.json +26 -26
  43. package/examples/stacked-vertical-bar-example.json +1 -1
  44. package/examples/temp-example-config.json +61 -54
  45. package/examples/temp-example-data.json +1 -1
  46. package/package.json +2 -2
  47. package/src/CdcChart.tsx +339 -380
  48. package/src/components/BarChart.tsx +425 -469
  49. package/src/components/DataTable.tsx +164 -195
  50. package/src/components/EditorPanel.js +1009 -710
  51. package/src/components/Legend.js +279 -329
  52. package/src/components/LineChart.tsx +90 -79
  53. package/src/components/LinearChart.tsx +376 -434
  54. package/src/components/PairedBarChart.tsx +197 -213
  55. package/src/components/PieChart.tsx +95 -151
  56. package/src/components/SparkLine.js +179 -201
  57. package/src/components/useIntersectionObserver.tsx +17 -20
  58. package/src/context.tsx +3 -3
  59. package/src/data/initial-state.js +37 -16
  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 +62 -78
  65. package/src/hooks/useRightAxis.js +25 -0
  66. package/src/hooks/useTopAxis.js +6 -0
  67. package/src/index.html +45 -45
  68. package/src/index.tsx +13 -16
  69. package/src/scss/DataTable.scss +5 -4
  70. package/src/scss/editor-panel.scss +71 -69
  71. package/src/scss/main.scss +157 -114
  72. package/src/scss/variables.scss +1 -1
@@ -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,37 @@
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,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
+ }
161
198
  }
162
199
 
163
200
  .legend-item {
164
201
  cursor: pointer;
165
- transition: .2s all;
202
+ transition: 0.2s all;
166
203
 
167
204
  &.inactive {
168
- opacity: .5;
169
- transition: .2s all;
205
+ opacity: 0.5;
206
+ transition: 0.2s all;
170
207
  }
171
208
  }
172
209
  }
173
210
 
174
211
  .dynamic-legend-list {
175
-
176
212
  // overide traditional legend item that uses !important
177
213
  .legend-item {
178
214
  align-items: flex-end !important;
@@ -197,7 +233,7 @@
197
233
  .tooltip {
198
234
  background-color: #fff;
199
235
  border: rgba(0, 0, 0, 0.3) 1px solid !important;
200
- box-shadow: rgba(0, 0, 0, .1) 3px 3px 7px;
236
+ box-shadow: rgba(0, 0, 0, 0.1) 3px 3px 7px;
201
237
  line-height: 1.4em;
202
238
  font-size: 1em !important;
203
239
  border-radius: 4px !important;
@@ -215,6 +251,10 @@
215
251
  flex-wrap: wrap;
216
252
  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
  }
@@ -289,7 +329,7 @@
289
329
  }
290
330
 
291
331
  label:not(:empty) {
292
- margin-right: .4em;
332
+ margin-right: 0.4em;
293
333
  }
294
334
 
295
335
  select {
@@ -297,13 +337,13 @@
297
337
  }
298
338
 
299
339
  .single-filter {
300
- margin-bottom: .5em;
340
+ margin-bottom: 0.5em;
301
341
  }
302
342
  }
303
343
 
304
344
  @include breakpointClass(xs) {
305
345
  &.font-small {
306
- font-size: .8em;
346
+ font-size: 0.8em;
307
347
 
308
348
  .chart-container > svg {
309
349
  font-size: 12px;
@@ -311,7 +351,7 @@
311
351
  }
312
352
 
313
353
  &.font-medium {
314
- font-size: .9em;
354
+ font-size: 0.9em;
315
355
 
316
356
  .chart-container > svg {
317
357
  font-size: 14px;
@@ -328,7 +368,8 @@
328
368
  }
329
369
 
330
370
  @include breakpointClass(md) {
331
- .filters-section, .chart-container:not(.sparkline) {
371
+ .filters-section,
372
+ .chart-container:not(.sparkline) {
332
373
  margin-left: 1em;
333
374
  margin-right: 1em;
334
375
  }
@@ -346,6 +387,10 @@
346
387
  margin-right: 1em;
347
388
  order: 0;
348
389
  }
390
+ &.bottom{
391
+ width: 100%;
392
+ margin-left: 0;
393
+ }
349
394
  }
350
395
 
351
396
  > svg {
@@ -354,14 +399,14 @@
354
399
  order: 1;
355
400
 
356
401
  circle {
357
- filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, .5));
402
+ filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.5));
358
403
  transform-origin: 50% 50%;
359
404
  }
360
405
  }
361
406
  }
362
407
 
363
408
  &.font-small {
364
- font-size: .9em;
409
+ font-size: 0.9em;
365
410
 
366
411
  .chart-container > svg {
367
412
  font-size: 14px;
@@ -377,6 +422,8 @@
377
422
  }
378
423
  }
379
424
 
425
+
426
+
380
427
  @include breakpointClass(lg) {
381
428
  &.font-small {
382
429
  font-size: 1em;
@@ -407,120 +454,119 @@
407
454
  outline: 2px solid rgb(0, 95, 204) !important;
408
455
  }
409
456
 
410
- // ANIMATIONS
411
- // Pie Chart Animations
412
- .animated-pie {
413
- transition: all .4s ease-in-out;
414
- opacity: 0;
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;
415
467
  transform-origin: center;
416
- transform: scale(0, 0);
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;
417
486
 
418
487
  &.animated {
419
488
  opacity: 1;
420
- transform-origin: center;
421
- transform: scale(1, 1);
422
489
  }
490
+ }
491
+ }
423
492
 
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;
493
+ // Line/Combo Chart Animations
494
+ .linear,
495
+ .Line,
496
+ .Combo {
497
+ &.animated path {
498
+ opacity: 0;
499
+ }
500
+ &.animate {
501
+ path {
428
502
  opacity: 1;
429
- line-height: 1.4em;
430
- font-size: 1em;
431
- border-radius: 4px;
432
- padding: 8px 12px;
503
+ stroke-dasharray: 2000;
504
+ stroke-dashoffset: 2000;
505
+ animation: dash 2s ease-in-out forwards;
433
506
  }
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;
507
+ @keyframes dash {
508
+ to {
509
+ stroke-dashoffset: 0;
442
510
  }
443
511
  }
444
512
  }
513
+ }
445
514
 
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
- }
515
+ // Bar/Combo Chart Animations
516
+ .linear,
517
+ .Bar,
518
+ .Combo {
519
+ .visx-group {
520
+ position: relative;
466
521
  }
467
522
 
468
- // Bar/Combo Chart Animations
469
- .linear,
470
- .Bar,
471
- .Combo {
472
- .visx-group {
473
- position: relative;
523
+ &.animated {
524
+ .vertical rect,
525
+ .vertical foreignObject {
526
+ opacity: 0;
527
+ animation: growBar 0.5s linear forwards;
528
+ animation-play-state: paused;
474
529
  }
475
530
 
476
- &.animated {
477
- .vertical rect ,
478
- .vertical foreignObject {
479
- opacity: 0;
480
- animation: growBar 0.5s linear forwards;
481
- animation-play-state: paused;
482
- }
483
-
484
- .horizontal rect,
485
- .horizontal foreignObject {
486
- animation: growBarH 0.5s linear forwards;
487
- animation-play-state: paused;
488
- }
531
+ .horizontal rect,
532
+ .horizontal foreignObject {
533
+ animation: growBarH 0.5s linear forwards;
534
+ animation-play-state: paused;
535
+ }
489
536
 
490
- &.animate {
491
- rect,
492
- foreignObject {
493
- animation-play-state: running;
494
- }
537
+ &.animate {
538
+ rect,
539
+ foreignObject {
540
+ animation-play-state: running;
495
541
  }
542
+ }
496
543
 
497
- .group-1,
498
- .group-2 {
499
- transform-origin: center;
500
- }
544
+ .group-1,
545
+ .group-2 {
546
+ transform-origin: center;
501
547
  }
502
548
  }
503
-
549
+ }
504
550
 
505
551
  @keyframes growBar {
506
552
  from {
507
553
  opacity: 1;
508
- transform: scale(1, 0) ;
554
+ transform: scale(1, 0);
509
555
  }
510
556
 
511
557
  to {
512
558
  opacity: 1;
513
- transform: scale(1) ;
559
+ transform: scale(1);
514
560
  }
515
561
  }
516
562
 
517
563
  @keyframes growBarH {
518
564
  from {
519
- transform: scale(0, 1) ;
565
+ transform: scale(0, 1);
520
566
  }
521
567
 
522
568
  to {
523
- transform: scale(1) ;
569
+ transform: scale(1);
524
570
  }
525
571
  }
526
572
  }
@@ -534,7 +580,6 @@
534
580
  }
535
581
 
536
582
  #paired-bar-legend {
537
-
538
583
  text-align: center;
539
584
 
540
585
  div {
@@ -551,8 +596,8 @@
551
596
  }
552
597
 
553
598
  .isEditor.type-sparkline .cdc-chart-inner-container {
554
- margin: 3em auto 0;
555
- max-width: 60%;
599
+ margin: 3em auto 0;
600
+ max-width: 60%;
556
601
  }
557
602
 
558
603
  .cdc-open-viz-module.type-chart.lg.type-sparkline .chart-container > svg {
@@ -565,9 +610,8 @@
565
610
  }
566
611
 
567
612
  .cdc-open-viz-module.type-chart.type-sparkline {
568
-
569
613
  .cove-component__content {
570
- background: #F2F2F2;
614
+ background: #f2f2f2;
571
615
  }
572
616
 
573
617
  .cove-component__content.component--hideBackgroundColor {
@@ -583,7 +627,7 @@
583
627
  }
584
628
 
585
629
  .cove-component__content:not(.no-borders) {
586
- border: 1px solid $lightGray
630
+ border: 1px solid $lightGray;
587
631
  }
588
632
 
589
633
  .cove-component__header ~ .cove-component__content:not(.no-borders) {
@@ -601,7 +645,6 @@
601
645
  .subtext {
602
646
  margin-bottom: 15px;
603
647
  }
604
-
605
648
  }
606
649
 
607
650
  .cdc-open-viz-module .cove-component__content.sparkline {
@@ -613,10 +656,10 @@
613
656
  border-bottom-right-radius: 3px;
614
657
 
615
658
  .visx-axis-tick:first-of-type {
616
- transform: translate(20px, 0)
659
+ transform: translate(20px, 0);
617
660
  }
618
661
 
619
662
  .visx-axis-tick:last-of-type {
620
- transform: translate(-20px, 0)
663
+ transform: translate(-20px, 0);
621
664
  }
622
665
  }
@@ -1 +1 @@
1
- $editorWidth: 350px;
1
+ $editorWidth: 350px;