@cdc/waffle-chart 4.25.8 → 4.25.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdc/waffle-chart",
3
- "version": "4.25.8",
3
+ "version": "4.25.11",
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,15 +27,23 @@
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.8",
30
+ "@cdc/core": "^4.25.11",
31
31
  "@visx/shape": "^3.12.0",
32
32
  "@visx/text": "^3.12.0",
33
33
  "chroma": "0.0.1",
34
- "react-accessible-accordion": "^5.0.1"
34
+ "html-react-parser": "5.2.3",
35
+ "react-accessible-accordion": "^5.0.1",
36
+ "resize-observer-polyfill": "^1.5.1"
35
37
  },
36
38
  "peerDependencies": {
37
39
  "react": "^18.2.0",
38
40
  "react-dom": "^18.2.0"
39
41
  },
40
- "gitHead": "e369994230b5e3facff224e1d89d5937528ac5a0"
42
+ "devDependencies": {
43
+ "@vitejs/plugin-react": "^4.3.4",
44
+ "vite": "^4.4.11",
45
+ "vite-plugin-css-injected-by-js": "^2.4.0",
46
+ "vite-plugin-svgr": "^2.4.0"
47
+ },
48
+ "gitHead": "5f09a137c22f454111ab5f4cd7fdf1d2d58e31bd"
41
49
  }
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect, useReducer, useState } from 'react'
1
+ import React, { useCallback, useEffect, useMemo, useReducer, useState } from 'react'
2
2
 
3
3
  // visx
4
4
  import { Circle, Bar } from '@visx/shape'
@@ -13,6 +13,7 @@ import ResizeObserver from 'resize-observer-polyfill'
13
13
  import { Config } from './types/Config'
14
14
  import getViewport from '@cdc/core/helpers/getViewport'
15
15
  import fetchRemoteData from '@cdc/core/helpers/fetchRemoteData'
16
+ import { DATA_OPERATORS } from '@cdc/core/helpers/constants'
16
17
 
17
18
  import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
18
19
  import Loading from '@cdc/core/components/Loading'
@@ -28,7 +29,6 @@ import useDataVizClasses from '@cdc/core/helpers/useDataVizClasses'
28
29
  import './scss/main.scss'
29
30
  import Title from '@cdc/core/components/ui/Title'
30
31
  import Layout from '@cdc/core/components/Layout'
31
- import { publishAnalyticsEvent } from '@cdc/core/helpers/metrics/helpers'
32
32
 
33
33
  type CdcWaffleChartProps = {
34
34
  configUrl?: string
@@ -68,7 +68,7 @@ const WaffleChart = ({ config, isEditor, link = '', showConfigConfirm, updateCon
68
68
  const gaugeColor = config.visual.colors[config.theme]
69
69
  let dataFontSize = config.fontSize ? { fontSize: config.fontSize + 'px' } : null
70
70
 
71
- const calculateData = useCallback(() => {
71
+ const [dataPercentage, waffleDenominator, waffleNumerator] = useMemo(() => {
72
72
  //If either the column or function aren't set, do not calculate
73
73
  if (!dataColumn || !dataFunction) {
74
74
  return ''
@@ -240,22 +240,20 @@ const WaffleChart = ({ config, isEditor, link = '', showConfigConfirm, updateCon
240
240
  applyPrecision(waffleNumerator)
241
241
  ]
242
242
  }, [
243
- dataColumn,
244
- dataFunction,
245
243
  config.data,
246
244
  filters,
245
+ dataColumn,
246
+ dataFunction,
247
247
  dataConditionalColumn,
248
248
  dataConditionalOperator,
249
249
  dataConditionalComparate,
250
250
  customDenom,
251
+ dataDenom,
251
252
  dataDenomColumn,
252
253
  dataDenomFunction,
253
- roundToPlace,
254
- dataDenom
254
+ roundToPlace
255
255
  ])
256
256
 
257
- const [dataPercentage, waffleDenominator, waffleNumerator] = calculateData()
258
-
259
257
  const buildWaffle = useCallback(() => {
260
258
  let waffleData = []
261
259
  let nodeWidthNum = parseInt(nodeWidth, 10)
@@ -509,7 +507,6 @@ const CdcWaffleChart = ({
509
507
  useEffect(() => {
510
508
  if (config && !coveLoadedHasRan && container) {
511
509
  publish('cove_loaded', { config: config })
512
- publishAnalyticsEvent('waffle-chart_loaded', 'load', interactionLabel, 'waffle-chart')
513
510
  dispatch({ type: 'SET_COVE_LOADED_HAS_RAN', payload: true })
514
511
  }
515
512
  }, [config, container])
@@ -581,18 +578,5 @@ export const DATA_FUNCTIONS = [
581
578
  DATA_FUNCTION_SUM
582
579
  ]
583
580
 
584
- export const DATA_OPERATOR_LESS = '<'
585
- export const DATA_OPERATOR_GREATER = '>'
586
- export const DATA_OPERATOR_LESSEQUAL = '<='
587
- export const DATA_OPERATOR_GREATEREQUAL = '>='
588
- export const DATA_OPERATOR_EQUAL = '='
589
- export const DATA_OPERATOR_NOTEQUAL = '≠'
590
-
591
- export const DATA_OPERATORS = [
592
- DATA_OPERATOR_LESS,
593
- DATA_OPERATOR_GREATER,
594
- DATA_OPERATOR_LESSEQUAL,
595
- DATA_OPERATOR_GREATEREQUAL,
596
- DATA_OPERATOR_EQUAL,
597
- DATA_OPERATOR_NOTEQUAL
598
- ]
581
+ // Re-export DATA_OPERATORS for backward compatibility
582
+ export { DATA_OPERATORS }