@cdc/waffle-chart 4.25.3-6 → 4.25.5-1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdc/waffle-chart",
3
- "version": "4.25.3-6",
3
+ "version": "4.25.5-1",
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",
@@ -27,20 +27,15 @@
27
27
  "license": "Apache-2.0",
28
28
  "homepage": "https://github.com/CDCgov/cdc-open-viz#readme",
29
29
  "dependencies": {
30
- "@cdc/core": "^4.25.3-6",
31
- "@visx/group": "^3.0.0",
32
- "@visx/scale": "^3.0.0",
30
+ "@cdc/core": "^4.25.5-1",
33
31
  "@visx/shape": "^3.0.0",
34
32
  "@visx/text": "^3.0.0",
35
33
  "chroma": "0.0.1",
36
- "chroma-js": "^2.1.0",
37
- "html-react-parser": "^3.0.8",
38
- "react-accessible-accordion": "^3.3.4",
39
- "whatwg-fetch": "^3.6.2"
34
+ "react-accessible-accordion": "^3.3.4"
40
35
  },
41
36
  "peerDependencies": {
42
37
  "react": "^18.2.0",
43
38
  "react-dom": "^18.2.0"
44
39
  },
45
- "gitHead": "d83d8555c1500ff0cad9d2c5c3486324afa15ec6"
40
+ "gitHead": "1d0a6e716bc113e6bea3636fcae90ebf2d19bb5c"
46
41
  }
@@ -360,7 +360,12 @@ const WaffleChart = ({ config, isEditor, link = '', showConfigConfirm, updateCon
360
360
 
361
361
  return (
362
362
  <div className='cove-component__content'>
363
- <Title title={title} config={config} classes={['chart-title', `${config.theme}`, 'mb-0']} />
363
+ <Title
364
+ showTitle={config.showTitle}
365
+ title={title}
366
+ config={config}
367
+ classes={['chart-title', `${config.theme}`, 'mb-0']}
368
+ />
364
369
  <div className={contentClasses.join(' ')}>
365
370
  {!config.newViz && config.runtime && config.runtime.editorErrorMessage && (
366
371
  <Error updateConfig={updateConfig} config={config} />
@@ -1,5 +1,6 @@
1
1
  import React, { useState, useEffect, memo, useContext } from 'react'
2
2
 
3
+ import _ from 'lodash'
3
4
  import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
4
5
 
5
6
  import ConfigContext from '../ConfigContext'
@@ -19,23 +20,37 @@ import WarningImage from '../images/warning.svg'
19
20
 
20
21
  import { DATA_OPERATORS, DATA_FUNCTIONS } from '../CdcWaffleChart'
21
22
 
22
- const headerColors = ['theme-blue', 'theme-purple', 'theme-brown', 'theme-teal', 'theme-pink', 'theme-orange', 'theme-slate', 'theme-indigo', 'theme-cyan', 'theme-green', 'theme-amber']
23
-
24
- const CheckBox = memo(({ label, value, fieldName, section = null, subsection = null, tooltip, updateField, ...attributes }) => (
25
- <label className='checkbox'>
26
- <input
27
- type='checkbox'
28
- name={fieldName}
29
- checked={value}
30
- onChange={() => {
31
- updateField(section, subsection, fieldName, !value)
32
- }}
33
- {...attributes}
34
- />
35
- <span className='edit-label column-heading'>{label}</span>
36
- <span className='cove-icon'>{tooltip}</span>
37
- </label>
38
- ))
23
+ const headerColors = [
24
+ 'theme-blue',
25
+ 'theme-purple',
26
+ 'theme-brown',
27
+ 'theme-teal',
28
+ 'theme-pink',
29
+ 'theme-orange',
30
+ 'theme-slate',
31
+ 'theme-indigo',
32
+ 'theme-cyan',
33
+ 'theme-green',
34
+ 'theme-amber'
35
+ ]
36
+
37
+ const CheckBox = memo(
38
+ ({ label, value, fieldName, section = null, subsection = null, tooltip, updateField, ...attributes }) => (
39
+ <label className='checkbox'>
40
+ <input
41
+ type='checkbox'
42
+ name={fieldName}
43
+ checked={value}
44
+ onChange={() => {
45
+ updateField(section, subsection, fieldName, !value)
46
+ }}
47
+ {...attributes}
48
+ />
49
+ <span className='edit-label column-heading'>{label}</span>
50
+ <span className='cove-icon'>{tooltip}</span>
51
+ </label>
52
+ )
53
+ )
39
54
 
40
55
  const EditorPanel = memo(props => {
41
56
  const { config, updateConfig, loading, data, setParentConfig, isDashboard } = useContext(ConfigContext)
@@ -93,7 +108,7 @@ const EditorPanel = memo(props => {
93
108
  }
94
109
 
95
110
  const convertStateToConfig = () => {
96
- let strippedState = JSON.parse(JSON.stringify(config))
111
+ let strippedState = _.cloneDeep(config)
97
112
  delete strippedState.newViz
98
113
  delete strippedState.runtime
99
114
 
@@ -148,11 +163,40 @@ const EditorPanel = memo(props => {
148
163
  <Accordion.Section title='General'>
149
164
  <div className='cove-accordion__panel-section'>
150
165
  <div style={{ width: '100%', display: 'block' }} className='cove-input-group'>
151
- <InputSelect value={config.visualizationType} fieldName='visualizationType' label='Chart Type' updateField={updateField} options={approvedWaffleChartOptions} className='cove-input' />
152
- {config.visualizationType === 'Gauge' && <InputSelect value={config.visualizationSubType} fieldName='visualizationSubType' label='Chart Subtype' updateField={updateField} options={['Linear']} className='cove-input' />}
166
+ <InputSelect
167
+ value={config.visualizationType}
168
+ fieldName='visualizationType'
169
+ label='Chart Type'
170
+ updateField={updateField}
171
+ options={approvedWaffleChartOptions}
172
+ className='cove-input'
173
+ />
174
+ {config.visualizationType === 'Gauge' && (
175
+ <InputSelect
176
+ value={config.visualizationSubType}
177
+ fieldName='visualizationSubType'
178
+ label='Chart Subtype'
179
+ updateField={updateField}
180
+ options={['Linear']}
181
+ className='cove-input'
182
+ />
183
+ )}
153
184
  </div>
154
185
  </div>
155
- <InputText value={config.title} fieldName='title' label='Title' placeholder='Chart Title' updateField={updateField} />
186
+ <InputText
187
+ value={config.title}
188
+ fieldName='title'
189
+ label='Title'
190
+ placeholder='Chart Title'
191
+ updateField={updateField}
192
+ />
193
+ <InputCheckbox
194
+ size='small'
195
+ label='show title'
196
+ value={config.showTitle}
197
+ fieldName='showTitle'
198
+ updateField={updateField}
199
+ />
156
200
  <InputText
157
201
  type='textarea'
158
202
  value={config.content}
@@ -165,7 +209,10 @@ const EditorPanel = memo(props => {
165
209
  <Icon display='question' style={{ marginLeft: '0.5rem' }} />
166
210
  </Tooltip.Target>
167
211
  <Tooltip.Content>
168
- <p>Enter the message text for the visualization. The following HTML tags are supported: strong, em, sup, and sub.</p>
212
+ <p>
213
+ Enter the message text for the visualization. The following HTML tags are supported: strong, em, sup,
214
+ and sub.
215
+ </p>
169
216
  </Tooltip.Content>
170
217
  </Tooltip>
171
218
  }
@@ -183,22 +230,46 @@ const EditorPanel = memo(props => {
183
230
  <Icon display='question' style={{ marginLeft: '0.5rem' }} />
184
231
  </Tooltip.Target>
185
232
  <Tooltip.Content>
186
- <p>Enter supporting text to display below the data visualization, if applicable. The following HTML tags are supported: strong, em, sup, and sub.</p>
233
+ <p>
234
+ Enter supporting text to display below the data visualization, if applicable. The following HTML tags
235
+ are supported: strong, em, sup, and sub.
236
+ </p>
187
237
  </Tooltip.Content>
188
238
  </Tooltip>
189
239
  }
190
240
  />
191
241
  </Accordion.Section>
192
242
 
193
- <Accordion.Section icon={!config.dataColumn || !config.dataFunction ? <WarningImage width='15' className='warning-icon' /> : ''} title='Data'>
243
+ <Accordion.Section
244
+ icon={!config.dataColumn || !config.dataFunction ? <WarningImage width='15' className='warning-icon' /> : ''}
245
+ title='Data'
246
+ >
194
247
  <h4 style={{ fontWeight: '600' }}>Numerator</h4>
195
248
  <div className='cove-accordion__panel-section'>
196
249
  <div className='cove-input-group'>
197
- <InputSelect style={inputSelectStyle(!config.dataColumn)} value={config.dataColumn || ''} fieldName='dataColumn' label='Data Column' updateField={updateField} initial='Select' options={getColumns()} className='cove-input' />
250
+ <InputSelect
251
+ style={inputSelectStyle(!config.dataColumn)}
252
+ value={config.dataColumn || ''}
253
+ fieldName='dataColumn'
254
+ label='Data Column'
255
+ updateField={updateField}
256
+ initial='Select'
257
+ options={getColumns()}
258
+ className='cove-input'
259
+ />
198
260
  </div>
199
261
 
200
262
  <div className='cove-input-group'>
201
- <InputSelect style={inputSelectStyle(!config.dataFunction)} value={config.dataFunction || ''} fieldName='dataFunction' label='Data Function' updateField={updateField} initial='Select' options={DATA_FUNCTIONS} className='cove-input' />
263
+ <InputSelect
264
+ style={inputSelectStyle(!config.dataFunction)}
265
+ value={config.dataFunction || ''}
266
+ fieldName='dataFunction'
267
+ label='Data Function'
268
+ updateField={updateField}
269
+ initial='Select'
270
+ options={DATA_FUNCTIONS}
271
+ className='cove-input'
272
+ />
202
273
  </div>
203
274
 
204
275
  <div className='cove-input-group'>
@@ -207,18 +278,42 @@ const EditorPanel = memo(props => {
207
278
  </label>
208
279
  <div className='cove-accordion__panel-row cove-accordion__small-inputs'>
209
280
  <div className='cove-accordion__panel-col'>
210
- <InputSelect value={config.dataConditionalColumn || ''} fieldName='dataConditionalColumn' updateField={updateField} initial='Select' options={getColumns()} className='cove-input' />
281
+ <InputSelect
282
+ value={config.dataConditionalColumn || ''}
283
+ fieldName='dataConditionalColumn'
284
+ updateField={updateField}
285
+ initial='Select'
286
+ options={getColumns()}
287
+ className='cove-input'
288
+ />
211
289
  </div>
212
290
  <div className='cove-accordion__panel-col'>
213
- <InputSelect value={config.dataConditionalOperator || ''} fieldName='dataConditionalOperator' updateField={updateField} initial='Select' options={DATA_OPERATORS} className='cove-input' />
291
+ <InputSelect
292
+ value={config.dataConditionalOperator || ''}
293
+ fieldName='dataConditionalOperator'
294
+ updateField={updateField}
295
+ initial='Select'
296
+ options={DATA_OPERATORS}
297
+ className='cove-input'
298
+ />
214
299
  </div>
215
300
  <div className='cove-accordion__panel-col'>
216
- <InputText value={config.dataConditionalComparate} fieldName={'dataConditionalComparate'} updateField={updateField} className={config.invalidComparate ? 'cove-accordion__input-error' : ''} style={{ minHeight: '2rem' }} />
301
+ <InputText
302
+ value={config.dataConditionalComparate}
303
+ fieldName={'dataConditionalComparate'}
304
+ updateField={updateField}
305
+ className={config.invalidComparate ? 'cove-accordion__input-error' : ''}
306
+ style={{ minHeight: '2rem' }}
307
+ />
217
308
  </div>
218
309
  </div>
219
310
  </div>
220
311
 
221
- {config.invalidComparate && <div className='cove-accordion__panel-error'>Non-numerical comparate values can only be used with = or ≠.</div>}
312
+ {config.invalidComparate && (
313
+ <div className='cove-accordion__panel-error'>
314
+ Non-numerical comparate values can only be used with = or ≠.
315
+ </div>
316
+ )}
222
317
  </div>
223
318
  <div className='cove-accordion__panel-row align-center'>
224
319
  <div className='cove-accordion__panel-col'>
@@ -227,7 +322,12 @@ const EditorPanel = memo(props => {
227
322
  <div className='cove-accordion__panel-col'>
228
323
  <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
229
324
  <label className='cove-accordion__panel-label--inline'>Select from data</label>
230
- <InputCheckbox size='small' value={config.customDenom} fieldName='customDenom' updateField={updateField} />
325
+ <InputCheckbox
326
+ size='small'
327
+ value={config.customDenom}
328
+ fieldName='customDenom'
329
+ updateField={updateField}
330
+ />
231
331
  </div>
232
332
  </div>
233
333
  </div>
@@ -244,8 +344,22 @@ const EditorPanel = memo(props => {
244
344
  )}
245
345
  {config.customDenom && (
246
346
  <>
247
- <InputSelect value={config.dataDenomColumn || ''} fieldName='dataDenomColumn' label='Data Column' updateField={updateField} initial='Select' options={getColumns()} />
248
- <InputSelect value={config.dataDenomFunction || ''} fieldName='dataDenomFunction' label='Data Function' updateField={updateField} initial='Select' options={DATA_FUNCTIONS} />
347
+ <InputSelect
348
+ value={config.dataDenomColumn || ''}
349
+ fieldName='dataDenomColumn'
350
+ label='Data Column'
351
+ updateField={updateField}
352
+ initial='Select'
353
+ options={getColumns()}
354
+ />
355
+ <InputSelect
356
+ value={config.dataDenomFunction || ''}
357
+ fieldName='dataDenomFunction'
358
+ label='Data Function'
359
+ updateField={updateField}
360
+ initial='Select'
361
+ options={DATA_FUNCTIONS}
362
+ />
249
363
  </>
250
364
  )}
251
365
  </div>
@@ -258,7 +372,13 @@ const EditorPanel = memo(props => {
258
372
  <InputText value={config.suffix} fieldName='suffix' label='Suffix' updateField={updateField} />
259
373
  </div>
260
374
  <div>
261
- <InputText type='number' value={config.roundToPlace} fieldName='roundToPlace' label='Round' updateField={updateField} />
375
+ <InputText
376
+ type='number'
377
+ value={config.roundToPlace}
378
+ fieldName='roundToPlace'
379
+ label='Round'
380
+ updateField={updateField}
381
+ />
262
382
  </div>
263
383
  </li>
264
384
  </ul>
@@ -266,9 +386,30 @@ const EditorPanel = memo(props => {
266
386
  <>
267
387
  <hr className='cove-accordion__divider' />
268
388
  <div className='cove-accordion__panel-section reverse-labels'>
269
- <InputText inline size='small' value={config.valueDescription} label='Value Descriptor' fieldName='valueDescription' updateField={updateField} />
270
- <InputCheckbox inline size='small' value={config.showPercent} label='Show Percentage' fieldName='showPercent' updateField={updateField} />
271
- <InputCheckbox inline size='small' label='Show Denominator' value={config.showDenominator} fieldName='showDenominator' updateField={updateField} />
389
+ <InputText
390
+ inline
391
+ size='small'
392
+ value={config.valueDescription}
393
+ label='Value Descriptor'
394
+ fieldName='valueDescription'
395
+ updateField={updateField}
396
+ />
397
+ <InputCheckbox
398
+ inline
399
+ size='small'
400
+ value={config.showPercent}
401
+ label='Show Percentage'
402
+ fieldName='showPercent'
403
+ updateField={updateField}
404
+ />
405
+ <InputCheckbox
406
+ inline
407
+ size='small'
408
+ label='Show Denominator'
409
+ value={config.showDenominator}
410
+ fieldName='showDenominator'
411
+ updateField={updateField}
412
+ />
272
413
  </div>
273
414
  </>
274
415
  )}
@@ -279,7 +420,10 @@ const EditorPanel = memo(props => {
279
420
  <Icon display='question' style={{ marginLeft: '0.5rem' }} />
280
421
  </Tooltip.Target>
281
422
  <Tooltip.Content>
282
- <p>To refine the highlighted data point, specify one or more filters (e.g., "Male" and "Female" for a column called "Sex").</p>
423
+ <p>
424
+ To refine the highlighted data point, specify one or more filters (e.g., "Male" and "Female" for a
425
+ column called "Sex").
426
+ </p>
283
427
  </Tooltip.Content>
284
428
  </Tooltip>
285
429
  </label>
@@ -338,19 +482,54 @@ const EditorPanel = memo(props => {
338
482
  </Button>
339
483
  </Accordion.Section>
340
484
  <Accordion.Section title='Visual'>
341
- {config.visualizationType !== 'Gauge' && <InputSelect value={config.shape} fieldName='shape' label='Shape' updateField={updateField} options={['circle', 'square', 'person']} className='cove-input' />}
342
485
  {config.visualizationType !== 'Gauge' && (
343
- <div className='cove-accordion__panel-row cove-accordion__small-inputs' style={{ marginTop: '1rem', marginBottom: '1rem' }}>
486
+ <InputSelect
487
+ value={config.shape}
488
+ fieldName='shape'
489
+ label='Shape'
490
+ updateField={updateField}
491
+ options={['circle', 'square', 'person']}
492
+ className='cove-input'
493
+ />
494
+ )}
495
+ {config.visualizationType !== 'Gauge' && (
496
+ <div
497
+ className='cove-accordion__panel-row cove-accordion__small-inputs'
498
+ style={{ marginTop: '1rem', marginBottom: '1rem' }}
499
+ >
344
500
  <div className='cove-accordion__panel-col'>
345
- <InputText type='number' value={config.nodeWidth} fieldName='nodeWidth' label='Width' updateField={updateField} />
501
+ <InputText
502
+ type='number'
503
+ value={config.nodeWidth}
504
+ fieldName='nodeWidth'
505
+ label='Width'
506
+ updateField={updateField}
507
+ />
346
508
  </div>
347
509
  <div className='cove-accordion__panel-col'>
348
- <InputText type='number' value={config.nodeSpacer} fieldName='nodeSpacer' label='Spacer' updateField={updateField} />
510
+ <InputText
511
+ type='number'
512
+ value={config.nodeSpacer}
513
+ fieldName='nodeSpacer'
514
+ label='Spacer'
515
+ updateField={updateField}
516
+ />
349
517
  </div>
350
518
  </div>
351
519
  )}
352
520
 
353
- <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>
521
+ <div className='cove-input-group'>
522
+ {config.visualizationType !== 'Gauge' && (
523
+ <InputSelect
524
+ value={config.orientation}
525
+ fieldName='orientation'
526
+ label='Layout'
527
+ updateField={updateField}
528
+ className='cove-input'
529
+ options={['horizontal', 'vertical']}
530
+ />
531
+ )}
532
+ </div>
354
533
 
355
534
  <div className='cove-input-group'>
356
535
  <label>
@@ -366,7 +545,14 @@ const EditorPanel = memo(props => {
366
545
  </div>
367
546
  </div>
368
547
 
369
- <InputSelect value={config.overallFontSize} fieldName='overallFontSize' label='Overall Font Size' updateField={updateField} options={['small', 'medium', 'large']} className='cove-input' />
548
+ <InputSelect
549
+ value={config.overallFontSize}
550
+ fieldName='overallFontSize'
551
+ label='Overall Font Size'
552
+ updateField={updateField}
553
+ options={['small', 'medium', 'large']}
554
+ className='cove-input'
555
+ />
370
556
 
371
557
  <label>
372
558
  <span className='edit-label cove-input__label'>Theme</span>
@@ -385,11 +571,48 @@ const EditorPanel = memo(props => {
385
571
  </label>
386
572
 
387
573
  <div className='cove-accordion__panel-section reverse-labels'>
388
- <InputCheckbox inline size='small' value={config.visual.border} section='visual' fieldName='border' label='Display Border' updateField={updateField} />
389
- <InputCheckbox inline size='small' value={config.visual.borderColorTheme} section='visual' fieldName='borderColorTheme' label='Use theme border color' updateField={updateField} />
390
- <InputCheckbox size='small' value={config.visual.accent} section='visual' fieldName='accent' label='Use Accent Style' updateField={updateField} />
391
- <InputCheckbox size='small' value={config.visual.background} section='visual' fieldName='background' label='Use Theme Background Color' updateField={updateField} />
392
- <InputCheckbox size='small' value={config.visual.hideBackgroundColor} section='visual' fieldName='hideBackgroundColor' label='Hide Background Color' updateField={updateField} />
574
+ <InputCheckbox
575
+ inline
576
+ size='small'
577
+ value={config.visual.border}
578
+ section='visual'
579
+ fieldName='border'
580
+ label='Display Border'
581
+ updateField={updateField}
582
+ />
583
+ <InputCheckbox
584
+ inline
585
+ size='small'
586
+ value={config.visual.borderColorTheme}
587
+ section='visual'
588
+ fieldName='borderColorTheme'
589
+ label='Use theme border color'
590
+ updateField={updateField}
591
+ />
592
+ <InputCheckbox
593
+ size='small'
594
+ value={config.visual.accent}
595
+ section='visual'
596
+ fieldName='accent'
597
+ label='Use Accent Style'
598
+ updateField={updateField}
599
+ />
600
+ <InputCheckbox
601
+ size='small'
602
+ value={config.visual.background}
603
+ section='visual'
604
+ fieldName='background'
605
+ label='Use Theme Background Color'
606
+ updateField={updateField}
607
+ />
608
+ <InputCheckbox
609
+ size='small'
610
+ value={config.visual.hideBackgroundColor}
611
+ section='visual'
612
+ fieldName='hideBackgroundColor'
613
+ label='Hide Background Color'
614
+ updateField={updateField}
615
+ />
393
616
  </div>
394
617
  </Accordion.Section>
395
618
  </Accordion>
@@ -400,7 +623,13 @@ const EditorPanel = memo(props => {
400
623
  return (
401
624
  <ErrorBoundary component='EditorPanel'>
402
625
  <>
403
- <Layout.Sidebar displayPanel={displayPanel} onBackClick={onBackClick} isDashboard={isDashboard} title='Configure Waffle Chart' showEditorPanel={displayPanel}>
626
+ <Layout.Sidebar
627
+ displayPanel={displayPanel}
628
+ onBackClick={onBackClick}
629
+ isDashboard={isDashboard}
630
+ title='Configure Waffle Chart'
631
+ showEditorPanel={displayPanel}
632
+ >
404
633
  {editorContent}
405
634
  </Layout.Sidebar>
406
635
  {props.children}
@@ -1,5 +1,6 @@
1
1
  export default {
2
2
  title: 'Chart Title',
3
+ showTitle: true,
3
4
  visualizationType: 'Waffle',
4
5
  visualizationSubType: 'linear',
5
6
  showPercent: true,
package/src/index.jsx CHANGED
@@ -1,11 +1,11 @@
1
1
  import React from 'react'
2
2
  import ReactDOM from 'react-dom/client'
3
3
 
4
- import CdcWaffleChart from './CdcWaffleChart'
5
-
6
4
  import '@cdc/core/styles/cove-main.scss'
7
5
  import './coreStyles_wafflechart.scss'
8
6
 
7
+ import CdcWaffleChart from './CdcWaffleChart'
8
+
9
9
  let isEditor = window.location.href.includes('editor=true')
10
10
 
11
11
  let domContainer = document.getElementsByClassName('react-container')[0]
@@ -33,6 +33,7 @@ export type Config = {
33
33
  suffix: string
34
34
  theme: ComponentThemes
35
35
  title: string
36
+ showTitle: boolean
36
37
  type: 'waffle-chart'
37
38
  valueDescription: string
38
39
  visual: ComponentStyles