@cdc/chart 4.23.2 → 4.23.4
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.
- package/dist/cdcchart.js +42292 -40337
- package/examples/feature/__data__/area-chart.json +56 -0
- package/examples/{planet-example-data.json → feature/__data__/planet-example-data-max-increase.json} +4 -4
- package/examples/feature/__data__/planet-example-data.json +68 -0
- package/examples/feature/area/area-chart.json +244 -0
- package/examples/{example-bar-chart.json → feature/bar/example-bar-chart.json} +4 -1
- package/examples/feature/bar/horizontal-chart-max-increase.json +44 -0
- package/examples/{horizontal-chart.json → feature/bar/horizontal-chart.json} +10 -4
- package/examples/{horizontal-stacked-bar-chart.json → feature/bar/horizontal-stacked-bar-chart.json} +7 -3
- package/examples/{planet-chart-horizontal-example-config.json → feature/bar/planet-chart-horizontal-example-config.json} +8 -3
- package/examples/feature/bar/planet-example-config.json +156 -0
- package/examples/{box-plot.json → feature/boxplot/boxplot.json} +7 -8
- package/examples/feature/boxplot/testing.csv +38 -0
- package/examples/feature/combo/combochart-categories_are_numbers .json +18 -0
- package/examples/{planet-combo-example-config.json → feature/combo/planet-combo-example-config.json} +1 -1
- package/examples/feature/deviation/planet-deviation-config.json +168 -0
- package/examples/feature/deviation/planet-deviation-data.json +38 -0
- package/examples/feature/filters/filter-testing.json +178 -0
- package/examples/feature/forecasting/case_date_example.csv +130 -0
- package/examples/feature/forecasting/effective_reproduction.json +202 -0
- package/examples/feature/forecasting/r_data.csv +130 -0
- package/examples/feature/line/line-chart-max-increase.json +32 -0
- package/examples/feature/line/line-chart.json +124 -0
- package/examples/{paired-bar-example.json → feature/paired-bar/paired-bar-example.json} +10 -4
- package/examples/{planet-pie-example-config.json → feature/pie/planet-pie-example-config.json} +2 -2
- package/examples/{scatterplot-continuous.csv → feature/scatterplot/scatterplot-continuous.csv} +3 -3
- package/examples/{scatterplot.json → feature/scatterplot/scatterplot.json} +3 -3
- package/examples/feature/sparkline/example-sparkline.json +76 -0
- package/examples/feature/tests-big-small/big-small-test-bar.json +328 -0
- package/examples/feature/tests-big-small/big-small-test-line.json +328 -0
- package/examples/feature/tests-big-small/big-small-test-negative.json +328 -0
- package/examples/{case-rate-example-config.json → feature/tests-case-rate/case-rate-example-config.json} +2 -2
- package/examples/{covid-confidence-example-config.json → feature/tests-covid/covid-confidence-example-config.json} +8 -3
- package/examples/{covid-example-config.json → feature/tests-covid/covid-example-config.json} +7 -3
- package/examples/{cutoff-example-config.json → feature/tests-cutoff/cutoff-example-config.json} +7 -3
- package/examples/{date-exclusions-config.json → feature/tests-date-exclusions/date-exclusions-config.json} +2 -2
- package/examples/{example-bar-chart-nonnumeric.json → feature/tests-non-numerics/example-bar-chart-nonnumeric.json} +1 -1
- package/examples/{line-chart-nonnumeric.json → feature/tests-non-numerics/line-chart-nonnumeric.json} +5 -5
- package/examples/{planet-pie-example-config-nonnumeric.json → feature/tests-non-numerics/planet-pie-example-config-nonnumeric.json} +2 -2
- package/examples/{sparkline-chart-nonnumeric.json → feature/tests-non-numerics/sparkline-chart-nonnumeric.json} +2 -2
- package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart.json +31 -172
- package/examples/gallery/bar-chart-vertical/combo-line-chart.json +145 -7
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart-confidence.json +1 -0
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart-with-confidence.json +96 -14
- package/examples/gallery/line/line.json +1 -0
- package/examples/gallery/paired-bar/paired-bar-chart.json +1 -0
- package/index.html +76 -35
- package/package.json +6 -3
- package/src/CdcChart.jsx +245 -106
- package/src/components/AreaChart.jsx +233 -0
- package/src/components/BarChart.jsx +103 -62
- package/src/components/BoxPlot.jsx +39 -18
- package/src/components/DataTable.jsx +26 -21
- package/src/components/DeviationBar.jsx +191 -0
- package/src/components/EditorPanel.jsx +662 -298
- package/src/components/Legend.jsx +59 -46
- package/src/components/LineChart.jsx +12 -36
- package/src/components/LinearChart.jsx +163 -64
- package/src/components/PairedBarChart.jsx +6 -7
- package/src/components/PieChart.jsx +12 -17
- package/src/components/ScatterPlot.jsx +19 -16
- package/src/components/SparkLine.jsx +84 -118
- package/src/components/useIntersectionObserver.jsx +1 -1
- package/src/data/initial-state.js +27 -7
- package/src/hooks/useColorPalette.js +58 -48
- package/src/hooks/useReduceData.js +3 -4
- package/src/index.jsx +3 -2
- package/src/scss/editor-panel.scss +20 -0
- package/src/scss/main.scss +8 -6
- package/src/test/CdcChart.test.jsx +6 -0
- package/examples/box-plot.csv +0 -5
- package/examples/dynamic-legends.json +0 -125
- package/examples/line-chart.json +0 -34
- package/examples/planet-example-config.json +0 -37
- package/examples/temp-example-config.json +0 -64
- package/examples/temp-example-data.json +0 -130
- package/src/components/Filters.jsx +0 -125
- /package/examples/{age-adjusted-rates.json → feature/__data__/age-adjusted-rates.json} +0 -0
- /package/examples/{new-data.csv → feature/__data__/new-data.csv} +0 -0
- /package/examples/{Barchart_with_negative.json → feature/bar/Barchart_with_negative.json} +0 -0
- /package/examples/{stacked-vertical-bar-example-negative.json → feature/bar/stacked-vertical-bar-example-negative.json} +0 -0
- /package/examples/{stacked-vertical-bar-example.json → feature/bar/stacked-vertical-bar-example.json} +0 -0
- /package/examples/{box-plot-data.json → feature/boxplot/box-plot-data.json} +0 -0
- /package/examples/{newdata.json → feature/boxplot/boxplot-data.json} +0 -0
- /package/examples/{paired-bar-data.json → feature/paired-bar/paired-bar-data.json} +0 -0
- /package/examples/{paired-bar-formatted.json → feature/paired-bar/paired-bar-formatted.json} +0 -0
- /package/examples/{case-rate-example-data.json → feature/tests-case-rate/case-rate-example-data.json} +0 -0
- /package/examples/{covid-example-data-confidence.json → feature/tests-covid/covid-example-data-confidence.json} +0 -0
- /package/examples/{covid-example-data.json → feature/tests-covid/covid-example-data.json} +0 -0
- /package/examples/{cutoff-example-data.json → feature/tests-cutoff/cutoff-example-data.json} +0 -0
- /package/examples/{date-exclusions-data.json → feature/tests-date-exclusions/date-exclusions-data.json} +0 -0
- /package/examples/{example-combo-bar-nonnumeric.json → feature/tests-non-numerics/example-combo-bar-nonnumeric.json} +0 -0
- /package/examples/{planet-example-data-nonnumeric.json → feature/tests-non-numerics/planet-example-data-nonnumeric.json} +0 -0
- /package/examples/{stacked-vertical-bar-example-nonnumerics.json → feature/tests-non-numerics/stacked-vertical-bar-example-nonnumerics.json} +0 -0
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "chart",
|
|
3
|
-
"title": "Example Line Chart",
|
|
4
|
-
"theme": "theme-green",
|
|
5
|
-
"fontSize": "medium",
|
|
6
|
-
"height": "375",
|
|
7
|
-
"padding": {
|
|
8
|
-
"left": 5,
|
|
9
|
-
"right": 5
|
|
10
|
-
},
|
|
11
|
-
"yAxis": {
|
|
12
|
-
"size": "75",
|
|
13
|
-
"gridLines": false,
|
|
14
|
-
"label": "Y-Axis Example Label",
|
|
15
|
-
"numTicks": "9"
|
|
16
|
-
},
|
|
17
|
-
"barThickness": 0.35,
|
|
18
|
-
"xAxis": {
|
|
19
|
-
"size": "77",
|
|
20
|
-
"tickRotation": "25",
|
|
21
|
-
"dataKey": "Date",
|
|
22
|
-
"label": "X-Axis Example Label",
|
|
23
|
-
"type": "date",
|
|
24
|
-
"dateParseFormat": "%d/%m/%Y",
|
|
25
|
-
"dateDisplayFormat": "%d/%m/%Y"
|
|
26
|
-
},
|
|
27
|
-
"table": {
|
|
28
|
-
"label": "Data Table",
|
|
29
|
-
"expanded": true,
|
|
30
|
-
"download": true
|
|
31
|
-
},
|
|
32
|
-
"legend": {
|
|
33
|
-
"behavior": "isolate",
|
|
34
|
-
"position": "right",
|
|
35
|
-
"label": "Type of Data",
|
|
36
|
-
"dynamicLegend": false
|
|
37
|
-
},
|
|
38
|
-
"palette": "qualitative-bold",
|
|
39
|
-
"labels": false,
|
|
40
|
-
"dataFormat": {},
|
|
41
|
-
"confidenceKeys": {},
|
|
42
|
-
"data": [
|
|
43
|
-
{
|
|
44
|
-
"Date": "1/15/2016",
|
|
45
|
-
"Alabama": "90",
|
|
46
|
-
"Alaska": "135",
|
|
47
|
-
"Arizona": "300",
|
|
48
|
-
"Arkansas": "95",
|
|
49
|
-
"California": "120",
|
|
50
|
-
"Colorado": "310"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"Date": "2/15/2016",
|
|
54
|
-
"Alabama": "40",
|
|
55
|
-
"Alaska": "90",
|
|
56
|
-
"Arizona": "240",
|
|
57
|
-
"Arkansas": "60",
|
|
58
|
-
"California": "160",
|
|
59
|
-
"Colorado": "200"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"Date": "3/15/2016",
|
|
63
|
-
"Alabama": "50",
|
|
64
|
-
"Alaska": "300",
|
|
65
|
-
"Arizona": "290",
|
|
66
|
-
"Arkansas": "100",
|
|
67
|
-
"California": "200",
|
|
68
|
-
"Colorado": "250"
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"Date": "4/15/2016",
|
|
72
|
-
"Alabama": "120",
|
|
73
|
-
"Alaska": "160",
|
|
74
|
-
"Arizona": "230",
|
|
75
|
-
"Arkansas": "180",
|
|
76
|
-
"California": "160",
|
|
77
|
-
"Colorado": "220"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"Date": "5/15/2016",
|
|
81
|
-
"Alabama": "80",
|
|
82
|
-
"Alaska": "350",
|
|
83
|
-
"Arizona": "300",
|
|
84
|
-
"Arkansas": "150",
|
|
85
|
-
"California": "130",
|
|
86
|
-
"Colorado": "100"
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
"Date": "6/15/2016",
|
|
90
|
-
"Alabama": "90",
|
|
91
|
-
"Alaska": "220",
|
|
92
|
-
"Arizona": "320",
|
|
93
|
-
"Arkansas": "100",
|
|
94
|
-
"California": "220",
|
|
95
|
-
"Colorado": "300"
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
|
-
"visualizationType": "Line",
|
|
99
|
-
"series": [
|
|
100
|
-
{
|
|
101
|
-
"dataKey": "Alabama",
|
|
102
|
-
"type": "Bar"
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"dataKey": "Alaska",
|
|
106
|
-
"type": "Bar"
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
"dataKey": "Arizona",
|
|
110
|
-
"type": "Bar"
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"dataKey": "Arkansas",
|
|
114
|
-
"type": "Bar"
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
"dataKey": "California",
|
|
118
|
-
"type": "Bar"
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
"dataKey": "Colorado",
|
|
122
|
-
"type": "Bar"
|
|
123
|
-
}
|
|
124
|
-
]
|
|
125
|
-
}
|
package/examples/line-chart.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "chart",
|
|
3
|
-
"title": "Example Line Chart",
|
|
4
|
-
"theme": "theme-green",
|
|
5
|
-
"fontSize": "medium",
|
|
6
|
-
"height": "375",
|
|
7
|
-
"padding": { "left": 5, "right": 5 },
|
|
8
|
-
"yAxis": { "size": "75", "gridLines": false, "label": "Y-Axis Example Label", "numTicks": "9" },
|
|
9
|
-
"barThickness": 0.35,
|
|
10
|
-
"xAxis": { "size": "77", "tickRotation": "25", "dataKey": "Date", "label": "X-Axis Example Label", "type": "date", "dateParseFormat": "%d/%m/%Y", "dateDisplayFormat": "%d/%m/%Y" },
|
|
11
|
-
"table": { "label": "Data Table", "expanded": true, "download": true },
|
|
12
|
-
"legend": { "behavior": "isolate", "position": "right", "label": "Type of Data" },
|
|
13
|
-
"palette": "qualitative-bold",
|
|
14
|
-
"labels": false,
|
|
15
|
-
"dataFormat": {},
|
|
16
|
-
"confidenceKeys": {},
|
|
17
|
-
"data": [
|
|
18
|
-
{ "Date": "1/15/2016", "Data 1": "90", "Data 2": "135", "Data 3": "300", "Data 4": "95", "Data 5": "120", "Data 6": "310" },
|
|
19
|
-
{ "Date": "2/15/2016", "Data 1": "40", "Data 2": "90", "Data 3": "240", "Data 4": "60", "Data 5": "160", "Data 6": "200" },
|
|
20
|
-
{ "Date": "3/15/2016", "Data 1": "50", "Data 2": "300", "Data 3": "290", "Data 4": "100", "Data 5": "200", "Data 6": "250" },
|
|
21
|
-
{ "Date": "4/15/2016", "Data 1": "120", "Data 2": "160", "Data 3": "230", "Data 4": "180", "Data 5": "160", "Data 6": "220" },
|
|
22
|
-
{ "Date": "5/15/2016", "Data 1": "80", "Data 2": "350", "Data 3": "300", "Data 4": "150", "Data 5": "130", "Data 6": "100" },
|
|
23
|
-
{ "Date": "6/15/2016", "Data 1": "90", "Data 2": "220", "Data 3": "320", "Data 4": "100", "Data 5": "220", "Data 6": "300" }
|
|
24
|
-
],
|
|
25
|
-
"visualizationType": "Line",
|
|
26
|
-
"series": [
|
|
27
|
-
{ "dataKey": "Data 1", "type": "Bar" },
|
|
28
|
-
{ "dataKey": "Data 2", "type": "Bar" },
|
|
29
|
-
{ "dataKey": "Data 3", "type": "Bar" },
|
|
30
|
-
{ "dataKey": "Data 4", "type": "Bar" },
|
|
31
|
-
{ "dataKey": "Data 5", "type": "Bar" },
|
|
32
|
-
{ "dataKey": "Data 6", "type": "Bar" }
|
|
33
|
-
]
|
|
34
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"title": "Planet Radius (Bar Example)",
|
|
3
|
-
"dataUrl": "/examples/planet-example-data.json",
|
|
4
|
-
"visualizationType": "Bar",
|
|
5
|
-
"visualizationSubType": "regular",
|
|
6
|
-
"series": [{ "dataKey": "Radius" }],
|
|
7
|
-
"fontSize": "medium",
|
|
8
|
-
"dataCutoff": "0.5",
|
|
9
|
-
"orientation": "vertical",
|
|
10
|
-
"dataFormat": {
|
|
11
|
-
"roundTo": 1,
|
|
12
|
-
"commas": false,
|
|
13
|
-
"prefix": "",
|
|
14
|
-
"suffix": "km"
|
|
15
|
-
},
|
|
16
|
-
"padding": {
|
|
17
|
-
"left": 5,
|
|
18
|
-
"right": 5
|
|
19
|
-
},
|
|
20
|
-
"yAxis": {
|
|
21
|
-
"label": "Measurement (1000km)",
|
|
22
|
-
"rightSeries": "Diameter",
|
|
23
|
-
"rightLabel": "testing"
|
|
24
|
-
},
|
|
25
|
-
"xAxis": {
|
|
26
|
-
"label": "Planet",
|
|
27
|
-
"dataKey": "name",
|
|
28
|
-
"tickRotation": 30
|
|
29
|
-
},
|
|
30
|
-
"legend": {
|
|
31
|
-
"hide": false
|
|
32
|
-
},
|
|
33
|
-
"table": {
|
|
34
|
-
"label": "Data Table",
|
|
35
|
-
"expanded": false
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"title": "Average Temperature By City (Line Example)",
|
|
3
|
-
"description": "<p>Average temperature from October 1st through August 29th in:</p><ul><li>New York</li><li>San Francisco</li><li>Austin</li></ul>",
|
|
4
|
-
"dataUrl": "/examples/temp-example-data.json",
|
|
5
|
-
"visualizationType": "Line",
|
|
6
|
-
"series": [
|
|
7
|
-
{ "dataKey": "New York", "label": "NY" },
|
|
8
|
-
{ "dataKey": "San Francisco", "label": "SF" },
|
|
9
|
-
{ "dataKey": "Austin", "label": "AU" }
|
|
10
|
-
],
|
|
11
|
-
"filters": [
|
|
12
|
-
{
|
|
13
|
-
"label": "Wind",
|
|
14
|
-
"columnName": "wind"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"label": "Humidity",
|
|
18
|
-
"columnName": "humidity"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"seriesLabel": "City",
|
|
22
|
-
"fontSize": "large",
|
|
23
|
-
"dataFormat": {
|
|
24
|
-
"commas": false,
|
|
25
|
-
"prefix": "",
|
|
26
|
-
"suffix": "°"
|
|
27
|
-
},
|
|
28
|
-
"padding": {
|
|
29
|
-
"left": 15,
|
|
30
|
-
"right": 15
|
|
31
|
-
},
|
|
32
|
-
"yAxis": {
|
|
33
|
-
"label": "Temperature",
|
|
34
|
-
"paddingPercent": 0.15
|
|
35
|
-
},
|
|
36
|
-
"xAxis": {
|
|
37
|
-
"label": "Date",
|
|
38
|
-
"dataKey": "date",
|
|
39
|
-
"type": "date",
|
|
40
|
-
"dateParseFormat": "%Y-%m-%d",
|
|
41
|
-
"dateDisplayFormat": "%b %d",
|
|
42
|
-
"numTicks": 8,
|
|
43
|
-
"tickRotation": 50
|
|
44
|
-
},
|
|
45
|
-
"legend": {
|
|
46
|
-
"label": "Legend",
|
|
47
|
-
"above": true,
|
|
48
|
-
"left": true
|
|
49
|
-
},
|
|
50
|
-
"table": {
|
|
51
|
-
"label": "Data Table",
|
|
52
|
-
"expanded": false,
|
|
53
|
-
"download": true
|
|
54
|
-
},
|
|
55
|
-
"regions": [
|
|
56
|
-
{
|
|
57
|
-
"label": "Region",
|
|
58
|
-
"color": "black",
|
|
59
|
-
"background": "green",
|
|
60
|
-
"from": "2011-10-02",
|
|
61
|
-
"to": "2011-10-03"
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
}
|
|
@@ -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,125 +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, filteredData, setFilteredData, excludedData, filterData, runtimeFilters } = 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
|
-
})
|
|
42
|
-
|
|
43
|
-
setFilteredData(filterData(newFilters, excludedData))
|
|
44
|
-
setConfig({ ...config, filters: newFilters })
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return { handleApplyButton, changeFilterActive, announceChange, sortAsc, sortDesc, showApplyButton, handleReset }
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const Filters = () => {
|
|
51
|
-
const { config } = useContext(ConfigContext)
|
|
52
|
-
const { handleApplyButton, changeFilterActive, announceChange, sortAsc, sortDesc, showApplyButton, handleReset } = useFilters()
|
|
53
|
-
const { filters } = config
|
|
54
|
-
const buttonText = 'Apply Filters'
|
|
55
|
-
const resetText = 'Reset All'
|
|
56
|
-
|
|
57
|
-
// A List of Dropdowns
|
|
58
|
-
const FilterList = () => {
|
|
59
|
-
if (config.filters) {
|
|
60
|
-
return config.filters.map((singleFilter, index) => {
|
|
61
|
-
const values = []
|
|
62
|
-
|
|
63
|
-
if (!singleFilter.order || singleFilter.order === '') {
|
|
64
|
-
singleFilter.order = 'asc'
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (singleFilter.order === 'desc') {
|
|
68
|
-
singleFilter.values = singleFilter.values.sort(sortDesc)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (singleFilter.order === 'asc') {
|
|
72
|
-
singleFilter.values = singleFilter.values.sort(sortAsc)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
singleFilter.values.forEach((filterOption, index) => {
|
|
76
|
-
values.push(
|
|
77
|
-
<option key={index} value={filterOption}>
|
|
78
|
-
{filterOption}
|
|
79
|
-
</option>
|
|
80
|
-
)
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<div className='single-filter' key={index}>
|
|
85
|
-
<label htmlFor={`filter-${index}`}>{singleFilter.label}</label>
|
|
86
|
-
<select
|
|
87
|
-
id={`filter-${index}`}
|
|
88
|
-
className='filter-select'
|
|
89
|
-
data-index='0'
|
|
90
|
-
value={singleFilter.active}
|
|
91
|
-
onChange={e => {
|
|
92
|
-
changeFilterActive(index, e.target.value)
|
|
93
|
-
announceChange(`Filter ${singleFilter.label} value has been changed to ${e.target.value}, please reference the data table to see updated values.`)
|
|
94
|
-
}}
|
|
95
|
-
>
|
|
96
|
-
{values}
|
|
97
|
-
</select>
|
|
98
|
-
</div>
|
|
99
|
-
)
|
|
100
|
-
})
|
|
101
|
-
} else {
|
|
102
|
-
return null
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<section className={`filters-section`} style={{ display: 'block', width: '100%' }}>
|
|
108
|
-
<div className='filters-section__wrapper' style={{ flexWrap: 'wrap', display: 'flex', gap: '7px 15px', marginTop: '15px' }}>
|
|
109
|
-
<FilterList />
|
|
110
|
-
{config.filters.length > 0 && (
|
|
111
|
-
<div className='filter-section__buttons' style={{ width: '100%' }}>
|
|
112
|
-
<Button onClick={() => handleApplyButton(filters)} disabled={!showApplyButton} style={{ marginRight: '10px' }}>
|
|
113
|
-
{buttonText}
|
|
114
|
-
</Button>
|
|
115
|
-
<a href='#!' role='button' onClick={handleReset}>
|
|
116
|
-
{resetText}
|
|
117
|
-
</a>
|
|
118
|
-
</div>
|
|
119
|
-
)}
|
|
120
|
-
</div>
|
|
121
|
-
</section>
|
|
122
|
-
)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export default Filters
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/examples/{paired-bar-formatted.json → feature/paired-bar/paired-bar-formatted.json}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/examples/{cutoff-example-data.json → feature/tests-cutoff/cutoff-example-data.json}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|