@cdc/chart 4.23.3 → 4.23.5

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 (98) hide show
  1. package/dist/cdcchart.js +52543 -50830
  2. package/examples/feature/__data__/area-chart.json +56 -0
  3. package/examples/{planet-example-data.json → feature/__data__/planet-example-data.json} +3 -8
  4. package/examples/feature/__data__/planet-logaritmic-data.json +56 -0
  5. package/examples/feature/area/area-chart-category.json +240 -0
  6. package/examples/{area-chart.json → feature/area/area-chart-date.json} +70 -13
  7. package/examples/feature/bar/example-bar-chart.json +558 -0
  8. package/examples/{horizontal-chart-max-increase.json → feature/bar/horizontal-chart-max-increase.json} +10 -4
  9. package/examples/{horizontal-chart.json → feature/bar/horizontal-chart.json} +10 -4
  10. package/examples/{horizontal-stacked-bar-chart.json → feature/bar/horizontal-stacked-bar-chart.json} +7 -3
  11. package/examples/{planet-chart-horizontal-example-config.json → feature/bar/planet-chart-horizontal-example-config.json} +8 -3
  12. package/examples/feature/bar/planet-chart-logaritmic-config.json +170 -0
  13. package/examples/{planet-example-config.json → feature/bar/planet-example-config.json} +2 -2
  14. package/examples/{box-plot.json → feature/boxplot/boxplot.json} +7 -7
  15. package/examples/feature/boxplot/testing.csv +38 -0
  16. package/examples/feature/boxplot/valid-boxplot.csv +17 -0
  17. package/examples/feature/combo/combochart-categories_are_numbers .json +18 -0
  18. package/examples/{planet-combo-example-config.json → feature/combo/planet-combo-example-config.json} +1 -1
  19. package/examples/{planet-deviation-config.json → feature/deviation/planet-deviation-config.json} +2 -2
  20. package/examples/{planet-deviation-data.json → feature/deviation/planet-deviation-data.json} +9 -9
  21. package/examples/feature/filters/filter-testing.json +212 -0
  22. package/examples/feature/forecasting/case_date_example.csv +130 -0
  23. package/examples/feature/forecasting/effective_reproduction.json +202 -0
  24. package/examples/feature/forecasting/r_data.csv +130 -0
  25. package/examples/feature/forecasting/random_data.csv +366 -0
  26. package/examples/feature/line/line-chart.json +124 -0
  27. package/examples/{paired-bar-example.json → feature/paired-bar/paired-bar-example.json} +10 -4
  28. package/examples/{planet-pie-example-config.json → feature/pie/planet-pie-example-config.json} +2 -2
  29. package/examples/{scatterplot.json → feature/scatterplot/scatterplot.json} +1 -1
  30. package/examples/feature/test-highlight/test-highlight-2.json +789 -0
  31. package/examples/feature/test-highlight/test-highlight-vertical.json +561 -0
  32. package/examples/feature/test-highlight/test-highlight.json +100 -0
  33. package/examples/{case-rate-example-config.json → feature/tests-case-rate/case-rate-example-config.json} +2 -2
  34. package/examples/{covid-confidence-example-config.json → feature/tests-covid/covid-confidence-example-config.json} +8 -3
  35. package/examples/{covid-example-config.json → feature/tests-covid/covid-example-config.json} +7 -3
  36. package/examples/{cutoff-example-config.json → feature/tests-cutoff/cutoff-example-config.json} +7 -3
  37. package/examples/{date-exclusions-config.json → feature/tests-date-exclusions/date-exclusions-config.json} +2 -2
  38. package/examples/{example-bar-chart-nonnumeric.json → feature/tests-non-numerics/example-bar-chart-nonnumeric.json} +1 -1
  39. package/examples/{planet-pie-example-config-nonnumeric.json → feature/tests-non-numerics/planet-pie-example-config-nonnumeric.json} +2 -2
  40. package/examples/{sparkline-chart-nonnumeric.json → feature/tests-non-numerics/sparkline-chart-nonnumeric.json} +1 -1
  41. package/examples/{stacked-vertical-bar-example-nonnumerics.json → feature/tests-non-numerics/stacked-vertical-bar-example-nonnumerics.json} +1 -2
  42. package/examples/gallery/bar-chart-horizontal/horizontal-highlight.json +345 -0
  43. package/examples/gallery/bar-chart-vertical/combo-line-chart.json +145 -7
  44. package/examples/gallery/paired-bar/paired-bar-chart.json +1 -0
  45. package/index.html +73 -49
  46. package/package.json +2 -2
  47. package/src/CdcChart.jsx +405 -40
  48. package/src/components/AreaChart.jsx +122 -80
  49. package/src/components/BarChart.jsx +126 -49
  50. package/src/components/BoxPlot.jsx +28 -20
  51. package/src/components/DataTable.jsx +7 -6
  52. package/src/components/DeviationBar.jsx +34 -34
  53. package/src/components/EditorPanel.jsx +1332 -352
  54. package/src/components/Legend.jsx +40 -4
  55. package/src/components/LineChart.jsx +10 -23
  56. package/src/components/LinearChart.jsx +133 -286
  57. package/src/components/PairedBarChart.jsx +6 -6
  58. package/src/components/PieChart.jsx +2 -4
  59. package/src/components/SparkLine.jsx +6 -42
  60. package/src/data/initial-state.js +23 -4
  61. package/src/hooks/useHighlightedBars.js +154 -0
  62. package/src/hooks/useMinMax.js +92 -0
  63. package/src/hooks/useReduceData.js +31 -57
  64. package/src/hooks/useScales.js +202 -0
  65. package/src/index.jsx +2 -1
  66. package/src/scss/editor-panel.scss +15 -0
  67. package/src/scss/main.scss +8 -6
  68. package/examples/box-plot.csv +0 -5
  69. package/examples/dynamic-legends.json +0 -125
  70. package/examples/example-bar-chart.json +0 -36
  71. package/examples/line-chart.json +0 -34
  72. package/examples/temp-example-config.json +0 -64
  73. package/examples/temp-example-data.json +0 -130
  74. package/src/components/Filters.jsx +0 -126
  75. /package/examples/{age-adjusted-rates.json → feature/__data__/age-adjusted-rates.json} +0 -0
  76. /package/examples/{new-data.csv → feature/__data__/new-data.csv} +0 -0
  77. /package/examples/{planet-example-data-max-increase.json → feature/__data__/planet-example-data-max-increase.json} +0 -0
  78. /package/examples/{Barchart_with_negative.json → feature/bar/Barchart_with_negative.json} +0 -0
  79. /package/examples/{stacked-vertical-bar-example-negative.json → feature/bar/stacked-vertical-bar-example-negative.json} +0 -0
  80. /package/examples/{stacked-vertical-bar-example.json → feature/bar/stacked-vertical-bar-example.json} +0 -0
  81. /package/examples/{box-plot-data.json → feature/boxplot/box-plot-data.json} +0 -0
  82. /package/examples/{newdata.json → feature/boxplot/boxplot-data.json} +0 -0
  83. /package/examples/{line-chart-max-increase.json → feature/line/line-chart-max-increase.json} +0 -0
  84. /package/examples/{paired-bar-data.json → feature/paired-bar/paired-bar-data.json} +0 -0
  85. /package/examples/{paired-bar-formatted.json → feature/paired-bar/paired-bar-formatted.json} +0 -0
  86. /package/examples/{scatterplot-continuous.csv → feature/scatterplot/scatterplot-continuous.csv} +0 -0
  87. /package/examples/{example-sparkline.json → feature/sparkline/example-sparkline.json} +0 -0
  88. /package/examples/{big-small-test-bar.json → feature/tests-big-small/big-small-test-bar.json} +0 -0
  89. /package/examples/{big-small-test-line.json → feature/tests-big-small/big-small-test-line.json} +0 -0
  90. /package/examples/{big-small-test-negative.json → feature/tests-big-small/big-small-test-negative.json} +0 -0
  91. /package/examples/{case-rate-example-data.json → feature/tests-case-rate/case-rate-example-data.json} +0 -0
  92. /package/examples/{covid-example-data-confidence.json → feature/tests-covid/covid-example-data-confidence.json} +0 -0
  93. /package/examples/{covid-example-data.json → feature/tests-covid/covid-example-data.json} +0 -0
  94. /package/examples/{cutoff-example-data.json → feature/tests-cutoff/cutoff-example-data.json} +0 -0
  95. /package/examples/{date-exclusions-data.json → feature/tests-date-exclusions/date-exclusions-data.json} +0 -0
  96. /package/examples/{example-combo-bar-nonnumeric.json → feature/tests-non-numerics/example-combo-bar-nonnumeric.json} +0 -0
  97. /package/examples/{line-chart-nonnumeric.json → feature/tests-non-numerics/line-chart-nonnumeric.json} +0 -0
  98. /package/examples/{planet-example-data-nonnumeric.json → feature/tests-non-numerics/planet-example-data-nonnumeric.json} +0 -0
@@ -1,130 +0,0 @@
1
- [
2
- {
3
- "date": "2011-10-01",
4
- "New York": "89.4",
5
- "San Francisco": "26.7",
6
- "Austin": "34.2",
7
- "wind": "Include Wind",
8
- "humidity": "Include Humidiy"
9
- },
10
- {
11
- "date": "2011-10-02",
12
- "New York": "54.0",
13
- "San Francisco": "59.9",
14
- "Austin": "68.7",
15
- "wind": "Include Wind",
16
- "humidity": "Include Humidiy"
17
- },
18
- {
19
- "date": "2011-10-03",
20
- "New York": "51.3",
21
- "San Francisco": "53.1",
22
- "Austin": "64.4",
23
- "wind": "Include Wind",
24
- "humidity": "Include Humidiy"
25
- },
26
- {
27
- "date": "2011-10-04",
28
- "New York": "34.7",
29
- "San Francisco": "56.8",
30
- "Austin": "98.0",
31
- "wind": "Include Wind",
32
- "humidity": "Include Humidiy"
33
- },
34
- {
35
- "date": "2011-10-01",
36
- "New York": "32.4",
37
- "San Francisco": "43.7",
38
- "Austin": "54.2",
39
- "wind": "Don't Include Wind",
40
- "humidity": "Include Humidiy"
41
- },
42
- {
43
- "date": "2011-10-02",
44
- "New York": "65.0",
45
- "San Francisco": "76.9",
46
- "Austin": "87.7",
47
- "wind": "Don't Include Wind",
48
- "humidity": "Include Humidiy"
49
- },
50
- {
51
- "date": "2011-10-03",
52
- "New York": "53.3",
53
- "San Francisco": "59.1",
54
- "Austin": "69.4",
55
- "wind": "Don't Include Wind",
56
- "humidity": "Include Humidiy"
57
- },
58
- {
59
- "date": "2011-10-04",
60
- "New York": "55.7",
61
- "San Francisco": "58.8",
62
- "Austin": "68.0",
63
- "wind": "Don't Include Wind",
64
- "humidity": "Include Humidiy"
65
- },
66
- {
67
- "date": "2011-10-01",
68
- "New York": "63.4",
69
- "San Francisco": "62.7",
70
- "Austin": "72.2",
71
- "wind": "Include Wind",
72
- "humidity": "Don't Include Humidiy"
73
- },
74
- {
75
- "date": "2011-10-02",
76
- "New York": "58.0",
77
- "San Francisco": "59.9",
78
- "Austin": "67.7",
79
- "wind": "Include Wind",
80
- "humidity": "Don't Include Humidiy"
81
- },
82
- {
83
- "date": "2011-10-03",
84
- "New York": "53.3",
85
- "San Francisco": "59.1",
86
- "Austin": "69.4",
87
- "wind": "Include Wind",
88
- "humidity": "Don't Include Humidiy"
89
- },
90
- {
91
- "date": "2011-10-04",
92
- "New York": "55.7",
93
- "San Francisco": "58.8",
94
- "Austin": "68.0",
95
- "wind": "Include Wind",
96
- "humidity": "Don't Include Humidiy"
97
- },
98
- {
99
- "date": "2011-10-01",
100
- "New York": "63.4",
101
- "San Francisco": "62.7",
102
- "Austin": "87.2",
103
- "wind": "Don't Include Wind",
104
- "humidity": "Don't Include Humidiy"
105
- },
106
- {
107
- "date": "2011-10-02",
108
- "New York": "98.0",
109
- "San Francisco": "59.9",
110
- "Austin": "67.7",
111
- "wind": "Don't Include Wind",
112
- "humidity": "Don't Include Humidiy"
113
- },
114
- {
115
- "date": "2011-10-03",
116
- "New York": "53.3",
117
- "San Francisco": "59.1",
118
- "Austin": "69.4",
119
- "wind": "Don't Include Wind",
120
- "humidity": "Don't Include Humidiy"
121
- },
122
- {
123
- "date": "2011-10-04",
124
- "New York": "55.7",
125
- "San Francisco": "54.8",
126
- "Austin": "68.0",
127
- "wind": "Don't Include Wind",
128
- "humidity": "Don't Include Humidiy"
129
- }
130
- ]
@@ -1,126 +0,0 @@
1
- import React, { useState, useContext } from 'react'
2
- import ConfigContext from './../ConfigContext'
3
- import Button from '@cdc/core/components/elements/Button'
4
-
5
- const useFilters = () => {
6
- const { config, setConfig, setFilteredData, excludedData, filterData } = useContext(ConfigContext)
7
- const [showApplyButton, setShowApplyButton] = useState(false)
8
-
9
- const sortAsc = (a, b) => {
10
- return a.toString().localeCompare(b.toString(), 'en', { numeric: true })
11
- }
12
-
13
- const sortDesc = (a, b) => {
14
- return b.toString().localeCompare(a.toString(), 'en', { numeric: true })
15
- }
16
-
17
- const announceChange = text => {}
18
-
19
- const changeFilterActive = (index, value) => {
20
- let newFilters = config.filters
21
- newFilters[index].active = value
22
- setConfig({
23
- ...config,
24
- filters: newFilters
25
- })
26
- setShowApplyButton(true)
27
- }
28
-
29
- const handleApplyButton = newFilters => {
30
- setConfig({ ...config, filters: newFilters })
31
- setFilteredData(filterData(newFilters, excludedData))
32
- setShowApplyButton(false)
33
- }
34
-
35
- const handleReset = () => {
36
- let newFilters = config.filters
37
-
38
- // reset to first item in values array.
39
- newFilters.map(filter => {
40
- filter.active = filter.values[0]
41
- return null
42
- })
43
-
44
- setFilteredData(filterData(newFilters, excludedData))
45
- setConfig({ ...config, filters: newFilters })
46
- }
47
-
48
- return { handleApplyButton, changeFilterActive, announceChange, sortAsc, sortDesc, showApplyButton, handleReset }
49
- }
50
-
51
- const Filters = () => {
52
- const { config } = useContext(ConfigContext)
53
- const { handleApplyButton, changeFilterActive, announceChange, sortAsc, sortDesc, showApplyButton, handleReset } = useFilters()
54
- const { filters } = config
55
- const buttonText = 'Apply Filters'
56
- const resetText = 'Reset All'
57
-
58
- // A List of Dropdowns
59
- const FilterList = () => {
60
- if (config.filters) {
61
- return config.filters.map((singleFilter, index) => {
62
- const values = []
63
-
64
- if (!singleFilter.order || singleFilter.order === '') {
65
- singleFilter.order = 'asc'
66
- }
67
-
68
- if (singleFilter.order === 'desc') {
69
- singleFilter.values = singleFilter.values.sort(sortDesc)
70
- }
71
-
72
- if (singleFilter.order === 'asc') {
73
- singleFilter.values = singleFilter.values.sort(sortAsc)
74
- }
75
-
76
- singleFilter.values.forEach((filterOption, index) => {
77
- values.push(
78
- <option key={index} value={filterOption}>
79
- {filterOption}
80
- </option>
81
- )
82
- })
83
-
84
- return (
85
- <div className='single-filter' key={index}>
86
- <label htmlFor={`filter-${index}`}>{singleFilter.label}</label>
87
- <select
88
- id={`filter-${index}`}
89
- className='filter-select'
90
- data-index='0'
91
- value={singleFilter.active}
92
- onChange={e => {
93
- changeFilterActive(index, e.target.value)
94
- announceChange(`Filter ${singleFilter.label} value has been changed to ${e.target.value}, please reference the data table to see updated values.`)
95
- }}
96
- >
97
- {values}
98
- </select>
99
- </div>
100
- )
101
- })
102
- } else {
103
- return null
104
- }
105
- }
106
-
107
- return (
108
- <section className={`filters-section`} style={{ display: 'block', width: '100%' }}>
109
- <div className='filters-section__wrapper' style={{ flexWrap: 'wrap', display: 'flex', gap: '7px 15px', marginTop: '15px' }}>
110
- <FilterList />
111
- {config.filters.length > 0 && (
112
- <div className='filter-section__buttons' style={{ width: '100%' }}>
113
- <Button onClick={() => handleApplyButton(filters)} disabled={!showApplyButton} style={{ marginRight: '10px' }}>
114
- {buttonText}
115
- </Button>
116
- <a href='#!' role='button' onClick={handleReset}>
117
- {resetText}
118
- </a>
119
- </div>
120
- )}
121
- </div>
122
- </section>
123
- )
124
- }
125
-
126
- export default Filters