@cdc/waffle-chart 4.23.5 → 4.23.7
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 +4821 -3476
- package/examples/example-config.json +2 -2
- package/examples/gauge.json +134 -0
- package/package.json +6 -3
- package/src/CdcWaffleChart.jsx +54 -22
- package/src/components/EditorPanel.jsx +41 -23
- package/src/data/initial-state.js +6 -1
- package/src/images/warning.svg +1 -0
- package/src/scss/main.scss +1 -0
- package/src/scss/waffle-chart.scss +47 -10
- package/LICENSE +0 -201
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"type": "waffle-chart",
|
|
3
3
|
"dataUrl": "/examples/example-data.json",
|
|
4
4
|
"filters": [],
|
|
5
|
-
"title": "
|
|
5
|
+
"title": "Chart Title",
|
|
6
6
|
"content": "of cases occurred in the home",
|
|
7
|
-
"subtext": "
|
|
7
|
+
"subtext": "Chart subtext or citation",
|
|
8
8
|
"theme": "theme-blue",
|
|
9
9
|
"suffix": "%"
|
|
10
10
|
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Chart Title",
|
|
3
|
+
"visualizationType": "Gauge",
|
|
4
|
+
"visualizationSubType": "linear",
|
|
5
|
+
"showPercent": true,
|
|
6
|
+
"showDenominator": true,
|
|
7
|
+
"valueDescription": "out of",
|
|
8
|
+
"content": "of cases occurred in the home",
|
|
9
|
+
"subtext": "Chart subtext or citation",
|
|
10
|
+
"orientation": "horizontal",
|
|
11
|
+
"data": [
|
|
12
|
+
{
|
|
13
|
+
"Insured Rate": "43",
|
|
14
|
+
"Coverage Status": "Insured",
|
|
15
|
+
"state": "Alabama",
|
|
16
|
+
"Year (Good filter option)": "2010",
|
|
17
|
+
"link": "",
|
|
18
|
+
"Verified": true
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"Insured Rate": "0",
|
|
22
|
+
"Coverage Status": "Uninsured",
|
|
23
|
+
"state": "Alaska",
|
|
24
|
+
"Year (Good filter option)": "2006",
|
|
25
|
+
"link": "",
|
|
26
|
+
"Verified": false
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"Insured Rate": "72.7",
|
|
30
|
+
"Coverage Status": "Insured",
|
|
31
|
+
"state": "Arizona",
|
|
32
|
+
"Year (Good filter option)": "2008",
|
|
33
|
+
"link": "#lorem",
|
|
34
|
+
"Verified": true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"Insured Rate": "78.7",
|
|
38
|
+
"Coverage Status": "Insured",
|
|
39
|
+
"state": "Arkansas",
|
|
40
|
+
"Year (Good filter option)": "2010",
|
|
41
|
+
"link": "",
|
|
42
|
+
"Verified": true
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"Insured Rate": "37.2",
|
|
46
|
+
"Coverage Status": "Insured",
|
|
47
|
+
"state": "California",
|
|
48
|
+
"Year (Good filter option)": "2018",
|
|
49
|
+
"link": "https://search.cdc.gov/search/?query=California&utf8=%E2%9C%93&affiliate=cdc-main",
|
|
50
|
+
"Verified": true
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"Insured Rate": "50.6",
|
|
54
|
+
"Coverage Status": "Insured",
|
|
55
|
+
"state": "Colorado",
|
|
56
|
+
"Year (Good filter option)": "2014",
|
|
57
|
+
"link": "",
|
|
58
|
+
"Verified": false
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"Insured Rate": "83.2",
|
|
62
|
+
"Coverage Status": "Insured",
|
|
63
|
+
"state": "Connecticut",
|
|
64
|
+
"Year (Good filter option)": "2019",
|
|
65
|
+
"link": "",
|
|
66
|
+
"Verified": true
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"Insured Rate": "90",
|
|
70
|
+
"Coverage Status": "Insured",
|
|
71
|
+
"state": "Delaware",
|
|
72
|
+
"Year (Good filter option)": "2020",
|
|
73
|
+
"link": "",
|
|
74
|
+
"Verified": true
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"Insured Rate": "77.1",
|
|
78
|
+
"Coverage Status": "Insured",
|
|
79
|
+
"state": "District of Columbia",
|
|
80
|
+
"Year (Good filter option)": "2019",
|
|
81
|
+
"link": "https://search.cdc.gov/search/index.html?query=Washington+D.C.&sitelimit=&utf8=%E2%9C%93&affiliate=cdc-main",
|
|
82
|
+
"Verified": false
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"Insured Rate": "83",
|
|
86
|
+
"Coverage Status": "Insured",
|
|
87
|
+
"state": "Florida",
|
|
88
|
+
"Year (Good filter option)": "2016",
|
|
89
|
+
"link": "",
|
|
90
|
+
"Verified": true
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"Insured Rate": "67.4",
|
|
94
|
+
"Coverage Status": "Insured",
|
|
95
|
+
"state": "Georgia",
|
|
96
|
+
"Year (Good filter option)": "2013",
|
|
97
|
+
"link": "",
|
|
98
|
+
"Verified": false
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"filters": [],
|
|
102
|
+
"fontSize": "",
|
|
103
|
+
"overallFontSize": "medium",
|
|
104
|
+
"dataColumn": "Insured Rate",
|
|
105
|
+
"dataFunction": "Count",
|
|
106
|
+
"dataConditionalColumn": "",
|
|
107
|
+
"dataConditionalOperator": "",
|
|
108
|
+
"dataConditionalComparate": "",
|
|
109
|
+
"invalidComparate": false,
|
|
110
|
+
"customDenom": false,
|
|
111
|
+
"dataDenom": "100",
|
|
112
|
+
"dataDenomColumn": "",
|
|
113
|
+
"dataDenomFunction": "",
|
|
114
|
+
"suffix": "%",
|
|
115
|
+
"roundToPlace": "0",
|
|
116
|
+
"shape": "circle",
|
|
117
|
+
"nodeWidth": "10",
|
|
118
|
+
"nodeSpacer": "2",
|
|
119
|
+
"theme": "theme-blue",
|
|
120
|
+
"type": "waffle-chart",
|
|
121
|
+
"visual": {
|
|
122
|
+
"border": true,
|
|
123
|
+
"accent": false,
|
|
124
|
+
"background": false,
|
|
125
|
+
"hideBackgroundColor": false,
|
|
126
|
+
"borderColorTheme": false
|
|
127
|
+
},
|
|
128
|
+
"dataUrl": "/examples/example-data.json",
|
|
129
|
+
"validated": 4.23,
|
|
130
|
+
"runtime": {
|
|
131
|
+
"uniqueId": 1690862969105,
|
|
132
|
+
"editorErrorMessage": ""
|
|
133
|
+
}
|
|
134
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/waffle-chart",
|
|
3
|
-
"version": "4.23.
|
|
3
|
+
"version": "4.23.7",
|
|
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,8 +26,11 @@
|
|
|
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.7",
|
|
30
|
+
"@visx/group": "^3.0.0",
|
|
31
|
+
"@visx/scale": "^3.0.0",
|
|
30
32
|
"@visx/shape": "^3.0.0",
|
|
33
|
+
"@visx/text": "^3.0.0",
|
|
31
34
|
"chroma": "0.0.1",
|
|
32
35
|
"chroma-js": "^2.1.0",
|
|
33
36
|
"html-react-parser": "^3.0.8",
|
|
@@ -38,5 +41,5 @@
|
|
|
38
41
|
"react": "^18.2.0",
|
|
39
42
|
"react-dom": "^18.2.0"
|
|
40
43
|
},
|
|
41
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "6c7ac5215dcf3bc1cc7d199089c8c2e75f53a93e"
|
|
42
45
|
}
|
package/src/CdcWaffleChart.jsx
CHANGED
|
@@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useState } from 'react'
|
|
|
2
2
|
import parse from 'html-react-parser'
|
|
3
3
|
import { Group } from '@visx/group'
|
|
4
4
|
import { Circle, Bar } from '@visx/shape'
|
|
5
|
+
import { scaleLinear } from '@visx/scale'
|
|
5
6
|
|
|
6
7
|
import ResizeObserver from 'resize-observer-polyfill'
|
|
7
8
|
import getViewport from '@cdc/core/helpers/getViewport'
|
|
@@ -17,6 +18,7 @@ import defaults from './data/initial-state'
|
|
|
17
18
|
import { publish } from '@cdc/core/helpers/events'
|
|
18
19
|
|
|
19
20
|
import useDataVizClasses from '@cdc/core/helpers/useDataVizClasses'
|
|
21
|
+
import coveUpdateWorker from '@cdc/core/helpers/coveUpdateWorker'
|
|
20
22
|
|
|
21
23
|
import './scss/main.scss'
|
|
22
24
|
|
|
@@ -202,10 +204,10 @@ const WaffleChart = ({ config, isEditor, link }) => {
|
|
|
202
204
|
}
|
|
203
205
|
|
|
204
206
|
// @ts-ignore
|
|
205
|
-
return applyPrecision((waffleNumerator / waffleDenominator) * 100)
|
|
207
|
+
return [applyPrecision((waffleNumerator / waffleDenominator) * 100), waffleDenominator, applyPrecision(waffleNumerator)]
|
|
206
208
|
}, [dataColumn, dataFunction, config.data, filters, dataConditionalColumn, dataConditionalOperator, dataConditionalComparate, customDenom, dataDenomColumn, dataDenomFunction, roundToPlace, dataDenom])
|
|
207
209
|
|
|
208
|
-
const dataPercentage = calculateData()
|
|
210
|
+
const [dataPercentage, waffleDenominator, waffleNumerator] = calculateData()
|
|
209
211
|
|
|
210
212
|
const buildWaffle = useCallback(() => {
|
|
211
213
|
let waffleData = []
|
|
@@ -267,6 +269,14 @@ const WaffleChart = ({ config, isEditor, link }) => {
|
|
|
267
269
|
console.error(e.message)
|
|
268
270
|
}
|
|
269
271
|
}
|
|
272
|
+
const gaugeWidth = '100%'
|
|
273
|
+
const gaugeHeight = 35
|
|
274
|
+
|
|
275
|
+
const xScale = scaleLinear({
|
|
276
|
+
domain: [0, config.dataDenom],
|
|
277
|
+
range: [0, gaugeWidth]
|
|
278
|
+
})
|
|
279
|
+
const gaugeColor = themeColor[theme]
|
|
270
280
|
|
|
271
281
|
return (
|
|
272
282
|
<div className={innerContainerClasses.join(' ')}>
|
|
@@ -278,27 +288,48 @@ const WaffleChart = ({ config, isEditor, link }) => {
|
|
|
278
288
|
)}
|
|
279
289
|
<div className={contentClasses.join(' ')}>
|
|
280
290
|
<div className='cove-component__content-wrap'>
|
|
281
|
-
|
|
282
|
-
<div className=
|
|
283
|
-
<
|
|
284
|
-
<
|
|
285
|
-
|
|
291
|
+
{config.visualizationType === 'Gauge' && (
|
|
292
|
+
<div className={`cove-gauge-chart${config.overallFontSize ? ' font-' + config.overallFontSize : ''}`}>
|
|
293
|
+
<div className='cove-gauge-chart__chart'>
|
|
294
|
+
<div style={dataFontSize}>
|
|
295
|
+
{prefix ? prefix : ' '}
|
|
296
|
+
{config.showPercent ? dataPercentage : waffleNumerator}
|
|
297
|
+
{suffix ? suffix + ' ' : ' '} {config.valueDescription} {config.showDenominator && waffleDenominator ? waffleDenominator : ' '}
|
|
298
|
+
</div>
|
|
299
|
+
<div className='cove-gauge-chart__data--text'>{parse(content)}</div>
|
|
300
|
+
<svg height={gaugeHeight} width={'100%'}>
|
|
301
|
+
<Group>
|
|
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(dataPercentage)} height={gaugeHeight} fill={gaugeColor} />
|
|
304
|
+
</Group>
|
|
305
|
+
</svg>
|
|
306
|
+
<div className={'cove-gauge-chart__subtext'}>{parse(subtext)}</div>
|
|
307
|
+
</div>
|
|
286
308
|
</div>
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
</div>
|
|
295
|
-
)}
|
|
296
|
-
<div className='cove-waffle-chart__data--text'>{parse(content)}</div>
|
|
297
|
-
|
|
298
|
-
{subtext && <div className='cove-waffle-chart__subtext'>{parse(subtext)}</div>}
|
|
309
|
+
)}
|
|
310
|
+
{config.visualizationType !== 'Gauge' && (
|
|
311
|
+
<div className={`cove-waffle-chart${orientation === 'vertical' ? ' cove-waffle-chart--verical' : ''}${config.overallFontSize ? ' font-' + config.overallFontSize : ''}`}>
|
|
312
|
+
<div className='cove-waffle-chart__chart' style={{ width: setRatio() }}>
|
|
313
|
+
<svg width={setRatio()} height={setRatio()} role='img' aria-label={handleWaffleChartAriaLabel(config)} tabIndex={0}>
|
|
314
|
+
<Group>{buildWaffle()}</Group>
|
|
315
|
+
</svg>
|
|
299
316
|
</div>
|
|
300
|
-
|
|
301
|
-
|
|
317
|
+
{(dataPercentage || content) && (
|
|
318
|
+
<div className='cove-waffle-chart__data'>
|
|
319
|
+
{dataPercentage && (
|
|
320
|
+
<div className='cove-waffle-chart__data--primary' style={dataFontSize}>
|
|
321
|
+
{prefix ? prefix : null}
|
|
322
|
+
{dataPercentage}
|
|
323
|
+
{suffix ? suffix : null}
|
|
324
|
+
</div>
|
|
325
|
+
)}
|
|
326
|
+
<div className='cove-waffle-chart__data--text'>{parse(content)}</div>
|
|
327
|
+
|
|
328
|
+
{subtext && <div className='cove-waffle-chart__subtext'>{parse(subtext)}</div>}
|
|
329
|
+
</div>
|
|
330
|
+
)}
|
|
331
|
+
</div>
|
|
332
|
+
)}
|
|
302
333
|
</div>
|
|
303
334
|
</div>
|
|
304
335
|
{link && link}
|
|
@@ -341,7 +372,8 @@ const CdcWaffleChart = ({ configUrl, config: configObj, isDashboard = false, isE
|
|
|
341
372
|
|
|
342
373
|
response.data = responseData
|
|
343
374
|
|
|
344
|
-
|
|
375
|
+
const processedConfig = { ...(await coveUpdateWorker(response)) }
|
|
376
|
+
updateConfig({ ...defaults, ...processedConfig })
|
|
345
377
|
setLoading(false)
|
|
346
378
|
}, [])
|
|
347
379
|
|
|
@@ -13,6 +13,7 @@ import InputSelect from '@cdc/core/components/inputs/InputSelect'
|
|
|
13
13
|
import InputCheckbox from '@cdc/core/components/inputs/InputCheckbox'
|
|
14
14
|
|
|
15
15
|
import '@cdc/core/styles/v2/components/editor.scss'
|
|
16
|
+
import WarningImage from '../images/warning.svg'
|
|
16
17
|
|
|
17
18
|
import { DATA_OPERATORS, DATA_FUNCTIONS } from '../CdcWaffleChart'
|
|
18
19
|
|
|
@@ -39,6 +40,7 @@ const EditorPanel = memo(props => {
|
|
|
39
40
|
|
|
40
41
|
const [displayPanel, setDisplayPanel] = useState(true)
|
|
41
42
|
const [showConfigConfirm, setShowConfigConfirm] = useState(false)
|
|
43
|
+
const inputSelectStyle = condition => (condition ? { backgroundColor: '#ffd2d2', color: '#d8000c' } : {})
|
|
42
44
|
|
|
43
45
|
const updateField = (section, subsection, fieldName, newValue) => {
|
|
44
46
|
// Top level
|
|
@@ -194,12 +196,20 @@ const EditorPanel = memo(props => {
|
|
|
194
196
|
}
|
|
195
197
|
return filterDataOptions
|
|
196
198
|
}
|
|
199
|
+
//visualizationType
|
|
200
|
+
|
|
201
|
+
const approvedWaffleChartOptions = ['Waffle', 'Gauge']
|
|
197
202
|
|
|
198
203
|
const editorContent = (
|
|
199
204
|
<Accordion>
|
|
200
205
|
<Accordion.Section title='General'>
|
|
201
|
-
<
|
|
202
|
-
|
|
206
|
+
<div className='cove-accordion__panel-section'>
|
|
207
|
+
<div style={{ width: '100%', display: 'block' }} className='cove-input-group'>
|
|
208
|
+
<InputSelect value={config.visualizationType} fieldName='visualizationType' label='Chart Type' updateField={updateField} options={approvedWaffleChartOptions} className='cove-input' />
|
|
209
|
+
{config.visualizationType === 'Gauge' && <InputSelect value={config.visualizationSubType} fieldName='visualizationSubType' label='Chart Subtype' updateField={updateField} options={['Linear']} className='cove-input' />}
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
<InputText value={config.title} fieldName='title' label='Title' placeholder='Chart Title' updateField={updateField} />
|
|
203
213
|
<InputText
|
|
204
214
|
type='textarea'
|
|
205
215
|
value={config.content}
|
|
@@ -222,7 +232,7 @@ const EditorPanel = memo(props => {
|
|
|
222
232
|
value={config.subtext}
|
|
223
233
|
fieldName='subtext'
|
|
224
234
|
label='Subtext/Citation'
|
|
225
|
-
placeholder='
|
|
235
|
+
placeholder='Chart Subtext or Citation'
|
|
226
236
|
updateField={updateField}
|
|
227
237
|
tooltip={
|
|
228
238
|
<Tooltip style={{ textTransform: 'none' }}>
|
|
@@ -236,15 +246,16 @@ const EditorPanel = memo(props => {
|
|
|
236
246
|
}
|
|
237
247
|
/>
|
|
238
248
|
</Accordion.Section>
|
|
239
|
-
|
|
249
|
+
|
|
250
|
+
<Accordion.Section icon={!config.dataColumn || !config.dataFunction ? <WarningImage width='15' className='warning-icon' /> : ''} title='Data'>
|
|
240
251
|
<h4 style={{ fontWeight: '600' }}>Numerator</h4>
|
|
241
252
|
<div className='cove-accordion__panel-section'>
|
|
242
253
|
<div className='cove-input-group'>
|
|
243
|
-
<InputSelect value={config.dataColumn || ''} fieldName='dataColumn' label='Data Column' updateField={updateField} initial='Select' options={getColumns()} className='cove-input' />
|
|
254
|
+
<InputSelect style={inputSelectStyle(!config.dataColumn)} value={config.dataColumn || ''} fieldName='dataColumn' label='Data Column' updateField={updateField} initial='Select' options={getColumns()} className='cove-input' />
|
|
244
255
|
</div>
|
|
245
256
|
|
|
246
257
|
<div className='cove-input-group'>
|
|
247
|
-
<InputSelect value={config.dataFunction || ''} fieldName='dataFunction' label='Data Function' updateField={updateField} initial='Select' options={DATA_FUNCTIONS} className='cove-input' />
|
|
258
|
+
<InputSelect style={inputSelectStyle(!config.dataFunction)} value={config.dataFunction || ''} fieldName='dataFunction' label='Data Function' updateField={updateField} initial='Select' options={DATA_FUNCTIONS} className='cove-input' />
|
|
248
259
|
</div>
|
|
249
260
|
|
|
250
261
|
<div className='cove-input-group'>
|
|
@@ -308,9 +319,16 @@ const EditorPanel = memo(props => {
|
|
|
308
319
|
</div>
|
|
309
320
|
</li>
|
|
310
321
|
</ul>
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
322
|
+
{config.visualizationType === 'Gauge' && (
|
|
323
|
+
<>
|
|
324
|
+
<hr className='cove-accordion__divider' />
|
|
325
|
+
<div className='cove-accordion__panel-section reverse-labels'>
|
|
326
|
+
<InputText inline size='small' value={config.valueDescription} label='Value Descriptor' fieldName='valueDescription' updateField={updateField} />
|
|
327
|
+
<InputCheckbox inline size='small' value={config.showPercent} label='Show Percentage' fieldName='showPercent' updateField={updateField} />
|
|
328
|
+
<InputCheckbox inline size='small' label='Show Denominator' value={config.showDenominator} fieldName='showDenominator' updateField={updateField} />
|
|
329
|
+
</div>
|
|
330
|
+
</>
|
|
331
|
+
)}
|
|
314
332
|
<label style={{ marginBottom: '1rem' }}>
|
|
315
333
|
<span className='edit-label'>Data Point Filters</span>
|
|
316
334
|
<Tooltip style={{ textTransform: 'none' }}>
|
|
@@ -322,6 +340,7 @@ const EditorPanel = memo(props => {
|
|
|
322
340
|
</Tooltip.Content>
|
|
323
341
|
</Tooltip>
|
|
324
342
|
</label>
|
|
343
|
+
|
|
325
344
|
{config.filters && (
|
|
326
345
|
<ul className='filters-list' style={{ paddingLeft: 0, marginBottom: '1rem' }}>
|
|
327
346
|
{config.filters.map((filter, index) => (
|
|
@@ -376,20 +395,19 @@ const EditorPanel = memo(props => {
|
|
|
376
395
|
</Button>
|
|
377
396
|
</Accordion.Section>
|
|
378
397
|
<Accordion.Section title='Visual'>
|
|
379
|
-
<InputSelect value={config.shape} fieldName='shape' label='Shape' updateField={updateField} options={['circle', 'square', 'person']} className='cove-input' />
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
398
|
+
{config.visualizationType !== 'Gauge' && <InputSelect value={config.shape} fieldName='shape' label='Shape' updateField={updateField} options={['circle', 'square', 'person']} className='cove-input' />}
|
|
399
|
+
{config.visualizationType !== 'Gauge' && (
|
|
400
|
+
<div className='cove-accordion__panel-row cove-accordion__small-inputs' style={{ marginTop: '1rem', marginBottom: '1rem' }}>
|
|
401
|
+
<div className='cove-accordion__panel-col'>
|
|
402
|
+
<InputText type='number' value={config.nodeWidth} fieldName='nodeWidth' label='Width' updateField={updateField} />
|
|
403
|
+
</div>
|
|
404
|
+
<div className='cove-accordion__panel-col'>
|
|
405
|
+
<InputText type='number' value={config.nodeSpacer} fieldName='nodeSpacer' label='Spacer' updateField={updateField} />
|
|
406
|
+
</div>
|
|
387
407
|
</div>
|
|
388
|
-
|
|
408
|
+
)}
|
|
389
409
|
|
|
390
|
-
<div className='cove-input-group'>
|
|
391
|
-
<InputSelect value={config.orientation} fieldName='orientation' label='Layout' updateField={updateField} className='cove-input' options={['horizontal', 'vertical']} />
|
|
392
|
-
</div>
|
|
410
|
+
<div className='cove-input-group'>{config.visualizationType !== 'Gauge' && <InputSelect value={config.orientation} fieldName='orientation' label='Layout' updateField={updateField} className='cove-input' options={['horizontal', 'vertical']} />}</div>
|
|
393
411
|
|
|
394
412
|
<div className='cove-input-group'>
|
|
395
413
|
<label>
|
|
@@ -400,7 +418,7 @@ const EditorPanel = memo(props => {
|
|
|
400
418
|
<InputText type='number' value={config.fontSize} fieldName='fontSize' updateField={updateField} />
|
|
401
419
|
</div>
|
|
402
420
|
<div className='cove-accordion__panel-col' style={{ display: 'flex', alignItems: 'center' }}>
|
|
403
|
-
<label className='accordion__panel-label--muted'>default (50px)</label>
|
|
421
|
+
<label className='accordion__panel-label--muted'> {config.visualizationType === 'Gauge' ? ' default (16px)' : ' default (50px)'}</label>
|
|
404
422
|
</div>
|
|
405
423
|
</div>
|
|
406
424
|
</div>
|
|
@@ -444,7 +462,7 @@ const EditorPanel = memo(props => {
|
|
|
444
462
|
<button className={`cove-editor--toggle` + (!displayPanel ? ` collapsed` : ``)} title={displayPanel ? `Collapse Editor` : `Expand Editor`} onClick={onBackClick} />
|
|
445
463
|
<section className={`cove-editor__panel` + (displayPanel ? `` : ' hidden')}>
|
|
446
464
|
<div className='cove-editor__panel-container'>
|
|
447
|
-
<h2 className='cove-editor__heading'>Configure
|
|
465
|
+
<h2 className='cove-editor__heading'>Configure Chart</h2>
|
|
448
466
|
<section className='cove-editor__content'>{editorContent}</section>
|
|
449
467
|
</div>
|
|
450
468
|
</section>
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
title: '
|
|
2
|
+
title: 'Chart Title',
|
|
3
|
+
visualizationType: 'Waffle',
|
|
4
|
+
visualizationSubType: 'linear',
|
|
5
|
+
showPercent: true,
|
|
6
|
+
showDenominator: true,
|
|
7
|
+
valueDescription: 'out of',
|
|
3
8
|
content: '',
|
|
4
9
|
subtext: '',
|
|
5
10
|
orientation: 'horizontal',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"/></svg>
|
package/src/scss/main.scss
CHANGED
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
// }
|
|
19
19
|
//}
|
|
20
20
|
|
|
21
|
+
.warning-icon {
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: 50%;
|
|
24
|
+
left: 20%;
|
|
25
|
+
transform: translate(-50%, -50%);
|
|
26
|
+
color: red;
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
.cove {
|
|
22
30
|
&-editor__panel {
|
|
23
31
|
ul.color-palette {
|
|
@@ -25,6 +33,27 @@
|
|
|
25
33
|
}
|
|
26
34
|
}
|
|
27
35
|
|
|
36
|
+
.cove-gauge-chart {
|
|
37
|
+
&__chart {
|
|
38
|
+
width: 85%;
|
|
39
|
+
margin: 0 auto;
|
|
40
|
+
margin-left: auto;
|
|
41
|
+
height: auto;
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
justify-items: center;
|
|
45
|
+
align-items: flex-start;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&__subtext {
|
|
49
|
+
font-size: 0.75em;
|
|
50
|
+
}
|
|
51
|
+
&__text {
|
|
52
|
+
line-height: 1.25em;
|
|
53
|
+
width: 100%;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
28
57
|
.cove-waffle-chart {
|
|
29
58
|
display: flex;
|
|
30
59
|
flex-wrap: wrap;
|
|
@@ -54,7 +83,6 @@
|
|
|
54
83
|
}
|
|
55
84
|
|
|
56
85
|
.cove-waffle-chart__subtext {
|
|
57
|
-
font-style: italic;
|
|
58
86
|
font-size: 0.75em;
|
|
59
87
|
}
|
|
60
88
|
|
|
@@ -92,29 +120,38 @@
|
|
|
92
120
|
}
|
|
93
121
|
|
|
94
122
|
@at-root {
|
|
95
|
-
.cove-waffle-chart.font-small
|
|
96
|
-
|
|
123
|
+
.cove-waffle-chart.font-small,
|
|
124
|
+
.cove-gauge-chart.font-small #{&} {
|
|
125
|
+
.cove-waffle-chart__data--primary,
|
|
126
|
+
.cove-gauge-chart__data--primary {
|
|
97
127
|
font-size: 35px;
|
|
98
128
|
}
|
|
99
|
-
.cove-waffle-chart__data--text
|
|
129
|
+
.cove-waffle-chart__data--text,
|
|
130
|
+
.cove-gauge-chart__data--text {
|
|
100
131
|
font-size: 14px;
|
|
101
132
|
}
|
|
102
133
|
}
|
|
103
134
|
|
|
104
|
-
.cove-waffle-chart.font-medium
|
|
105
|
-
|
|
135
|
+
.cove-waffle-chart.font-medium,
|
|
136
|
+
.cove-gauge-chart.font-medium #{&} {
|
|
137
|
+
.cove-waffle-chart__data--primary,
|
|
138
|
+
.cove-gauge-chart__data--primary {
|
|
106
139
|
font-size: 50px;
|
|
107
140
|
}
|
|
108
|
-
.cove-waffle-chart__data--text
|
|
141
|
+
.cove-waffle-chart__data--text,
|
|
142
|
+
.cove-gauge-chart__data--text {
|
|
109
143
|
font-size: 18px;
|
|
110
144
|
}
|
|
111
145
|
}
|
|
112
146
|
|
|
113
|
-
.cove-waffle-chart.font-large
|
|
114
|
-
|
|
147
|
+
.cove-waffle-chart.font-large,
|
|
148
|
+
.cove-gauge-chart.font-large #{&} {
|
|
149
|
+
.cove-waffle-chart__data--primary,
|
|
150
|
+
.cove-gauge-chart__data--primary {
|
|
115
151
|
font-size: 80px;
|
|
116
152
|
}
|
|
117
|
-
.cove-waffle-chart__data--text
|
|
153
|
+
.cove-waffle-chart__data--text,
|
|
154
|
+
.cove-gauge-chart__data--text {
|
|
118
155
|
font-size: 20px;
|
|
119
156
|
}
|
|
120
157
|
}
|