@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,693 @@
1
+ //TODO: Remove after COVE refactor
2
+ .cove {
3
+ @import "@cdc/core/styles/v2/layout/tooltip.scss";
4
+ }
5
+
6
+ .editor-panel {
7
+ display: flex;
8
+ flex-direction: column;
9
+ position: fixed;
10
+ top: 0;
11
+ bottom: 0;
12
+ left: 0;
13
+ width: $editorWidth;
14
+ background: #fff;
15
+ z-index: 8;
16
+
17
+ &.hidden {
18
+ display: none;
19
+ }
20
+
21
+ .two-col-inputs {
22
+ display: flex;
23
+ margin-top: 1em;
24
+ justify-content: space-between;
25
+
26
+ > label {
27
+ width: 48%;
28
+ margin-top: 0 !important
29
+ }
30
+ }
31
+
32
+ .helper-tooltip {
33
+ padding: 5px;
34
+ max-width: 300px;
35
+ }
36
+
37
+ .helper {
38
+ position: relative;
39
+ opacity: .7;
40
+ cursor: pointer;
41
+ width: 17px;
42
+ height: 17px;
43
+ align-self: center;
44
+ margin-left: .3rem;
45
+ margin-top: -0.3rem;
46
+ border: none !important;
47
+ box-shadow: none !important;
48
+
49
+ svg {
50
+ position: absolute;
51
+ top: 0;
52
+ left: 0;
53
+ width: 100%;
54
+ height: 100%;
55
+ }
56
+ }
57
+
58
+ .divider-heading {
59
+ display: block;
60
+ font-size: 1em;
61
+ margin-top: 1em;
62
+ }
63
+
64
+ .series-list {
65
+ list-style: none;
66
+ border: $lightGray 1px solid;
67
+
68
+ &:empty {
69
+ border: none !important
70
+ }
71
+
72
+ li {
73
+ padding: .3em .5em;
74
+ display: flex;
75
+ align-items: center;
76
+ justify-content: space-between;
77
+ font-size: .9em;
78
+
79
+ &:hover {
80
+ background-color: $lightestGray;
81
+ }
82
+
83
+ .series-list__name {
84
+ position: relative;
85
+ user-select: none;
86
+
87
+ &.series-list__name--truncate {
88
+ &[data-title] {
89
+ $bgColor: rgb(34 34 34 / 90%);
90
+ position: relative;
91
+
92
+ &::before,
93
+ &::after {
94
+ opacity: 0;
95
+ pointer-events: none;
96
+ position: absolute;
97
+ transition: opacity 250ms cubic-bezier(0.16, 1, 0.3, 1);
98
+ z-index: 1;
99
+ }
100
+
101
+ &::before {
102
+ content: attr(data-title);
103
+ bottom: -39px;
104
+ padding: 6px 10px;
105
+ background: $bgColor;
106
+ color: #fff;
107
+ font-size: 14px;
108
+ white-space: nowrap;
109
+ border-radius: 4px;
110
+ }
111
+
112
+ &::after {
113
+ content: '';
114
+ bottom: -8px;
115
+ left: 10px;
116
+ border: 7px solid transparent;
117
+ border-bottom: 6px solid $bgColor;
118
+ }
119
+
120
+ &:hover {
121
+ &::before,
122
+ &::after {
123
+ opacity: 1;
124
+ }
125
+ }
126
+ }
127
+
128
+ .series-list__name-text {
129
+ cursor: pointer;
130
+ }
131
+ }
132
+ }
133
+
134
+ .series-list__dropdown {
135
+ font-size: .8em;
136
+ }
137
+
138
+ .series-list__remove {
139
+ padding: 0 4px;
140
+ font-size: 1.125rem;
141
+ color: #f00;
142
+ cursor: pointer;
143
+ }
144
+
145
+ + li {
146
+ border-top: $lightGray 1px solid;
147
+ }
148
+ }
149
+ }
150
+
151
+ .series-list__name-text {
152
+ max-width: 150px;
153
+ white-space: nowrap;
154
+ text-overflow: ellipsis;
155
+ overflow: hidden;
156
+ }
157
+
158
+ .accordion__heading {
159
+ background: $lightestGray;
160
+ }
161
+
162
+ .accordion__item {
163
+ select {
164
+ text-transform: capitalize;
165
+ outline: none;
166
+ }
167
+
168
+ .number-narrow {
169
+ min-width: auto;
170
+ width: 75px
171
+ }
172
+ }
173
+
174
+ .form-container {
175
+ border-right: $lightGray 1px solid;
176
+ flex-grow: 1;
177
+ }
178
+
179
+ .guidance-link {
180
+ margin: 2em 1em 0;
181
+ padding: .75em 1em;
182
+
183
+ svg {
184
+ width: 60px;
185
+ color: $blue;
186
+ margin-right: 1rem;
187
+ height: 60px; // IE11
188
+ path {
189
+ fill: currentColor;
190
+ }
191
+ }
192
+ }
193
+
194
+ .warning {
195
+ color: #D8000C;
196
+ background-color: #FFD2D2;
197
+ padding: .75em 1em;
198
+ margin: 1em 0;
199
+ font-size: .8em;
200
+ border: #D8000C 1px solid;
201
+ border-radius: .4em;
202
+
203
+ strong {
204
+ font-weight: 600;
205
+ display: block;
206
+ }
207
+ }
208
+
209
+ .accordion__button {
210
+ cursor: pointer;
211
+ font-size: 1em;
212
+ padding: .3em 1em;
213
+ width: 100%;
214
+ text-align: left;
215
+ position: relative;
216
+ border-bottom: 1px solid rgba(0, 0, 0, 0.2);
217
+
218
+ &::before {
219
+ display: inline-block;
220
+ content: '';
221
+ height: 7px;
222
+ width: 7px;
223
+ margin-right: 1em;
224
+ border-bottom: 2px solid currentColor;
225
+ border-right: 2px solid currentColor;
226
+ right: 0;
227
+ position: absolute;
228
+ top: 50%;
229
+ transform: rotate(-45deg) translateY(-50%);
230
+ transition: .1s all;
231
+ }
232
+
233
+ &[aria-expanded='true']::before {
234
+ transform: rotate(45deg) translateY(-50%);
235
+ transform-origin: right;
236
+ margin-right: 1.3em;
237
+ transition: .1s all;
238
+ }
239
+ }
240
+
241
+ .accordion__panel {
242
+ border-bottom: 1px solid rgba(0, 0, 0, 0.2);
243
+ padding: 1em 1.25em 2em;
244
+ animation: fadein 0.2s ease-in;
245
+
246
+ &:first-child {
247
+ margin-top: 0;
248
+ }
249
+
250
+ h5 {
251
+ font-size: .8em;
252
+ }
253
+ }
254
+
255
+ .advanced {
256
+ padding: 0 1em 1em;
257
+ text-align: left;
258
+
259
+ p {
260
+ font-size: .8rem;
261
+ }
262
+
263
+ .advanced-toggle-link {
264
+ padding-top: 1em;
265
+ display: block;
266
+ text-align: left;
267
+ cursor: pointer;
268
+ color: rgba(0, 0, 0, .5);
269
+ text-decoration: underline;
270
+
271
+ span {
272
+ text-decoration: none;
273
+ display: inline-block;
274
+ font-family: monospace;
275
+ padding-right: 5px;
276
+ }
277
+
278
+ &:hover {
279
+ color: rgba(0, 0, 0, .7);
280
+ }
281
+ }
282
+
283
+ textarea {
284
+ height: 400px;
285
+ width: 100%;
286
+ font-size: .9em;
287
+ padding: .5em;
288
+ font-family: monospace;
289
+ box-sizing: border-box
290
+ }
291
+ }
292
+
293
+ @keyframes fadein {
294
+ 0% {
295
+ opacity: 0;
296
+ }
297
+
298
+ 100% {
299
+ opacity: 1;
300
+ }
301
+ }
302
+
303
+ .heading-2 {
304
+ background: #565656;
305
+ color: #fff;
306
+ font-size: 1.1em;
307
+ padding: .6em 1em;
308
+ position: relative;
309
+ border-bottom: #565656 3px solid;
310
+ z-index: 3;
311
+ }
312
+
313
+ label {
314
+ text-transform: uppercase;
315
+ display: block;
316
+ font-size: .8em;
317
+ font-weight: 600;
318
+ user-select: none;
319
+
320
+ &:not(:first-child) {
321
+ margin-top: 1em;
322
+ }
323
+
324
+ span.edit-label {
325
+ margin-bottom: .3em;
326
+ display: block;
327
+ }
328
+
329
+ span.column-heading {
330
+ font-size: 1em;
331
+ }
332
+
333
+ &.checkbox {
334
+ display: flex;
335
+
336
+ input {
337
+ margin-left: 0;
338
+ width: inherit;
339
+ display: inline;
340
+ }
341
+ }
342
+ }
343
+
344
+ input[type="text"], input[role="combobox"], input[type="number"], textarea {
345
+ min-width: 100%;
346
+ max-width: 100%; // Doing this prevents width of textarea from being changed
347
+ }
348
+
349
+ textarea {
350
+ min-height: 140px;
351
+ }
352
+
353
+ .header .color-palette li {
354
+ width: 21px;
355
+ height: 21px;
356
+ border-radius: 40px;
357
+ margin-right: 2.8px;
358
+ }
359
+
360
+ .color-palette {
361
+ display: flex;
362
+ max-width: 100%;
363
+ padding: 0;
364
+ margin: .5em 0 0 0;
365
+ list-style: none;
366
+ flex-wrap: wrap;
367
+
368
+ li {
369
+ width: 45px;
370
+ height: 23px;
371
+ margin-right: 4px;
372
+ margin-bottom: 10px;
373
+ display: flex;
374
+ border-radius: 5px;
375
+ overflow: hidden;
376
+ cursor: pointer;
377
+ position: relative;
378
+
379
+ .click-target {
380
+ position: absolute;
381
+ top: 0;
382
+ left: 0;
383
+ right: 0;
384
+ bottom: 0;
385
+ }
386
+
387
+ &.selected {
388
+ border: rgba(0, 0, 0, .8) 2px solid;
389
+ }
390
+
391
+ span {
392
+ width: 33.3%;
393
+ }
394
+ }
395
+ }
396
+
397
+ fieldset {
398
+ display: block;
399
+ }
400
+
401
+ .primary-fieldset {
402
+ padding: 0;
403
+ margin: 0;
404
+ border: 0;
405
+ }
406
+
407
+ ul.column-edit {
408
+ list-style: none;
409
+
410
+ li {
411
+ margin-top: 1em;
412
+ }
413
+
414
+ .three-col {
415
+ display: flex;
416
+ justify-content: space-between;
417
+
418
+ > label {
419
+ margin-top: 0;
420
+ width: 30%;
421
+ display: inline-block;
422
+
423
+ input[type="text"], input[type="number"] {
424
+ width: 50px;
425
+ }
426
+ }
427
+ }
428
+ }
429
+
430
+ .emove-column {
431
+ float: right;
432
+ text-transform: uppercase;
433
+ color: #C32B2B;
434
+ font-size: .7em;
435
+ line-height: 1.6em;
436
+ border-radius: 5px;
437
+ margin: 0 auto;
438
+ transition: .1s all;
439
+ border: 0;
440
+ text-decoration: underline;
441
+ outline: 0;
442
+ cursor: pointer;
443
+ font-weight: bold;
444
+ }
445
+
446
+ .edit-block {
447
+ padding-left: 1em;
448
+ border-left: rgba(0, 0, 0, 0.2) 4px solid;
449
+ transition: .2s all;
450
+
451
+ &:not(:first-child) {
452
+ margin-top: 2em;
453
+ }
454
+
455
+ input[type="text"], input[type="number"] {
456
+ font-size: 1em;
457
+ }
458
+
459
+ label {
460
+ margin-top: 0;
461
+ }
462
+
463
+ label + label {
464
+ margin-top: 1em;
465
+ }
466
+
467
+ &:hover {
468
+ border-left: rgba(0, 0, 0, 0.7) 4px solid;
469
+ transition: .2s all;
470
+ }
471
+ }
472
+
473
+ span.subtext {
474
+ display: block;
475
+ color: rgba(0, 0, 0, .5);
476
+ text-transform: none;
477
+ font-weight: normal;
478
+ }
479
+
480
+ .btn {
481
+ margin-top: 1em;
482
+ }
483
+
484
+ .sort-list {
485
+ list-style: none;
486
+
487
+ > li {
488
+ margin-right: .3em;
489
+ margin-bottom: .3em;
490
+ }
491
+ }
492
+
493
+ .sort-list li > div {
494
+ display: block;
495
+ box-sizing: border-box;
496
+ border: 1px solid #D1D1D1;
497
+ border-radius: 2px;
498
+ background: #F1F1F1;
499
+ padding: .4em .6em;
500
+ font-size: .8em;
501
+ margin-bottom: .3em;
502
+ cursor: move;
503
+ }
504
+
505
+ .info {
506
+ font-size: .8em;
507
+ line-height: 1.4em;
508
+ font-style: italic;
509
+ padding-top: 10px;
510
+ }
511
+
512
+ .react-tags__search {
513
+ width: 100%;
514
+ }
515
+
516
+ .react-tags {
517
+ position: relative;
518
+
519
+ input.react-tags__search-input {
520
+ font-size: .8rem;
521
+ }
522
+
523
+ /* clicking anywhere will focus the input */
524
+ cursor: text;
525
+
526
+ span {
527
+ display: inline
528
+ }
529
+ }
530
+
531
+ .react-tags.is-focused {
532
+ border-color: rgba(0, 0, 0, 0.7);
533
+ }
534
+
535
+ .react-tags__selected {
536
+ display: inline;
537
+ }
538
+
539
+ .react-tags__selected-tag {
540
+ display: inline-block;
541
+ box-sizing: border-box;
542
+ border: 1px solid #D1D1D1;
543
+ border-radius: 2px;
544
+ background: #F1F1F1;
545
+ padding: .4em .6em;
546
+ font-size: .8em;
547
+ margin-right: .3em;
548
+ margin-bottom: .3em;
549
+ }
550
+
551
+ .react-tags__selected-tag:after {
552
+ content: '\2715';
553
+ color: #AAA;
554
+ margin-left: 8px;
555
+ }
556
+
557
+ .react-tags__selected-tag:hover,
558
+ .react-tags__selected-tag:focus {
559
+ border-color: #B1B1B1;
560
+ }
561
+
562
+ .react-tags__search {
563
+ display: inline-block;
564
+
565
+ /* prevent autoresize overflowing the container */
566
+ max-width: 100%;
567
+ }
568
+
569
+ @media screen and (min-width: 30em) {
570
+
571
+ .react-tags__search {
572
+ /* this will become the offsetParent for suggestions */
573
+ position: relative;
574
+ }
575
+
576
+ }
577
+
578
+ .react-tags__search input {
579
+ /* prevent autoresize overflowing the container */
580
+ max-width: 100%;
581
+
582
+ /* emove styles and layout from this element */
583
+ margin: 0;
584
+ outline: none;
585
+ padding: .5em .3em;
586
+
587
+ /* match the font styles */
588
+ font-size: inherit;
589
+ line-height: inherit;
590
+ }
591
+
592
+ .react-tags__search input::-ms-clear {
593
+ display: none;
594
+ }
595
+
596
+ .react-tags__suggestions {
597
+ position: absolute;
598
+ top: 100%;
599
+ left: 0;
600
+ width: 100%;
601
+ }
602
+
603
+ @media screen and (min-width: 30em) {
604
+ .react-tags__suggestions {
605
+ width: 240px;
606
+ }
607
+ }
608
+
609
+ .react-tags__suggestions ul {
610
+ margin: 4px -1px;
611
+ padding: 0;
612
+ list-style: none;
613
+ background: white;
614
+ border: 1px solid #D1D1D1;
615
+ border-radius: 2px;
616
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
617
+ }
618
+
619
+ .react-tags__suggestions li {
620
+ border-bottom: 1px solid #ddd;
621
+ padding: 6px 8px;
622
+ }
623
+
624
+ .react-tags__suggestions li mark {
625
+ text-decoration: underline;
626
+ background: none;
627
+ font-weight: 600;
628
+ }
629
+
630
+ .react-tags__suggestions li:hover {
631
+ cursor: pointer;
632
+ background: #eee;
633
+ }
634
+
635
+ .react-tags__suggestions li.is-active {
636
+ background: #b7cfe0;
637
+ }
638
+
639
+ .react-tags__suggestions li.is-disabled {
640
+ opacity: 0.5;
641
+ cursor: auto;
642
+ }
643
+
644
+ [type="radio"] {
645
+ border: 1px solid #8c8f94;
646
+ border-radius: 50%;
647
+ margin-right: 5px;
648
+ }
649
+ }
650
+
651
+ .editor-toggle {
652
+ background: #F2F2F2;
653
+ border-radius: 60px;
654
+ color: #000;
655
+ font-size: 1em;
656
+ border: 0;
657
+ position: fixed;
658
+ z-index: 100;
659
+ transition: .1s background;
660
+ cursor: pointer;
661
+ width: 25px;
662
+ height: 25px;
663
+ left: 307px;
664
+ top: 10px;
665
+ box-shadow: rgba(0, 0, 0, .5) 0 1px 2px;
666
+
667
+ &:before {
668
+ top: 43%;
669
+ left: 50%;
670
+ transform: translate(-50%, -50%);
671
+ position: absolute;
672
+ content: "\00ab";
673
+ }
674
+
675
+ &.collapsed {
676
+ left: 1em;
677
+ margin-left: 0;
678
+
679
+ &:before {
680
+ content: "\00bb";
681
+ }
682
+ }
683
+
684
+ &:hover {
685
+ background: rgba(255, 255, 255, 1)
686
+ }
687
+ }
688
+
689
+ @include breakpointClass(md) {
690
+ .editor-panel:not(.hidden) + .cdc-chart-inner-container {
691
+ padding-left: $editorWidth;
692
+ }
693
+ }