From d737b0ef8e7325cd1daec4659a0f363902f37f69 Mon Sep 17 00:00:00 2001 From: Monroe <35408073+Mgetz10@users.noreply.github.com> Date: Fri, 20 Dec 2024 13:25:56 -0500 Subject: [PATCH 01/13] Fix [Auto Padding] insufficient auto padding added (#1793) * fix: if auto padding is too close to next tick, add one more ticks worth of padding * remove comment * fix: cleaner dif * fix: add 0.1 to tip it over the edge * fix: bump up padding threshold * fix: bump again * fix: remove log --- packages/chart/src/components/LinearChart.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/chart/src/components/LinearChart.tsx b/packages/chart/src/components/LinearChart.tsx index b500d161a..3f421f970 100644 --- a/packages/chart/src/components/LinearChart.tsx +++ b/packages/chart/src/components/LinearChart.tsx @@ -410,6 +410,7 @@ const LinearChart = forwardRef(({ parentHeight, p useEffect(() => { if (lastMaxValue.current === maxValue) return lastMaxValue.current = maxValue + if (!yAxisAutoPadding) return setYAxisAutoPadding(0) }, [maxValue]) @@ -422,9 +423,17 @@ const LinearChart = forwardRef(({ parentHeight, p const tickGap = yScale.ticks(handleNumTicks)[1] - yScale.ticks(handleNumTicks)[0] const nextTick = Math.max(...yScale.ticks(handleNumTicks)) + tickGap - const newPadding = minValue < 0 ? (nextTick - maxValue) / maxValue / 2 : (nextTick - maxValue) / maxValue + const divideBy = minValue < 0 ? maxValue / 2 : maxValue + const calculatedPadding = (nextTick - maxValue) / divideBy + + // if auto padding is too close to next tick, add one more ticks worth of padding + const PADDING_THRESHOLD = 0.025 + const newPadding = + calculatedPadding > PADDING_THRESHOLD ? calculatedPadding : calculatedPadding + tickGap / divideBy - setYAxisAutoPadding(newPadding * 100) + /* sometimes even though the padding is getting to the next tick exactly, + d3 still doesn't show the tick. we add 0.1 to ensure to tip it over the edge */ + setYAxisAutoPadding(newPadding * 100 + 0.1) }, [maxValue, labelsOverflow, yScale, handleNumTicks]) // Render Functions @@ -433,7 +442,7 @@ const LinearChart = forwardRef(({ parentHeight, p const getTickPositions = (ticks, xScale) => { if (!ticks.length) return false - // filterout first index + // filter out first index const filteredTicks = ticks.filter(tick => tick.index !== 0) const numberOfTicks = filteredTicks?.length const xMaxHalf = xScale.range()[0] || xMax / 2 From 8312e413880a9cfa0b9b944406f8e7a6993455ff Mon Sep 17 00:00:00 2001 From: Monroe <35408073+Mgetz10@users.noreply.github.com> Date: Mon, 23 Dec 2024 15:17:37 -0500 Subject: [PATCH 02/13] fix [no ticket] auto padding breaking when only one tick (#1795) --- packages/chart/src/components/LinearChart.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/chart/src/components/LinearChart.tsx b/packages/chart/src/components/LinearChart.tsx index 3f421f970..2c770057d 100644 --- a/packages/chart/src/components/LinearChart.tsx +++ b/packages/chart/src/components/LinearChart.tsx @@ -420,8 +420,8 @@ const LinearChart = forwardRef(({ parentHeight, p const maxValueIsGreaterThanTopGridLine = maxValue > Math.max(...yScale.ticks(handleNumTicks)) if (!maxValueIsGreaterThanTopGridLine || !labelsOverflow) return - - const tickGap = yScale.ticks(handleNumTicks)[1] - yScale.ticks(handleNumTicks)[0] + const ticks = yScale.ticks(handleNumTicks) + const tickGap = ticks.length === 1 ? ticks[0] : ticks[1] - ticks[0] const nextTick = Math.max(...yScale.ticks(handleNumTicks)) + tickGap const divideBy = minValue < 0 ? maxValue / 2 : maxValue const calculatedPadding = (nextTick - maxValue) / divideBy From 3cd61aebdb118f27287c8e58696e7ea3b1dbf5af Mon Sep 17 00:00:00 2001 From: Josh Lacey Date: Tue, 24 Dec 2024 11:41:21 -0500 Subject: [PATCH 03/13] enhancement dev-9990 filter order column (#1796) --- .../EditorPanel/VizFilterEditor/VizFilterEditor.tsx | 11 +++++++++++ packages/core/components/Filters/Filters.tsx | 3 ++- .../core/components/Filters/helpers/handleSorting.ts | 5 +++++ packages/core/helpers/addValuesToFilters.ts | 12 ++++++++++-- packages/core/types/VizFilter.ts | 3 ++- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/packages/core/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx b/packages/core/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx index c7b988a9b..ba8a7343e 100644 --- a/packages/core/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx +++ b/packages/core/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx @@ -241,6 +241,17 @@ const VizFilterEditor: React.FC = ({ config, updateField, rawDat handleFilterOrder={(index1, index2) => handleFilterOrder(index1, index2, filterIndex)} /> )} + {filter.order === 'column' && ( + { - setState({ - ...state, - filterBehavior: e.target.value - }) - }} - > - - - - - - {filtersJSX} - - ) - } - const removeAdditionalColumn = columnName => { const newColumns = state.columns @@ -1271,38 +1225,7 @@ const EditorPanel = ({ columnsRequiredChecker }) => { return true }) - const updateField = (section, subsection, fieldName, newValue) => { - if (!section) { - setState({ - ...state, - [fieldName]: newValue - }) - return - } - - const isArray = Array.isArray(state[section]) - - let sectionValue = isArray ? [...state[section], newValue] : { ...state[section], [fieldName]: newValue } - - if (null !== subsection) { - if (isArray) { - sectionValue = [...state[section]] - sectionValue[subsection] = { ...sectionValue[subsection], [fieldName]: newValue } - } else { - sectionValue = { - ...state[section], - [subsection]: { ...state[section][subsection], [fieldName]: newValue } - } - } - } - - let updatedState = { - ...state, - [section]: sectionValue - } - - setState(updatedState) - } + const updateField = updateFieldFactory(state, setState) const onBackClick = () => { setDisplayPanel(!displayPanel) @@ -1314,163 +1237,6 @@ const EditorPanel = ({ columnsRequiredChecker }) => { const usedFilterColumns = {} - const filtersJSX = state.filters.map((filter, index) => { - if (filter.type === 'url') return <> - - if (filter.columnName) { - usedFilterColumns[filter.columnName] = true - } - - return ( - <> -
- - - - - - - - - - - - - {filter.order === 'cust' && ( - - handleFilterOrder(source.index, destination?.index, index, state.filters?.[index]) - } - > - - {provided => ( -
    - {state.filters[index]?.values.map((value, index) => { - return ( - - {(provided, snapshot) => ( -
  • -
    - {value} -
    -
  • - )} -
    - ) - })} - {provided.placeholder} -
- )} -
-
- )} -
- - ) - }) - const StateOptionList = () => { const arrOfArrays = Object.entries(supportedStatesFipsCodes) @@ -2857,7 +2623,7 @@ const EditorPanel = ({ columnsRequiredChecker }) => { )} - {filtersJSX.length > 0 && ( + {state.filters.length > 0 && ( )} - {(filtersJSX.length > 0 || state.general.type === 'bubble' || state.general.geoType === 'us') && ( + {(state.filters.length > 0 || state.general.type === 'bubble' || state.general.geoType === 'us') && ( From a4dae3fd94c2cb2b9b188741b02c0c0f7aad3841 Mon Sep 17 00:00:00 2001 From: Matt-DiPaolo <125307923+Matt-DiPaolo@users.noreply.github.com> Date: Tue, 14 Jan 2025 11:41:08 -0500 Subject: [PATCH 08/13] PATCH FIX/dev-9866 Nested Dropdown filter availability - maps (#1835) * Fix/Dev-9866 Nested Dropdowns on Viz level Filters on Maps * patch-fix/dev-9866-nested-dropdown-maps Fixes * Fix/Dev-9866 * fix/dev-9866 excludedData removed * fix/dev-9866 Fixed comments * Fix/dev-9866 moved code out of filter.length loop --- packages/core/components/Filters/Filters.tsx | 2 +- packages/core/helpers/addValuesToFilters.ts | 12 ++++---- packages/core/helpers/filterVizData.ts | 4 +-- .../helpers/tests/addValuesToFilters.test.ts | 7 ++++- packages/map/src/CdcMap.tsx | 28 ++++++++++++------- 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/packages/core/components/Filters/Filters.tsx b/packages/core/components/Filters/Filters.tsx index 6c8f077c5..971f7b69b 100644 --- a/packages/core/components/Filters/Filters.tsx +++ b/packages/core/components/Filters/Filters.tsx @@ -125,7 +125,7 @@ export const useFilters = props => { queryParams[newFilter?.subGrouping?.setByQueryParameter] = newFilter.subGrouping.active updateQueryString(queryParams) } - setFilteredData(newFilters[index]) + setFilteredData(newFilters) } if (!visualizationConfig.dynamicSeries) { diff --git a/packages/core/helpers/addValuesToFilters.ts b/packages/core/helpers/addValuesToFilters.ts index 6715c3b04..e1e863d96 100644 --- a/packages/core/helpers/addValuesToFilters.ts +++ b/packages/core/helpers/addValuesToFilters.ts @@ -1,6 +1,7 @@ import _ from 'lodash' import { getQueryStringFilterValue } from '@cdc/core/helpers/queryStringUtils' import { VizFilter } from '../types/VizFilter' +import { FILTER_STYLE } from '@cdc/dashboard/src/types/FilterStyles' type Filter = { columnName: string @@ -80,7 +81,7 @@ const handleVizParents = (filter: VizFilter, data: any[] | MapData, filtersLooku let filteredData = Array.isArray(data) ? data : Object.values(data).flat(1) filter.parents.forEach(parentKey => { const parent = filtersLookup[parentKey] - if (parent?.filterStyle === 'nested-dropdown') { + if (parent?.filterStyle === FILTER_STYLE.nestedDropdown) { const { subGrouping } = parent as VizFilter if (subGrouping?.active) { filteredData = filteredData.filter(d => { @@ -115,11 +116,11 @@ export const addValuesToFilters = (filters: VizFilter[], data: any[] | MapData): filteredData = handleVizParents(filter as VizFilter, data, filtersLookup) } generateValuesForFilter(filterCopy, filteredData) - if (filterCopy.values.length > 0) { + if (filterCopy.values?.length > 0) { const queryStringFilterValue = getQueryStringFilterValue(filterCopy) if (queryStringFilterValue) { filterCopy.active = queryStringFilterValue - } else if (filterCopy.filterStyle === 'multi-select') { + } else if (filterCopy.filterStyle === FILTER_STYLE.multiSelect) { const defaultValues = filterCopy.values const active = Array.isArray(filterCopy.active) ? filterCopy.active : [filterCopy.active] filterCopy.active = active.filter(val => includes(defaultValues, val)) @@ -136,12 +137,11 @@ export const addValuesToFilters = (filters: VizFilter[], data: any[] | MapData): values: filterCopy.subGrouping.valuesLookup[groupName].values } const queryStringFilterValue = getQueryStringFilterValue(subGroupingFilter) - const groupActive = filterCopy.active || filterCopy.values[0] + const groupActive = groupName || filterCopy.values[0] const defaultValue = filterCopy.subGrouping.valuesLookup[groupActive as string].values[0] // if the value doesn't exist in the subGrouping then return the default - const filteredLookupValues = Object.values(filterCopy.subGrouping.valuesLookup).flatMap(v => v.values) const activeValue = queryStringFilterValue || filterCopy.subGrouping.active - filterCopy.subGrouping.active = filteredLookupValues.includes(activeValue) ? activeValue : defaultValue + filterCopy.subGrouping.active = activeValue || defaultValue } return filterCopy }) diff --git a/packages/core/helpers/filterVizData.ts b/packages/core/helpers/filterVizData.ts index ed2387c39..bd2d91910 100644 --- a/packages/core/helpers/filterVizData.ts +++ b/packages/core/helpers/filterVizData.ts @@ -36,9 +36,9 @@ export const filterVizData = (filters: Filter[], data) => { } if (filter.filterStyle === 'nested-dropdown' && filter.subGrouping && add === true) { const subGroupActive = filter.subGrouping.active - const value = row[filter.subGrouping.columnName] + const subGroupValue = row[filter.subGrouping.columnName] if (subGroupActive === undefined) return - if (value != subGroupActive) { + if (subGroupValue != subGroupActive) { add = false } } diff --git a/packages/core/helpers/tests/addValuesToFilters.test.ts b/packages/core/helpers/tests/addValuesToFilters.test.ts index 614f743a7..6d68874e4 100644 --- a/packages/core/helpers/tests/addValuesToFilters.test.ts +++ b/packages/core/helpers/tests/addValuesToFilters.test.ts @@ -2,6 +2,7 @@ import _ from 'lodash' import { VizFilter } from '../../types/VizFilter' import { addValuesToFilters } from '../addValuesToFilters' import { describe, it, expect, vi } from 'vitest' +import { FILTER_STYLE } from '@cdc/dashboard/src/types/FilterStyles' describe('addValuesToFilters', () => { const parentFilter = { columnName: 'parentColumn', id: 11, active: 'apple', values: [] } as VizFilter @@ -36,7 +37,11 @@ describe('addValuesToFilters', () => { //expect(newFilters[1].values).toEqual([]) }) it('works for nested dropdowns', () => { - const nestedParentFilter = { ...parentFilter, subGrouping: { columnName: 'childColumn' } } + const nestedParentFilter = { + ...parentFilter, + filterStyle: FILTER_STYLE.nestedDropdown, + subGrouping: { columnName: 'childColumn' } + } const newFilters = addValuesToFilters([nestedParentFilter], data) expect(newFilters[0].values).toEqual(['apple', 'pear']) expect(newFilters[0].subGrouping.valuesLookup).toEqual({ apple: { values: ['a', 'b'] }, pear: { values: ['c'] } }) diff --git a/packages/map/src/CdcMap.tsx b/packages/map/src/CdcMap.tsx index 825df8e77..7542745cc 100644 --- a/packages/map/src/CdcMap.tsx +++ b/packages/map/src/CdcMap.tsx @@ -78,6 +78,7 @@ import useTooltip from './hooks/useTooltip' import { isSolrCsv, isSolrJson } from '@cdc/core/helpers/isSolr' import SkipTo from '@cdc/core/components/elements/SkipTo' import { getGeoFillColor } from './helpers/colors' +import { SubGrouping } from '@cdc/core/types/VizFilter' // Data props const stateKeys = Object.keys(supportedStates) @@ -358,7 +359,7 @@ const CdcMap = ({ }) // eslint-disable-next-line - const generateRuntimeLegend = useCallback((obj, runtimeData, hash) => { + const generateRuntimeLegend = useCallback((obj, runtimeFilters, hash) => { const newLegendMemo = new Map() // Reset memoization const newLegendSpecialClassLastMemo = new Map() // Reset bin memoization let primaryCol = obj.columns.primary.name, @@ -373,7 +374,7 @@ const CdcMap = ({ result.fromHash = hash } - result.runtimeDataHash = runtimeData.fromHash + result.runtimeDataHash = runtimeFilters?.fromHash // Unified will based the legend off ALL of the data maps received. Otherwise, it will use let dataSet = obj.legend.unified ? obj.data : Object.values(runtimeData) @@ -810,7 +811,7 @@ const CdcMap = ({ legendMemo.current = newLegendMemo if (state.general.geoType === 'world') { - const runtimeDataKeys = Object.keys(runtimeData) + const runtimeDataKeys = Object.keys(runtimeFilters) const isCountriesWithNoDataState = obj.data === undefined ? false : !countryKeys.every(countryKey => runtimeDataKeys.includes(countryKey)) @@ -920,6 +921,7 @@ const CdcMap = ({ newFilter.active = active ?? values[0] // Default to first found value newFilter.filterStyle = obj.filters[idx].filterStyle ? obj.filters[idx].filterStyle : 'dropdown' newFilter.showDropdown = showDropdown + newFilter.subGrouping = obj.filters[idx].subGrouping || {} filters.push(newFilter) } @@ -968,17 +970,23 @@ const CdcMap = ({ // Filters if (filters?.length) { for (let i = 0; i < filters.length; i++) { - const { columnName, active, type } = filters[i] - if (type !== 'url' && String(row[columnName]) !== String(active)) return false // Bail out, not part of filter + const { columnName, active, type, filterStyle, subGrouping } = filters[i] + const isDataFilter = type !== 'url' + const matchingValue = String(active) === String(row[columnName]) // Group + if (isDataFilter && !matchingValue) return false // Bail out, data doesn't match the filter selection + if (filterStyle == 'nested-dropdown') { + const matchingSubValue = String(row[subGrouping?.columnName]) === String(subGrouping?.active) + if (subGrouping?.active && !matchingSubValue) { + return false // Bail out, data doesn't match the subgroup selection + } + } } } - // Don't add additional rows with same UID - if (undefined === result[row.uid]) { + if (result[row.uid] === undefined) { result[row.uid] = row } }) - return result } catch (e) { console.error('COVE: ', e) // eslint-disable-line @@ -1593,12 +1601,12 @@ const CdcMap = ({ }) // Data - if (hashData !== runtimeData.fromHash && state.data?.fromColumn) { + if (hashData !== runtimeData?.fromHash && state.data?.fromColumn) { const newRuntimeData = generateRuntimeData(state, filters || runtimeFilters, hashData) setRuntimeData(newRuntimeData) } else { - if (hashLegend !== runtimeLegend.fromHash && undefined === runtimeData.init) { + if (hashLegend !== runtimeLegend?.fromHash && undefined === runtimeData.init) { const legend = generateRuntimeLegend(state, runtimeData, hashLegend) setRuntimeLegend(legend) } From 80ffe5b862080e893817e27d68d37018f506cdbb Mon Sep 17 00:00:00 2001 From: Josh Lacey Date: Tue, 14 Jan 2025 12:04:18 -0500 Subject: [PATCH 09/13] [DEV-10201] fix: map viz filters (#1834) --- .../DataTable/DataTableStandAlone.tsx | 6 ++-- packages/core/components/Filters/Filters.tsx | 2 -- packages/core/helpers/addValuesToFilters.ts | 6 ++++ packages/map/src/CdcMap.tsx | 34 ++++++++----------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/core/components/DataTable/DataTableStandAlone.tsx b/packages/core/components/DataTable/DataTableStandAlone.tsx index 29e526d71..6a519df35 100644 --- a/packages/core/components/DataTable/DataTableStandAlone.tsx +++ b/packages/core/components/DataTable/DataTableStandAlone.tsx @@ -6,6 +6,7 @@ import DataTableEditorPanel from './components/DataTableEditorPanel' import Filters from '../Filters' import { TableConfig } from './types/TableConfig' import { filterVizData } from '../../helpers/filterVizData' +import { addValuesToFilters } from '../../helpers/addValuesToFilters' type StandAloneProps = { visualizationKey: string @@ -28,9 +29,8 @@ const DataTableStandAlone: React.FC = ({ useEffect(() => { // when using editor changes to filter should update the data - setFilteredData( - filterVizData(config.filters, config?.formattedData?.length > 0 ? config.formattedData : config.data) - ) + const filters = addValuesToFilters(config.filters, config.data) + setFilteredData(filterVizData(filters, config?.formattedData?.length > 0 ? config.formattedData : config.data)) }, [config.filters]) if (isEditor) diff --git a/packages/core/components/Filters/Filters.tsx b/packages/core/components/Filters/Filters.tsx index 971f7b69b..7ba1837ac 100644 --- a/packages/core/components/Filters/Filters.tsx +++ b/packages/core/components/Filters/Filters.tsx @@ -274,8 +274,6 @@ type FilterProps = { setFilteredData: Function // updating function for setting fitlerBehavior setConfig: Function - // exclusions - exclusions: any[] standaloneMap?: boolean } diff --git a/packages/core/helpers/addValuesToFilters.ts b/packages/core/helpers/addValuesToFilters.ts index e1e863d96..75ede9b4e 100644 --- a/packages/core/helpers/addValuesToFilters.ts +++ b/packages/core/helpers/addValuesToFilters.ts @@ -69,6 +69,12 @@ const generateValuesForFilter = (filter: VizFilter, data: any[] | MapData) => { } if (orderColumn) { filter.values = valuesWithOrders.sort((a, b) => a[1].localeCompare(b[1])).map(([value]) => value) + } else if (filter.order && filter.order !== 'cust') { + const sort = (a, b) => { + const asc = filter.order !== 'desc' + return String(asc ? a : b).localeCompare(String(asc ? b : a), 'en', { numeric: true }) + } + filter.values = values.sort(sort) } else { filter.values = values } diff --git a/packages/map/src/CdcMap.tsx b/packages/map/src/CdcMap.tsx index 7542745cc..639e10bcf 100644 --- a/packages/map/src/CdcMap.tsx +++ b/packages/map/src/CdcMap.tsx @@ -119,10 +119,17 @@ const CdcMap = ({ const [loading, setLoading] = useState(true) const [displayPanel, setDisplayPanel] = useState(true) const [currentViewport, setCurrentViewport] = useState('lg') - const [topoData, setTopoData] = useState({}) + const [topoData, setTopoData] = useState<{}>({}) const [runtimeFilters, setRuntimeFilters] = useState([]) - const [runtimeLegend, setRuntimeLegend] = useState([]) const [runtimeData, setRuntimeData] = useState({ init: true }) + const _setRuntimeData = (data: any) => { + if (config) { + setRuntimeData(data) + } else { + setRuntimeFilters(data) + } + } + const [runtimeLegend, setRuntimeLegend] = useState([]) const [stateToShow, setStateToShow] = useState(null) const [modal, setModal] = useState(null) const [accessibleStatus, setAccessibleStatus] = useState('') @@ -876,32 +883,21 @@ const CdcMap = ({ ) => { let newFilter = runtimeFilters[idx] - const sortAsc = (a, b) => { - return a.toString().localeCompare(b.toString(), 'en', { numeric: true }) - } - - const sortDesc = (a, b) => { - return b.toString().localeCompare(a.toString(), 'en', { numeric: true }) + const sort = (a, b) => { + const asc = obj.filters[idx].order !== 'desc' + return String(asc ? a : b).localeCompare(String(asc ? b : a), 'en', { numeric: true }) } if (type !== 'url') { values = getUniqueValues(state.data, columnName) - if (obj.filters[idx].order === 'asc') { - values = values.sort(sortAsc) - } - - if (obj.filters[idx].order === 'desc') { - values = values.sort(sortDesc) - } - if (obj.filters[idx].order === 'cust') { if (obj.filters[idx]?.values.length > 0) { values = obj.filters[idx].values } + } else { + values = values.sort(sort) } - } else { - values = values } if (undefined === newFilter) { @@ -1819,7 +1815,7 @@ const CdcMap = ({ config={state} setConfig={setState} filteredData={runtimeFilters} - setFilteredData={setRuntimeFilters} + setFilteredData={_setRuntimeData} dimensions={dimensions} standaloneMap={!config} /> From ba84fcae7d03291df9deba7b11adf42f6738a256 Mon Sep 17 00:00:00 2001 From: Josh Lacey Date: Wed, 15 Jan 2025 10:56:11 -0500 Subject: [PATCH 10/13] Patch fix/dev-10201 debug (#1836) * patch fix debugging dev-10201 * patch fix debugging dev-10201 --- packages/map/src/CdcMap.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/map/src/CdcMap.tsx b/packages/map/src/CdcMap.tsx index 639e10bcf..85b3ed7e9 100644 --- a/packages/map/src/CdcMap.tsx +++ b/packages/map/src/CdcMap.tsx @@ -917,7 +917,7 @@ const CdcMap = ({ newFilter.active = active ?? values[0] // Default to first found value newFilter.filterStyle = obj.filters[idx].filterStyle ? obj.filters[idx].filterStyle : 'dropdown' newFilter.showDropdown = showDropdown - newFilter.subGrouping = obj.filters[idx].subGrouping || {} + newFilter.subGrouping = obj.filters[idx].subGrouping filters.push(newFilter) } @@ -1568,7 +1568,7 @@ const CdcMap = ({ const hashFilters = hashObj(state.filters) let filters - if (state.filters && hashFilters !== runtimeFilters.fromHash) { + if (state.filters && (config || hashFilters !== runtimeFilters.fromHash)) { filters = generateRuntimeFilters(state, hashFilters, runtimeFilters) if (filters) { From 649293e07b7c7e127f853f5cc8b8df4d216f0871 Mon Sep 17 00:00:00 2001 From: Adam Doe <17502761+adamdoe@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:09:55 -0800 Subject: [PATCH 11/13] update default filters --- packages/core/helpers/coveUpdateWorker.ts | 2 +- packages/core/helpers/ver/4.24.10.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/core/helpers/coveUpdateWorker.ts b/packages/core/helpers/coveUpdateWorker.ts index b346a1cca..4408b2b38 100644 --- a/packages/core/helpers/coveUpdateWorker.ts +++ b/packages/core/helpers/coveUpdateWorker.ts @@ -20,7 +20,7 @@ export const coveUpdateWorker = config => { ['4.24.5', update_4_24_5], ['4.24.7', update_4_24_7, true], ['4.24.9', update_4_24_9], - ['4.24.10', update_4_24_10] + ['4.24.10', update_4_24_10, true] ] versions.forEach(([version, updateFunction, alwaysRun]: [string, UpdateFunction, boolean?]) => { diff --git a/packages/core/helpers/ver/4.24.10.ts b/packages/core/helpers/ver/4.24.10.ts index a6aebe76f..ad5c6717b 100644 --- a/packages/core/helpers/ver/4.24.10.ts +++ b/packages/core/helpers/ver/4.24.10.ts @@ -34,12 +34,24 @@ export const setXAxisLabelOffsetToZero = newConfig => { newConfig.xAxis.labelOffset = 0 } +export const defineFilterStyles = newConfig => { + if (newConfig.filters) { + newConfig.filters = newConfig.filters.map(filter => { + if (!filter.filterStyle) { + filter.filterStyle = 'dropdown' + } + return filter + }) + } +} + const update_4_24_10 = config => { const ver = '4.24.10' const newConfig = _.cloneDeep(config) setXAxisLabelOffsetToZero(newConfig) changePivotColumns(newConfig) removeMultiSelectPropFromMultiselect(newConfig) + defineFilterStyles(newConfig) newConfig.version = ver return newConfig } From 9c70676ff0a88a8d5d2e148dd7c674115c1ad691 Mon Sep 17 00:00:00 2001 From: Adam Doe <17502761+adamdoe@users.noreply.github.com> Date: Wed, 15 Jan 2025 11:42:02 -0800 Subject: [PATCH 12/13] patch theme --- packages/map/src/CdcMap.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/map/src/CdcMap.tsx b/packages/map/src/CdcMap.tsx index 85b3ed7e9..f0827c500 100644 --- a/packages/map/src/CdcMap.tsx +++ b/packages/map/src/CdcMap.tsx @@ -1770,7 +1770,12 @@ const CdcMap = ({ ) const sectionClassNames = () => { - const classes = ['cove-component__content', 'cdc-map-inner-container', `${currentViewport}`] + const classes = [ + 'cove-component__content', + 'cdc-map-inner-container', + `${currentViewport}`, + `${state?.general?.headerColor}` + ] if (config?.runtime?.editorErrorMessage.length > 0) classes.push('type-map--has-error') return classes.join(' ') } From 9e9405ebbb10f6303f48246eacddd5c11b75ebd4 Mon Sep 17 00:00:00 2001 From: Adam Doe <17502761+adamdoe@users.noreply.github.com> Date: Thu, 16 Jan 2025 12:19:34 -0800 Subject: [PATCH 13/13] resolve hatch issue --- .../UsaMap/components/Territory/Territory.Rectangle.tsx | 6 +++--- .../map/src/components/UsaMap/components/UsaMap.State.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/map/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx b/packages/map/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx index dc58769ac..3e17a167d 100644 --- a/packages/map/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx +++ b/packages/map/src/components/UsaMap/components/Territory/Territory.Rectangle.tsx @@ -54,7 +54,7 @@ const TerritoryRectangle: React.FC = ({ {state.map.patterns.map((patternData, patternIndex) => { const patternColor = patternData.color || getContrastColor('#FFF', backgroundColor) - const hasMatchingValues = patternData.dataValue === territoryData[patternData.dataKey] + const hasMatchingValues = patternData.dataValue === territoryData?.[patternData.dataKey] if (!hasMatchingValues) return null if (!patternData.pattern) return null @@ -96,8 +96,8 @@ const TerritoryRectangle: React.FC = ({ fill={`url(#territory-${territory}-${patternData?.dataKey}--${patternIndex})`} color={patternData ? 'white' : textColor} className={[ - `territory-pattern-${patternData.dataKey}`, - `territory-pattern-${patternData.dataKey}--${patternData.dataValue}` + `territory-pattern-${patternData?.dataKey}`, + `territory-pattern-${patternData?.dataKey}--${patternData.dataValue}` ].join(' ')} /> { {map.patterns.map((patternData, patternIndex) => { const { pattern, dataKey, size } = patternData const currentFill = styles.fill - const hasMatchingValues = patternData.dataValue === geoData[patternData.dataKey] + const hasMatchingValues = patternData.dataValue === geoData?.[patternData.dataKey] const patternColor = patternData.color || getContrastColor('#000', currentFill) if (!hasMatchingValues) return