@cdc/waffle-chart 4.23.8 → 4.23.10
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/cdcwafflechart.js +2379 -2435
- package/package.json +3 -3
- package/src/CdcWaffleChart.jsx +7 -7
- package/src/_stories/WaffleChart.stories.tsx +80 -0
- package/src/components/EditorPanel.jsx +1 -1
- package/src/scss/main.scss +1 -33
- package/src/scss/waffle-chart.scss +16 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/waffle-chart",
|
|
3
|
-
"version": "4.23.
|
|
3
|
+
"version": "4.23.10",
|
|
4
4
|
"description": "React component for displaying a single piece of data in a card module",
|
|
5
5
|
"moduleName": "CdcWaffleChart",
|
|
6
6
|
"main": "dist/cdcwafflechart",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"homepage": "https://github.com/CDCgov/cdc-open-viz#readme",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@cdc/core": "^4.23.
|
|
29
|
+
"@cdc/core": "^4.23.10",
|
|
30
30
|
"@visx/group": "^3.0.0",
|
|
31
31
|
"@visx/scale": "^3.0.0",
|
|
32
32
|
"@visx/shape": "^3.0.0",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"react": "^18.2.0",
|
|
42
42
|
"react-dom": "^18.2.0"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "ff5b1ca0c84bb0629bc69e5a26a4a81254dbf69f"
|
|
45
45
|
}
|
package/src/CdcWaffleChart.jsx
CHANGED
|
@@ -273,7 +273,7 @@ const WaffleChart = ({ config, isEditor, link }) => {
|
|
|
273
273
|
const gaugeHeight = 35
|
|
274
274
|
|
|
275
275
|
const xScale = scaleLinear({
|
|
276
|
-
domain: [0,
|
|
276
|
+
domain: [0, waffleDenominator],
|
|
277
277
|
range: [0, gaugeWidth]
|
|
278
278
|
})
|
|
279
279
|
const gaugeColor = themeColor[theme]
|
|
@@ -291,19 +291,19 @@ const WaffleChart = ({ config, isEditor, link }) => {
|
|
|
291
291
|
{config.visualizationType === 'Gauge' && (
|
|
292
292
|
<div className={`cove-gauge-chart${config.overallFontSize ? ' font-' + config.overallFontSize : ''}`}>
|
|
293
293
|
<div className='cove-gauge-chart__chart'>
|
|
294
|
-
<div style={dataFontSize}>
|
|
294
|
+
<div className='cove-waffle-chart__data--primary' style={dataFontSize}>
|
|
295
295
|
{prefix ? prefix : ' '}
|
|
296
296
|
{config.showPercent ? dataPercentage : waffleNumerator}
|
|
297
297
|
{suffix ? suffix + ' ' : ' '} {config.valueDescription} {config.showDenominator && waffleDenominator ? waffleDenominator : ' '}
|
|
298
298
|
</div>
|
|
299
|
-
<div className='cove-
|
|
299
|
+
<div className='cove-waffle-chart__data--text'>{parse(content)}</div>
|
|
300
300
|
<svg height={gaugeHeight} width={'100%'}>
|
|
301
301
|
<Group>
|
|
302
302
|
<foreignObject style={{ border: '1px solid black' }} x={0} y={0} width={gaugeWidth} height={gaugeHeight} fill='#fff' />
|
|
303
|
-
<Bar x={0} y={0} width={xScale(
|
|
303
|
+
<Bar x={0} y={0} width={xScale(waffleNumerator)} height={gaugeHeight} fill={gaugeColor} />
|
|
304
304
|
</Group>
|
|
305
305
|
</svg>
|
|
306
|
-
<div className={'cove-
|
|
306
|
+
<div className={'cove-waffle-chart__subtext subtext'}>{parse(subtext)}</div>
|
|
307
307
|
</div>
|
|
308
308
|
</div>
|
|
309
309
|
)}
|
|
@@ -325,7 +325,7 @@ const WaffleChart = ({ config, isEditor, link }) => {
|
|
|
325
325
|
)}
|
|
326
326
|
<div className='cove-waffle-chart__data--text'>{parse(content)}</div>
|
|
327
327
|
|
|
328
|
-
{subtext && <div className='cove-waffle-chart__subtext'>{parse(subtext)}</div>}
|
|
328
|
+
{subtext && <div className='cove-waffle-chart__subtext subtext'>{parse(subtext)}</div>}
|
|
329
329
|
</div>
|
|
330
330
|
)}
|
|
331
331
|
</div>
|
|
@@ -425,7 +425,7 @@ const CdcWaffleChart = ({ configUrl, config: configObj, isDashboard = false, isE
|
|
|
425
425
|
let content = <Loading />
|
|
426
426
|
|
|
427
427
|
if (loading === false) {
|
|
428
|
-
let classNames = ['cove', 'type-waffle-chart', currentViewport, config.theme, 'font-' + config.overallFontSize]
|
|
428
|
+
let classNames = ['cove', 'cdc-open-viz-module', 'type-waffle-chart', currentViewport, config.theme, 'font-' + config.overallFontSize]
|
|
429
429
|
|
|
430
430
|
if (isEditor) {
|
|
431
431
|
classNames.push('is-editor')
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
3
|
+
|
|
4
|
+
import WaffleChart from '../CdcWaffleChart'
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof WaffleChart> = {
|
|
7
|
+
title: 'Components/Templates/WaffleChart',
|
|
8
|
+
component: WaffleChart
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type Story = StoryObj<typeof WaffleChart>
|
|
12
|
+
|
|
13
|
+
export const Primary: Story = {
|
|
14
|
+
args: {
|
|
15
|
+
config: {
|
|
16
|
+
shape: 'square',
|
|
17
|
+
title: 'Overdose Mortality Rates',
|
|
18
|
+
content: 'of overdoses resulted in death.',
|
|
19
|
+
subtext: 'This data is an example and does not reflect actual averages',
|
|
20
|
+
orientation: 'horizontal',
|
|
21
|
+
data: [
|
|
22
|
+
{
|
|
23
|
+
'Resulted in Death': 250,
|
|
24
|
+
'Number of Overdoses': 600,
|
|
25
|
+
state: 'Alabama',
|
|
26
|
+
Year: '2010'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
'Resulted in Death': 16,
|
|
30
|
+
'Number of Overdoses': 80,
|
|
31
|
+
state: 'Alaska',
|
|
32
|
+
Year: '2008'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
'Resulted in Death': 19,
|
|
36
|
+
'Number of Overdoses': 100,
|
|
37
|
+
state: 'Alaska',
|
|
38
|
+
Year: '2010'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
'Resulted in Death': 93,
|
|
42
|
+
'Number of Overdoses': 400,
|
|
43
|
+
state: 'Alaska',
|
|
44
|
+
Year: '2012'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
'Resulted in Death': 82,
|
|
48
|
+
'Number of Overdoses': 400,
|
|
49
|
+
state: 'Arizona',
|
|
50
|
+
Year: '2010'
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
filters: [],
|
|
54
|
+
fontSize: null,
|
|
55
|
+
overallFontSize: 'medium',
|
|
56
|
+
dataColumn: 'Resulted in Death',
|
|
57
|
+
dataFunction: 'Sum',
|
|
58
|
+
dataConditionalColumn: '',
|
|
59
|
+
dataConditionalOperator: null,
|
|
60
|
+
dataConditionalComparate: '',
|
|
61
|
+
customDenom: true,
|
|
62
|
+
dataDenom: null,
|
|
63
|
+
dataDenomColumn: 'Number of Overdoses',
|
|
64
|
+
dataDenomFunction: 'Sum',
|
|
65
|
+
prefix: '',
|
|
66
|
+
suffix: '%',
|
|
67
|
+
roundToPlace: 0,
|
|
68
|
+
nodeWidth: 10,
|
|
69
|
+
nodeSpacer: 2,
|
|
70
|
+
theme: 'blue'
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
render: args => (
|
|
74
|
+
<>
|
|
75
|
+
<WaffleChart {...args} />
|
|
76
|
+
</>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default meta
|
|
@@ -418,7 +418,7 @@ const EditorPanel = memo(props => {
|
|
|
418
418
|
<InputText type='number' value={config.fontSize} fieldName='fontSize' updateField={updateField} />
|
|
419
419
|
</div>
|
|
420
420
|
<div className='cove-accordion__panel-col' style={{ display: 'flex', alignItems: 'center' }}>
|
|
421
|
-
<label className='accordion__panel-label--muted'>
|
|
421
|
+
<label className='accordion__panel-label--muted'> default (50px)</label>
|
|
422
422
|
</div>
|
|
423
423
|
</div>
|
|
424
424
|
</div>
|
package/src/scss/main.scss
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@import '@cdc/core/styles/v2/components/input';
|
|
2
2
|
@import '@cdc/core/styles/v2/main';
|
|
3
|
+
@import '@cdc/core/styles/base';
|
|
3
4
|
@import 'waffle-chart';
|
|
4
5
|
|
|
5
6
|
.cdc-open-viz-module.type-waffle-chart {
|
|
@@ -13,37 +14,4 @@
|
|
|
13
14
|
content: '\21BB';
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
@include breakpointClass(xs) {
|
|
18
|
-
&.font-small {
|
|
19
|
-
font-size: 0.8em;
|
|
20
|
-
}
|
|
21
|
-
&.font-medium {
|
|
22
|
-
font-size: 0.9em;
|
|
23
|
-
}
|
|
24
|
-
&.font-large {
|
|
25
|
-
font-size: 1em;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@include breakpointClass(md) {
|
|
30
|
-
&.font-small {
|
|
31
|
-
font-size: 0.9em;
|
|
32
|
-
}
|
|
33
|
-
&.font-large {
|
|
34
|
-
font-size: 1.1em;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
@include breakpointClass(lg) {
|
|
39
|
-
&.font-small {
|
|
40
|
-
font-size: 1em;
|
|
41
|
-
}
|
|
42
|
-
&.font-medium {
|
|
43
|
-
font-size: 1.1em;
|
|
44
|
-
}
|
|
45
|
-
&.font-large {
|
|
46
|
-
font-size: 1.2em;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
17
|
}
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
.cove .waffle-chart .cove-component__header {
|
|
12
|
-
|
|
13
|
-
}
|
|
11
|
+
// .cove .waffle-chart .cove-component__header {
|
|
12
|
+
// font-size: unset;
|
|
13
|
+
// }
|
|
14
14
|
|
|
15
15
|
//@each $theme, $color in $theme-colors {
|
|
16
16
|
// .cdc-waffle-chart.theme-#{$theme} #{&} {
|
|
@@ -43,14 +43,19 @@
|
|
|
43
43
|
flex-direction: column;
|
|
44
44
|
justify-items: center;
|
|
45
45
|
align-items: flex-start;
|
|
46
|
+
|
|
47
|
+
& > svg {
|
|
48
|
+
margin: 0.7em 0;
|
|
49
|
+
}
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
&__subtext {
|
|
49
|
-
font-
|
|
53
|
+
font-style: italic;
|
|
54
|
+
font-size: 0.9em !important;
|
|
50
55
|
}
|
|
51
56
|
&__text {
|
|
52
57
|
line-height: 1.25em;
|
|
53
|
-
|
|
58
|
+
font-weight: 400;
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
|
|
@@ -82,10 +87,6 @@
|
|
|
82
87
|
margin-bottom: 1rem;
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
.cove-waffle-chart__subtext {
|
|
86
|
-
font-size: 0.75em;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
90
|
.cove-waffle-chart__data {
|
|
90
91
|
display: flex;
|
|
91
92
|
flex-wrap: wrap;
|
|
@@ -122,36 +123,30 @@
|
|
|
122
123
|
@at-root {
|
|
123
124
|
.cove-waffle-chart.font-small,
|
|
124
125
|
.cove-gauge-chart.font-small #{&} {
|
|
125
|
-
.cove-waffle-chart__data--primary
|
|
126
|
-
.cove-gauge-chart__data--primary {
|
|
126
|
+
.cove-waffle-chart__data--primary {
|
|
127
127
|
font-size: 35px;
|
|
128
128
|
}
|
|
129
|
-
.cove-waffle-chart__data--text
|
|
130
|
-
.cove-gauge-chart__data--text {
|
|
129
|
+
.cove-waffle-chart__data--text {
|
|
131
130
|
font-size: 14px;
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
.cove-waffle-chart.font-medium,
|
|
136
135
|
.cove-gauge-chart.font-medium #{&} {
|
|
137
|
-
.cove-waffle-chart__data--primary
|
|
138
|
-
.cove-gauge-chart__data--primary {
|
|
136
|
+
.cove-waffle-chart__data--primary {
|
|
139
137
|
font-size: 50px;
|
|
140
138
|
}
|
|
141
|
-
.cove-waffle-chart__data--text
|
|
142
|
-
.cove-gauge-chart__data--text {
|
|
139
|
+
.cove-waffle-chart__data--text {
|
|
143
140
|
font-size: 18px;
|
|
144
141
|
}
|
|
145
142
|
}
|
|
146
143
|
|
|
147
144
|
.cove-waffle-chart.font-large,
|
|
148
145
|
.cove-gauge-chart.font-large #{&} {
|
|
149
|
-
.cove-waffle-chart__data--primary
|
|
150
|
-
.cove-gauge-chart__data--primary {
|
|
146
|
+
.cove-waffle-chart__data--primary {
|
|
151
147
|
font-size: 80px;
|
|
152
148
|
}
|
|
153
|
-
.cove-waffle-chart__data--text
|
|
154
|
-
.cove-gauge-chart__data--text {
|
|
149
|
+
.cove-waffle-chart__data--text {
|
|
155
150
|
font-size: 20px;
|
|
156
151
|
}
|
|
157
152
|
}
|