@cdc/chart 1.3.4 → 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.
- package/LICENSE +201 -0
- package/README.md +5 -5
- package/dist/cdcchart.js +6 -6
- package/examples/age-adjusted-rates.json +1486 -1218
- package/examples/case-rate-example-config.json +1 -1
- package/examples/covid-confidence-example-config.json +33 -33
- package/examples/covid-example-config.json +34 -34
- package/examples/covid-example-data-confidence.json +30 -30
- package/examples/covid-example-data.json +20 -20
- package/examples/cutoff-example-config.json +36 -34
- package/examples/cutoff-example-data.json +36 -36
- package/examples/date-exclusions-config.json +1 -1
- package/examples/dynamic-legends.json +125 -0
- package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart-with-numbers-on-bar.json +192 -0
- package/examples/gallery/bar-chart-horizontal/horizontal-bar-chart.json +231 -0
- package/examples/gallery/bar-chart-horizontal/horizontal-stacked.json +240 -0
- package/examples/gallery/bar-chart-vertical/combo-line-chart.json +137 -0
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart-categorical.json +80 -0
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +81 -0
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart-with-confidence.json +68 -0
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart.json +111 -0
- package/examples/gallery/lollipop/lollipop-style-horizontal.json +216 -0
- package/examples/gallery/paired-bar/paired-bar-chart.json +196 -0
- package/examples/horizontal-chart.json +36 -33
- package/examples/horizontal-stacked-bar-chart.json +34 -34
- package/examples/line-chart.json +75 -75
- package/examples/paired-bar-data.json +16 -14
- package/examples/paired-bar-example.json +48 -46
- package/examples/paired-bar-formatted.json +36 -36
- package/examples/planet-chart-horizontal-example-config.json +33 -33
- package/examples/planet-combo-example-config.json +34 -29
- package/examples/planet-example-config.json +35 -33
- package/examples/planet-example-data.json +56 -56
- package/examples/planet-pie-example-config.json +28 -26
- package/examples/private/filters.json +170 -0
- package/examples/private/line-test-data.json +22 -0
- package/examples/private/line-test-two.json +210 -0
- package/examples/private/line-test.json +102 -0
- package/examples/private/new.json +48800 -0
- package/examples/private/shawn.json +1106 -0
- package/examples/private/test.json +10123 -10123
- package/examples/private/yaxis-test.json +133 -0
- package/examples/private/yaxis-testing.csv +27 -0
- package/examples/private/yaxis.json +28 -0
- package/examples/stacked-vertical-bar-example.json +228 -0
- package/examples/temp-example-config.json +61 -54
- package/examples/temp-example-data.json +1 -1
- package/package.json +2 -2
- package/src/CdcChart.tsx +370 -458
- package/src/components/BarChart.tsx +449 -441
- package/src/components/DataTable.tsx +164 -180
- package/src/components/EditorPanel.js +1066 -663
- package/src/components/Legend.js +284 -0
- package/src/components/LineChart.tsx +114 -63
- package/src/components/LinearChart.tsx +394 -358
- package/src/components/PairedBarChart.tsx +216 -135
- package/src/components/PieChart.tsx +106 -135
- package/src/components/SparkLine.js +184 -205
- package/src/components/useIntersectionObserver.tsx +27 -0
- package/src/context.tsx +3 -3
- package/src/data/initial-state.js +44 -7
- package/src/hooks/useActiveElement.js +13 -13
- package/src/hooks/useChartClasses.js +41 -0
- package/src/hooks/useColorPalette.ts +56 -63
- package/src/hooks/useLegendClasses.js +28 -0
- package/src/hooks/useReduceData.ts +69 -37
- package/src/hooks/useRightAxis.js +25 -0
- package/src/hooks/useTopAxis.js +6 -0
- package/src/index.html +54 -55
- package/src/index.tsx +13 -16
- package/src/scss/DataTable.scss +5 -4
- package/src/scss/editor-panel.scss +103 -71
- package/src/scss/main.scss +277 -38
- package/src/scss/variables.scss +1 -1
- package/src/components/BarStackVertical.js +0 -0
|
@@ -1,83 +1,76 @@
|
|
|
1
|
-
import { useEffect, useReducer } from 'react'
|
|
1
|
+
import { useEffect, useReducer } from 'react'
|
|
2
2
|
|
|
3
|
-
// constants
|
|
4
|
-
const SEQUENTIAL = 'SEQUENTIAL'
|
|
5
|
-
const SEQUENTIAL_REVERSE = 'SEQUENTIAL_REVERSE'
|
|
6
|
-
export const GET_PALETTE = 'GET_PALETTE'
|
|
3
|
+
// constants
|
|
4
|
+
const SEQUENTIAL = 'SEQUENTIAL'
|
|
5
|
+
const SEQUENTIAL_REVERSE = 'SEQUENTIAL_REVERSE'
|
|
6
|
+
export const GET_PALETTE = 'GET_PALETTE'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
// types & interfaces
|
|
8
|
+
// types & interfaces
|
|
10
9
|
interface State {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
payload: Palettes;
|
|
22
|
-
paletteName?:string
|
|
23
|
-
};
|
|
10
|
+
readonly filteredPallets: string[]
|
|
11
|
+
readonly filteredQualitative: string[]
|
|
12
|
+
readonly isPaletteReversed: boolean
|
|
13
|
+
paletteName: string | undefined
|
|
14
|
+
}
|
|
15
|
+
interface Action<Palettes> {
|
|
16
|
+
type: 'SEQUENTIAL' | 'SEQUENTIAL_REVERSE' | 'GET_PALETTE'
|
|
17
|
+
payload: Palettes
|
|
18
|
+
paletteName?: string
|
|
19
|
+
}
|
|
24
20
|
|
|
25
21
|
// create initial state
|
|
26
|
-
const initialState:State = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
const initialState: State = {
|
|
23
|
+
filteredPallets: [],
|
|
24
|
+
isPaletteReversed: false,
|
|
25
|
+
filteredQualitative: [],
|
|
26
|
+
paletteName: undefined
|
|
27
|
+
}
|
|
32
28
|
|
|
33
|
-
function reducer<T>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
function reducer<T>(state: State, action: Action<T>): State {
|
|
30
|
+
// <T> refers to generic type
|
|
31
|
+
const palletNamesArr: string[] = Object.keys(action.payload) // action.payload === colorPalettes object
|
|
32
|
+
let paletteName: string = ''
|
|
33
|
+
switch (action.type) {
|
|
37
34
|
case GET_PALETTE:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return { ...state, filteredPallets: sequential,filteredQualitative:qualitative, paletteName:paletteName,isPaletteReversed:false};
|
|
35
|
+
return { ...state, paletteName: action.paletteName }
|
|
36
|
+
case SEQUENTIAL:
|
|
37
|
+
paletteName = state.paletteName && state.paletteName.endsWith('reverse') ? String(state.paletteName).substring(0, state.paletteName.length - 7) : String(state.paletteName)
|
|
38
|
+
const qualitative = palletNamesArr.filter((name: string) => String(name).startsWith('qualitative') && !String(name).endsWith('reverse'))
|
|
39
|
+
const sequential = palletNamesArr.filter((name: string) => String(name).startsWith('sequential') && !String(name).endsWith('reverse'))
|
|
40
|
+
return { ...state, filteredPallets: sequential, filteredQualitative: qualitative, paletteName: paletteName, isPaletteReversed: false }
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
case SEQUENTIAL_REVERSE:
|
|
43
|
+
paletteName = palletNamesArr.find((name: string) => name === String(state.paletteName).concat('reverse') || name === String(state.paletteName).concat('-reverse'))
|
|
44
|
+
const qualitativeReverse: string[] = palletNamesArr.filter((name: string) => String(name).startsWith('qualitative') && String(name).endsWith('reverse'))
|
|
45
|
+
const sequentialReverse: string[] = palletNamesArr.filter((name: string) => String(name).startsWith('sequential') && String(name).endsWith('reverse'))
|
|
46
|
+
return { ...state, filteredQualitative: qualitativeReverse, filteredPallets: sequentialReverse, paletteName: paletteName, isPaletteReversed: true }
|
|
47
|
+
default:
|
|
48
|
+
return state
|
|
52
49
|
}
|
|
53
|
-
}
|
|
50
|
+
}
|
|
54
51
|
|
|
55
52
|
interface Keyable {
|
|
56
|
-
palette:string
|
|
57
|
-
isPaletteReversed:boolean
|
|
53
|
+
palette: string
|
|
54
|
+
isPaletteReversed: boolean
|
|
58
55
|
}
|
|
59
|
-
function init(initialState){
|
|
56
|
+
function init(initialState) {
|
|
60
57
|
return initialState
|
|
61
58
|
}
|
|
62
59
|
|
|
63
|
-
export function useColorPalette<T,Y extends Keyable>(colorPalettes:T,configState:Y){
|
|
64
|
-
const [state, dispatch] = useReducer(reducer, initialState,init)
|
|
65
|
-
const {paletteName,isPaletteReversed,filteredPallets,filteredQualitative} = state
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
export function useColorPalette<T, Y extends Keyable>(colorPalettes: T, configState: Y) {
|
|
61
|
+
const [state, dispatch] = useReducer(reducer, initialState, init)
|
|
62
|
+
const { paletteName, isPaletteReversed, filteredPallets, filteredQualitative } = state
|
|
69
63
|
|
|
70
64
|
useEffect(() => {
|
|
71
|
-
dispatch({ type: SEQUENTIAL, payload: colorPalettes })
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
dispatch({ type: SEQUENTIAL, payload: colorPalettes })
|
|
66
|
+
}, [])
|
|
74
67
|
|
|
75
|
-
useEffect(()=>{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (configState.isPaletteReversed) {
|
|
70
|
+
dispatch({ type: 'SEQUENTIAL_REVERSE', payload: colorPalettes })
|
|
71
|
+
return () => dispatch({ type: 'SEQUENTIAL', payload: colorPalettes })
|
|
79
72
|
}
|
|
80
|
-
|
|
73
|
+
}, [configState.isPaletteReversed, dispatch, colorPalettes])
|
|
81
74
|
|
|
82
|
-
|
|
83
|
-
}
|
|
75
|
+
return { paletteName, isPaletteReversed, filteredPallets, filteredQualitative, dispatch }
|
|
76
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export default function useLegendClasses(config) {
|
|
2
|
+
let containerClasses = ['legend-container']
|
|
3
|
+
let innerClasses = ['legend-container__inner']
|
|
4
|
+
|
|
5
|
+
// Legend Positioning
|
|
6
|
+
if (config.legend.position === "left") {
|
|
7
|
+
containerClasses.push('left')
|
|
8
|
+
}
|
|
9
|
+
if (config.legend.position === "bottom") {
|
|
10
|
+
containerClasses.push('bottom')
|
|
11
|
+
innerClasses.push('bottom')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if(config.legend.position==='bottom' && config.legend.singleRow){
|
|
15
|
+
innerClasses.push('single-row')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Legend > Item Ordering
|
|
19
|
+
if (config.legend.reverseLabelOrder) {
|
|
20
|
+
innerClasses.push('d-flex')
|
|
21
|
+
innerClasses.push('flex-column-reverse')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
containerClasses,
|
|
26
|
+
innerClasses
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,43 +1,75 @@
|
|
|
1
|
+
function useReduceData(config, data) {
|
|
2
|
+
// for combo charts check all Data Series set to Bar;
|
|
3
|
+
const isBar = config?.series?.every(element => element?.type === 'Bar')
|
|
1
4
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
const getMaxValueFromData = () => {
|
|
6
|
+
let max // will hold max number from data.
|
|
7
|
+
if ((config.visualizationType === 'Bar' || (config.visualizationType === 'Combo' && isBar)) && config.visualizationSubType === 'stacked') {
|
|
8
|
+
const yTotals = data.reduce((allTotals, xValue) => {
|
|
9
|
+
const totalYValues = config.runtime.seriesKeys.reduce((yTotal, k) => {
|
|
10
|
+
yTotal += Number(xValue[k])
|
|
11
|
+
return yTotal
|
|
12
|
+
}, 0)
|
|
13
|
+
|
|
14
|
+
allTotals.push(totalYValues)
|
|
15
|
+
if (totalYValues > max) {
|
|
16
|
+
max = totalYValues
|
|
17
|
+
}
|
|
18
|
+
return allTotals
|
|
19
|
+
}, [] as number[])
|
|
20
|
+
|
|
21
|
+
max = Math.max(...yTotals)
|
|
22
|
+
} else if (config.visualizationType === 'Bar' && config.series && config.series.dataKey) {
|
|
23
|
+
max = Math.max(...data.map(d => Number(d[config.series.dataKey])))
|
|
24
|
+
} else if (config.visualizationType === 'Combo' && config.visualizationSubType === 'stacked' && !isBar) {
|
|
25
|
+
let total = []
|
|
26
|
+
|
|
27
|
+
if (config.runtime.barSeriesKeys && config.runtime.lineSeriesKeys) {
|
|
28
|
+
// get barSeries max Values added to each other
|
|
29
|
+
data.map(function (d, index) {
|
|
30
|
+
const totalYValues = config.runtime.barSeriesKeys.reduce((yTotal, k) => {
|
|
31
|
+
yTotal += Number(d[k])
|
|
32
|
+
return yTotal
|
|
33
|
+
}, 0)
|
|
34
|
+
total.push(totalYValues)
|
|
35
|
+
})
|
|
36
|
+
// get lineSeries largest values
|
|
37
|
+
const lineMax = Math.max(...data.map(d => Math.max(...config.runtime.lineSeriesKeys.map(key => Number(d[key])))))
|
|
38
|
+
|
|
39
|
+
const barMax = Math.max(...total)
|
|
40
|
+
|
|
41
|
+
max = Number(barMax) > Number(lineMax) ? barMax : lineMax
|
|
25
42
|
}
|
|
43
|
+
} else {
|
|
44
|
+
max = Math.max(...data.map(d => Math.max(...config.runtime.seriesKeys.map(key => Number(d[key])))))
|
|
45
|
+
}
|
|
26
46
|
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const getMinValueFromData = ()=> {
|
|
31
|
-
let min
|
|
32
|
-
const minNumberFromData = Math.min(...data.map(
|
|
47
|
+
return max
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const getMinValueFromData = () => {
|
|
51
|
+
let min
|
|
52
|
+
const minNumberFromData = Math.min(...data.map(d => Math.min(...config.runtime.seriesKeys.map(key => Number(d[key])))))
|
|
33
53
|
min = String(minNumberFromData)
|
|
34
|
-
|
|
35
|
-
return min
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
54
|
+
|
|
55
|
+
return min
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const findPositiveNum = (): boolean => {
|
|
59
|
+
// loop throught provided data to find positve number in arr based on series keys.
|
|
60
|
+
let existPositiveValue = false
|
|
61
|
+
if (config.runtime.seriesKeys) {
|
|
62
|
+
for (let i = 0; i < config.runtime.seriesKeys.length; i++) {
|
|
63
|
+
existPositiveValue = data.some(d => d[config.runtime.seriesKeys[i]] >= 0)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return existPositiveValue
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const maxValue = getMaxValueFromData()
|
|
70
|
+
const minValue = getMinValueFromData()
|
|
71
|
+
const existPositiveValue = findPositiveNum()
|
|
72
|
+
return { minValue, maxValue, existPositiveValue }
|
|
41
73
|
}
|
|
42
74
|
|
|
43
|
-
export default useReduceData
|
|
75
|
+
export default useReduceData
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { scaleLinear } from '@visx/scale'
|
|
2
|
+
|
|
3
|
+
export default function useRightAxis({ config, yMax = 0, data = [], updateConfig }) {
|
|
4
|
+
const hasRightAxis = config.visualizationType === 'Combo' && config.orientation === 'vertical'
|
|
5
|
+
const rightSeriesKeys = config.series && config.series.filter(series => series.axis === 'Right').map(key => key.dataKey)
|
|
6
|
+
|
|
7
|
+
const allRightAxisData = rightSeriesKeys => {
|
|
8
|
+
if (!rightSeriesKeys) return [0]
|
|
9
|
+
let rightAxisData = []
|
|
10
|
+
rightSeriesKeys.map((key, index) => {
|
|
11
|
+
return (rightAxisData = [...rightAxisData, ...data.map(item => Number(item[key]))])
|
|
12
|
+
})
|
|
13
|
+
return rightAxisData
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const min = Math.min.apply(null, allRightAxisData(rightSeriesKeys))
|
|
17
|
+
const max = Math.max.apply(null, allRightAxisData(rightSeriesKeys))
|
|
18
|
+
|
|
19
|
+
const yScaleRight = scaleLinear({
|
|
20
|
+
domain: [0, max],
|
|
21
|
+
range: [yMax, 0]
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
return { yScaleRight, hasRightAxis }
|
|
25
|
+
}
|
package/src/index.html
CHANGED
|
@@ -1,68 +1,67 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta
|
|
6
|
-
name="viewport"
|
|
7
|
-
content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
|
8
|
-
/>
|
|
9
|
-
<style>
|
|
10
|
-
body {
|
|
11
|
-
/* max-width: 1000px; */
|
|
12
|
-
margin: 0 auto !important;
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-direction: column;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
}
|
|
17
|
-
.react-container + .react-container {
|
|
18
|
-
margin-top: 3rem;
|
|
19
|
-
}
|
|
20
|
-
</style>
|
|
21
|
-
</head>
|
|
22
|
-
<body>
|
|
23
|
-
<!-- <div class="react-container" data-config="/examples/temp-example-config.json"></div> -->
|
|
24
3
|
|
|
25
|
-
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
/* max-width: 1000px; */
|
|
10
|
+
margin: 0 auto !important;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.react-container+.react-container {
|
|
17
|
+
margin-top: 3rem;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
20
|
+
</head>
|
|
21
|
+
|
|
22
|
+
<body>
|
|
23
|
+
<!-- <div class="react-container" data-config="/examples/temp-example-config.json"></div> -->
|
|
24
|
+
|
|
25
|
+
<!-- <select id="cove_select">
|
|
26
26
|
<option value=""">Choose An Option</option>
|
|
27
27
|
<option value="Non-Hispanic White">Non-Hispanic White</option>
|
|
28
28
|
<option value="Hispanic or Latino">Test 2</option>
|
|
29
29
|
</select> -->
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
<div class="react-container" data-config="/examples/private/yaxis-test.json"></div>
|
|
32
|
+
<!-- <div class="react-container" data-config="/examples/dynamic-legends.json"></div> -->
|
|
33
|
+
<!-- <div class="react-container" data-config="/examples/cutoff-example-config.json"></div> -->
|
|
34
|
+
<!-- <div class="react-container" data-config="/examples/covid-confidence-example-config.json"></div> -->
|
|
35
|
+
<!-- <div class="react-container" data-config="/examples/planet-example-config.json"></div> -->
|
|
36
|
+
<!-- <div class="react-container" data-config="/examples/planet-chart-horizontal-example-config.json"></div> -->
|
|
37
|
+
<!-- <div class="react-container" data-config="/examples/planet-combo-example-config.json"></div>-->
|
|
38
|
+
<!-- <div class="react-container" data-config="/examples/planet-pie-example-config.json"></div>-->
|
|
39
|
+
<!-- <div class="react-container" data-config="/examples/date-exclusions-config.json"></div> -->
|
|
40
|
+
<!--<div class="react-container" data-config="/examples/case-rate-example-config.json"></div>-->
|
|
41
|
+
<!-- <div class="react-container" data-config="/examples/private/textelements.json"></div> -->
|
|
42
|
+
<!-- <div class="react-container" data-config="/examples/private/example-bar-chart.json"></div> -->
|
|
43
|
+
<!-- <div class="react-container" data-config="/examples/example-sparkline.json"></div> -->
|
|
44
|
+
<!-- DATA PRESENTATION GALLERY: https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/bar-chart.html#examples -->
|
|
45
|
+
|
|
46
|
+
<!-- HORIZONTAL BAR CHARTS -->
|
|
47
|
+
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-horizontal/horizontal-bar-chart-with-numbers-on-bar.json"></div> -->
|
|
48
|
+
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-horizontal/horizontal-bar-chart.json"></div> -->
|
|
49
|
+
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-horizontal/horizontal-stacked.json"></div> -->
|
|
50
|
+
|
|
51
|
+
<!-- VERTICAL BAR CHARTS -->
|
|
52
|
+
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-vertical/combo-line-chart.json"></div> -->
|
|
53
|
+
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-vertical/vertical-bar-chart-categorical.json"></div> -->
|
|
54
|
+
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json"></div> -->
|
|
55
|
+
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-vertical/vertical-bar-with-confidence.json"></div> -->
|
|
56
|
+
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-vertical/vertical-bar-chart.json"></div> -->
|
|
41
57
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<!-- DATA PRESENTATION GALLERY: https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/bar-chart.html#examples -->
|
|
46
|
-
|
|
47
|
-
<!-- HORIZONTAL BAR CHARTS -->
|
|
48
|
-
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-horizontal/horizontal-bar-chart-with-numbers-on-bar.json"></div> -->
|
|
49
|
-
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-horizontal/horizontal-bar-chart.json"></div> -->
|
|
50
|
-
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-horizontal/horizontal-stacked.json"></div> -->
|
|
58
|
+
<!-- LOLLIPOP CHARTS -->
|
|
59
|
+
<!-- <div class="react-container" data-config="/examples/gallery/lollipop/lollipop-style-horizontal.json"></div> -->
|
|
51
60
|
|
|
61
|
+
<!-- PAIRED BAR CHARTS -->
|
|
62
|
+
<!-- <div class="react-container" data-config="/examples/gallery/paired-bar/paired-bar-chart.json"></div> -->
|
|
52
63
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-vertical/vertical-bar-chart-categorical.json"></div> -->
|
|
56
|
-
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json"></div> -->
|
|
57
|
-
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-vertical/vertical-bar-with-confidence.json"></div> -->
|
|
58
|
-
<!-- <div class="react-container" data-config="/examples/gallery/bar-chart-vertical/vertical-bar-chart.json"></div> -->
|
|
59
|
-
|
|
60
|
-
<!-- LOLLIPOP CHARTS -->
|
|
61
|
-
<!-- <div class="react-container" data-config="/examples/gallery/lollipop/lollipop-style-horizontal.json"></div> -->
|
|
62
|
-
|
|
63
|
-
<!-- PAIRED BAR CHARTS -->
|
|
64
|
-
<!-- <div class="react-container" data-config="/examples/gallery/paired-bar/paired-bar-chart.json"></div> -->
|
|
64
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
65
|
+
</body>
|
|
65
66
|
|
|
66
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
67
|
-
</body>
|
|
68
67
|
</html>
|
package/src/index.tsx
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { publish, subscribe } from '@cdc/core/helpers/events'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { render } from 'react-dom'
|
|
1
|
+
import { publish, subscribe } from '@cdc/core/helpers/events'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { render } from 'react-dom'
|
|
4
4
|
|
|
5
|
-
import CdcChart from './CdcChart'
|
|
5
|
+
import CdcChart from './CdcChart'
|
|
6
6
|
|
|
7
|
-
const domContainers = document.querySelectorAll('.react-container')
|
|
7
|
+
const domContainers = document.querySelectorAll('.react-container')
|
|
8
8
|
|
|
9
|
-
let isEditor = window.location.href.includes('editor=true')
|
|
9
|
+
let isEditor = window.location.href.includes('editor=true')
|
|
10
10
|
|
|
11
|
-
domContainers.forEach(
|
|
12
|
-
render(
|
|
11
|
+
domContainers.forEach(domContainer => {
|
|
12
|
+
render(
|
|
13
13
|
<React.StrictMode>
|
|
14
|
-
<CdcChart
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
domContainer,
|
|
20
|
-
);
|
|
21
|
-
});
|
|
14
|
+
<CdcChart configUrl={domContainer.attributes['data-config'].value} isEditor={isEditor} />
|
|
15
|
+
</React.StrictMode>,
|
|
16
|
+
domContainer
|
|
17
|
+
)
|
|
18
|
+
})
|
package/src/scss/DataTable.scss
CHANGED