Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[fix] Fixed synced filter domain and interval calculation (#2725)

Igor Dykhta8ea1cabe05a6
diff --git a/src/components/src/common/range-slider-timeline.tsx b/src/components/src/common/range-slider-timeline.tsx
index 30ee6bbc4..cb8db8c3c 100644
--- a/src/components/src/common/range-slider-timeline.tsx
+++ b/src/components/src/common/range-slider-timeline.tsx
@@ -25,7 +25,7 @@ const TIMELINE_MARKER_STYLE: CSSProperties = {
const containerStyle = {
display: 'flex',
width: '100%',
- height: '16px'
+ height: '24px'
};
const iconWrapperStyle = {
diff --git a/src/reducers/src/vis-state-updaters.ts b/src/reducers/src/vis-state-updaters.ts
index 69c1fe61d..c0cbd45e4 100644
--- a/src/reducers/src/vis-state-updaters.ts
+++ b/src/reducers/src/vis-state-updaters.ts
@@ -128,8 +128,13 @@ import {mergeDatasetsByOrder} from './vis-state-merger';
import {
fixEffectOrder,
getAnimatableVisibleLayers,
- getAnimatableVisibleLayersByType,
- mergeTimeDomains
+ getIntervalBasedAnimationLayers,
+ mergeTimeDomains,
+ adjustValueToAnimationWindow,
+ updateTimeFilterPlotType,
+ getDefaultTimeFormat,
+ LayerToFilterTimeInterval,
+ TIME_INTERVALS_ORDERED
} from '@kepler.gl/utils';
import {createEffect} from '@kepler.gl/effects';
@@ -968,10 +973,10 @@ export function setFilterAnimationTimeUpdater(
* @memberof visStateUpdaters
* @public
*/
-export function setFilterAnimationWindowUpdater(
- state: VisState,
+export function setFilterAnimationWindowUpdater<S extends VisState>(
+ state: S,
{id, animationWindow}: VisStateActions.SetFilterAnimationWindowUpdaterAction
-): VisState {
+): S {
const filter = state.filters.find(f => f.id === id);
if (!filter) {
@@ -998,10 +1003,10 @@ export function setFilterAnimationWindowUpdater(
* @memberof visStateUpdaters
* @public
*/
-export function setFilterUpdater(
- state: VisState,
+export function setFilterUpdater<S extends VisState>(
+ state: S,
action: VisStateActions.SetFilterUpdaterAction
-): VisState {
+): S {
const {idx, valueIndex = 0} = action;
const oldFilter = state.filters[idx];
if (!oldFilter) {
@@ -1061,10 +1066,6 @@ export function setFilterUpdater(
// pass only the dataset we need to update
newState = updateAllLayerDomainData(newState, datasetIdsToFilter, newFilter);
- // if (newFilter.syncedWithLayerTimeline) {
- // newState = syncTimeFilterWithLayerTimelineUpdater(state, {idx, enable: newFilter.syncedWithLayerTimeline});
- // }
-
return newState;
}
@@ -2697,11 +2698,11 @@ export function updateFileLoadingProgressUpdater(state, {fileName, progress}) {
/**
* Helper function to update layer domains for an array of datasets
*/
-export function updateAllLayerDomainData(
- state: VisState,
+export function updateAllLayerDomainData<S extends VisState>(
+ state: S,
dataId: string | string[],
updatedFilter?: Filter
-): VisState {
+): S {
const dataIds = typeof dataId === 'string' ? [dataId] : dataId;
const newLayers: Layer[] = [];
const newLayerData: any[] = [];
@@ -3185,6 +3186,7 @@ export function layerFilteredItemsChangeUpdater<S extends VisState>(
};
}
+// eslint-disable-next-line max-statements
export function syncTimeFilterWithLayerTimelineUpdater<S extends VisState>(
state: S,
action: VisStateActions.SyncTimeFilterWithLayerTimelineAction
@@ -3192,31 +3194,102 @@ export function syncTimeFilterWithLayerTimelineUpdater<S extends VisState>(
const {idx: filterIdx, enable = false} = action;
const filter = state.filters[filterIdx] as TimeRangeFilter;
- const hasHexTileLayer =
- enable && Boolean(getAnimatableVisibleLayersByType(state.layers, 'hexTile').length);
- const newFilterDomain =
- hasHexTileLayer && state.animationConfig.domain
- ? mergeTimeDomains([filter.domain, state.animationConfig.domain as [number, number]])
- : filter.domain;
+ let newState = state;
+ let newFilter = filter;
+
+ // if we enable sync we are going to merge filter and animationConfig domains and store into filter.domain
+ if (enable) {
+ const animatableLayers = getAnimatableVisibleLayers(newState.layers);
+ // if no animatableLayers are present we simply return
+ if (!animatableLayers.length) {
+ return newState;
+ }
- const syncTimelineMode = getSyncAnimationMode(filter);
+ const intervalBasedAnimationLayers = getIntervalBasedAnimationLayers(animatableLayers);
+ const hasIntervalBasedAnimationLayer = Boolean(intervalBasedAnimationLayers.length);
- let newState = setFilterAnimationWindowUpdater(state, {
- id: filter.id,
- animationWindow: hasHexTileLayer ? ANIMATION_WINDOW.interval : filter.animationWindow
- });
+ const newFilterDomain = mergeTimeDomains([filter.domain, newState.animationConfig.domain]);
- let newFilter = newState.filters[filterIdx];
+ // we only update animationWindow if we have interval based animation layers with defined intervals and the current filter animation window is not interval
+ if (hasIntervalBasedAnimationLayer) {
+ if (filter.animationWindow !== ANIMATION_WINDOW.interval) {
+ newState = setFilterAnimationWindowUpdater(newState, {
+ id: filter.id,
+ animationWindow: ANIMATION_WINDOW.interval
+ });
+ }
- const newFilterValue = adjustValueToFilterDomain(
- hasHexTileLayer ? [newFilterDomain[0], newFilterDomain[0]] : newFilter.value,
- {
- domain: newFilterDomain,
- // check whether this is valid type here - required to pass ts checks.
- type: newFilter.type
+ newFilter = newState.filters[filterIdx] as TimeRangeFilter;
+
+ // adjust time filter interval
+ newFilter = adjustTimeFilterInterval(newState, newFilter);
+
+ // replace filter in state with newFilter
+ newState = {
+ ...newState,
+ filters: swap_<Filter>(newFilter)(newState.filters)
+ };
}
- );
+
+ newFilter = newState.filters[filterIdx] as TimeRangeFilter;
+
+ // adjust value based on new domain
+ const newFilterValue = adjustValueToFilterDomain(
+ newFilter.animationWindow === ANIMATION_WINDOW.interval
+ ? [newFilterDomain[0], newFilterDomain[0]]
+ : newFilterDomain,
+ {...newFilter, domain: newFilterDomain}
+ );
+
+ newState = setFilterUpdater(newState, {
+ idx: filterIdx,
+ prop: 'value',
+ value: newFilterValue
+ });
+
+ newFilter = {
+ ...(newState.filters[filterIdx] as TimeRangeFilter),
+ syncedWithLayerTimeline: true
+ };
+
+ // replace filter in state with newFilter
+ newState = {
+ ...newState,
+ filters: swap_<Filter>(newFilter)(newState.filters)
+ };
+
+ newState = setTimeFilterTimelineModeUpdater(newState, {
+ id: newFilter.id,
+ mode: getSyncAnimationMode(newFilter)
+ });
+
+ // set the animation config value to match filter value
+ return setLayerAnimationTimeUpdater(newState, {value: newState.filters[filterIdx].value[0]});
+ }
+
+ // set domain and step
+ newFilter = {
+ ...filter,
+ syncedWithLayerTimeline: false
+ };
+
+ // replace filter in state with newFilter
+ newState = {
+ ...newState,
+ filters: swap_<Filter>(newFilter)(newState.filters)
+ };
+
+ // reset sync timeline mode
+ newState = setTimeFilterTimelineModeUpdater(newState, {
+ id: newFilter.id,
+ mode: SYNC_TIMELINE_MODES.end
+ });
+
+ newFilter = newState.filters[filterIdx] as TimeRangeFilter;
+
+ // reset filter value
+ const newFilterValue = adjustValueToFilterDomain(newFilter.domain, newFilter);
newState = setFilterUpdater(newState, {
idx: filterIdx,
@@ -3224,23 +3297,15 @@ export function syncTimeFilterWithLayerTimelineUpdater<S extends VisState>(
value: newFilterValue
});
- newFilter = {
- ...newState.filters[filterIdx],
- syncedWithLayerTimeline: enable,
- syncTimelineMode
- } as TimeRangeFilter;
-
- const animationConfigCurrentTime = enable
- ? newFilterDomain[0]
- : newState.animationConfig.domain?.[0] ?? 0;
+ newState = setTimeFilterTimelineModeUpdater(newState, {
+ id: newFilter.id,
+ mode: getSyncAnimationMode(newFilter)
+ });
- return setLayerAnimationTimeUpdater(
- {
- ...newState,
- filters: swap_<Filter>(newFilter)(newState.filters)
- },
- {value: animationConfigCurrentTime ?? null}
- );
+ // reset animation config current time to
+ return setLayerAnimationTimeUpdater(newState, {
+ value: newState.animationConfig.domain?.[0] ?? null
+ });
}
export function setTimeFilterTimelineModeUpdater<S extends VisState>(
@@ -3251,11 +3316,7 @@ export function setTimeFilterTimelineModeUpdater<S extends VisState>(
const filter = state.filters.find(f => f.id === filterId) as TimeRangeFilter | undefined;
- if (!filter?.syncedWithLayerTimeline) {
- return state;
- }
-
- if (!validateSyncAnimationMode(filter, syncTimelineMode)) {
+ if (!filter || !validateSyncAnimationMode(filter, syncTimelineMode)) {
return state;
}
@@ -3288,6 +3349,34 @@ function validateSyncAnimationMode(filter: TimeRangeFilter, newMode: number) {
);
}
+function adjustTimeFilterInterval(state, filter) {
+ const intervalBasedAnimationLayers = getIntervalBasedAnimationLayers(state.layers);
+
+ let interval: string | null = null;
+ if (intervalBasedAnimationLayers.length > 0) {
+ // @ts-ignore
+ const intervalIndex = intervalBasedAnimationLayers.reduce((currentIndex, l) => {
+ if (l.meta.targetTimeInterval) {
+ const newIndex = TIME_INTERVALS_ORDERED.findIndex(i => i === l.meta.targetTimeInterval);
+ return newIndex > -1 && newIndex < currentIndex ? newIndex : currentIndex;
+ }
+ }, TIME_INTERVALS_ORDERED.length - 1);
+ // @ts-ignore
+ const hexTileInterval = TIME_INTERVALS_ORDERED[intervalIndex];
+ interval = LayerToFilterTimeInterval[hexTileInterval];
+ }
+
+ if (!interval) {
+ return filter;
+ }
+
+ // adjust filter
+ const timeFormat = getDefaultTimeFormat(interval);
+ const updatedPlotType = {...filter.plotType, interval, timeFormat};
+ const newFilter = updateTimeFilterPlotType(filter, updatedPlotType, state.datasets);
+ return adjustValueToAnimationWindow(state, newFilter);
+}
+
// Find dataId from a saved visState property:
// layers, filters, interactions, layerBlending, overlayBlending, splitMaps, animationConfig, editor
// replace it with another dataId
diff --git a/src/utils/src/filter-utils.ts b/src/utils/src/filter-utils.ts
index b74e130b6..1e026bcd0 100644
--- a/src/utils/src/filter-utils.ts
+++ b/src/utils/src/filter-utils.ts
@@ -1252,6 +1252,15 @@ export function getAnimatableVisibleLayersByType(layers: any[], type: string): a
return getAnimatableVisibleLayers(layers).filter(l => l.type === type);
}
+/**
+ * @param {Layer[]} layers
+ * @returns {Layer[]}
+ */
+export function getIntervalBasedAnimationLayers(layers: any[]): any[] {
+ // @ts-ignore
+ return getAnimatableVisibleLayers(layers).filter(l => l.config.animation?.timeSteps);
+}
+
export function mergeFilterWithTimeline(
filter: TimeRangeFilter,
animationConfig: AnimationConfig
diff --git a/src/utils/src/index.ts b/src/utils/src/index.ts
index abadd8752..e27565cac 100644
--- a/src/utils/src/index.ts
+++ b/src/utils/src/index.ts
@@ -21,7 +21,14 @@ export {createNotification, exportImageError, successNotification} from './notif
export {setStyleSheetBaseHref} from './dom-utils';
export {default as domtoimage} from './dom-to-image';
export {getFrequency, getMode, aggregate} from './aggregation';
-export {getBinThresholds, histogramFromThreshold, histogramFromDomain, runGpuFilterForPlot} from './plot';
+export {
+ getBinThresholds,
+ histogramFromThreshold,
+ histogramFromDomain,
+ runGpuFilterForPlot,
+ adjustValueToAnimationWindow,
+ updateTimeFilterPlotType
+} from './plot';
// eslint-disable-next-line prettier/prettier
export type {FieldFormatter} from './data-utils';
export * from './data-utils';
@@ -30,7 +37,10 @@ export {
getTimelineFromAnimationConfig,
getTimelineFromFilter,
SAMPLE_TIMELINE,
- TIMELINE_MODES
+ TIMELINE_MODES,
+ LayerToFilterTimeInterval,
+ TIME_INTERVALS_ORDERED,
+ TileTimeInterval
} from './time';
export {
@@ -45,7 +55,7 @@ export {
getFormatLabels,
getFieldFormatLabels
} from './dataset-utils';
-export {getFormatValue} from './format';
+export {getFormatValue, getDefaultTimeFormat} from './format';
export {exportMapToHTML} from './export-map-html';
export {
isMSEdge,
diff --git a/src/utils/src/time.ts b/src/utils/src/time.ts
index b50a35d72..4bbbde87b 100644
--- a/src/utils/src/time.ts
+++ b/src/utils/src/time.ts
@@ -1,21 +1,46 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
-import {AnimationConfig, Timeline, TimeRangeFilter} from '@kepler.gl/types';
+import {ascending, bisector, tickStep} from 'd3-array';
+import moment from 'moment';
-import {toArray} from './utils';
import {
TICK_INTERVALS,
BINS_LARGE,
DURATIONS,
TIME_INTERVALS,
durationYear,
+ INTERVAL,
TickInterval
} from '@kepler.gl/constants';
-import moment from 'moment';
+import {AnimationConfig, Timeline, TimeRangeFilter} from '@kepler.gl/types';
+
+import {toArray} from './utils';
import {getFrequency} from './aggregation';
-import {ascending, bisector, tickStep} from 'd3-array';
+export const TileTimeInterval = {
+ YEAR: 'Y',
+ MONTH: 'M',
+ DAY: 'D',
+ HOUR: 'H',
+ MINUTE: 'T'
+};
+
+export const TIME_INTERVALS_ORDERED = [
+ TileTimeInterval.MINUTE,
+ TileTimeInterval.HOUR,
+ TileTimeInterval.DAY,
+ TileTimeInterval.MONTH,
+ TileTimeInterval.YEAR
+];
+
+export const LayerToFilterTimeInterval = {
+ [TileTimeInterval.MINUTE]: INTERVAL['1-minute'],
+ [TileTimeInterval.HOUR]: INTERVAL['1-hour'],
+ [TileTimeInterval.DAY]: INTERVAL['1-day'],
+ [TileTimeInterval.MONTH]: INTERVAL['1-month'],
+ [TileTimeInterval.YEAR]: INTERVAL['1-year']
+};
export const TIMELINE_MODES = {
inner: 'inner',
diff --git a/test/helpers/mock-state.js b/test/helpers/mock-state.js
index f0edff2ea..51f855c59 100644
--- a/test/helpers/mock-state.js
+++ b/test/helpers/mock-state.js
@@ -199,8 +199,8 @@ function mockStateWithSyncedTimeFilter() {
return updatedState;
}
-function mockStateWithTripGeojson() {
- const initialState = cloneDeep(InitialState);
+export function mockStateWithTripGeojson(state) {
+ const initialState = cloneDeep(state || InitialState);
// load csv and geojson
const updatedState = applyActions(keplerGlReducer, initialState, [
diff --git a/test/node/reducers/vis-state-test.js b/test/node/reducers/vis-state-test.js
index 03c7380c6..9089b11d9 100644
--- a/test/node/reducers/vis-state-test.js
+++ b/test/node/reducers/vis-state-test.js
@@ -18,7 +18,9 @@ import {
serializeLayer,
validateLayerWithData,
defaultInteractionConfig,
- prepareStateForDatasetReplace
+ prepareStateForDatasetReplace,
+ syncTimeFilterWithLayerTimelineUpdater,
+ setTimeFilterTimelineModeUpdater
} from '@kepler.gl/reducers';
import {processCsvData, processGeojson} from '@kepler.gl/processors';
@@ -27,8 +29,10 @@ import {createNewDataEntry, maybeToDate} from '@kepler.gl/table';
import {
createDataContainer,
applyFilterFieldName,
+ getAnimatableVisibleLayers,
getDefaultFilter,
- histogramFromDomain
+ histogramFromDomain,
+ TileTimeInterval
} from '@kepler.gl/utils';
import {
ALL_FIELD_TYPES,
@@ -38,7 +42,11 @@ import {
DEFAULT_COLOR_UI,
FILTER_VIEW_TYPES,
LIGHT_AND_SHADOW_EFFECT,
- BINS
+ ANIMATION_WINDOW,
+ BINS,
+ INTERVAL,
+ LAYER_TYPES,
+ SYNC_TIMELINE_MODES
} from '@kepler.gl/constants';
const {ArcLayer, PointLayer, GeojsonLayer, LineLayer, TripLayer} = KeplerGlLayers;
@@ -85,7 +93,8 @@ import {
StateWH3Layer,
testCsvDataId,
testGeoJsonDataId,
- InitialState
+ InitialState,
+ mockStateWithTripGeojson
} from 'test/helpers/mock-state';
import {getNextColorMakerValue} from 'test/helpers/layer-utils';
import {expectedTripLayerConfig} from '../../fixtures/test-trip-csv-data';
@@ -5817,6 +5826,303 @@ test('#visStateReducer -> applyFilterFieldName', t => {
t.end();
});
+// sync filter with timeline
+function mockStateWithFilterAndTripLayer() {
+ const initialState = CloneDeep(StateWFilters);
+ return mockStateWithTripGeojson(initialState).visState;
+}
+
+test('#visStateReducer -> sync with time filter with trip layer', t => {
+ let visState = mockStateWithFilterAndTripLayer();
+
+ const animatableLayers = getAnimatableVisibleLayers(visState.layers);
+ t.equal(animatableLayers.length, 1, 'Should find 1 animatable layer');
+ t.equal(animatableLayers[0].type, LAYER_TYPES.trip, 'Should find 1 animatable trip layer');
+
+ const originalDomain = [...visState.filters[0].domain];
+
+ // ============
+ // Enable sync
+ // ============
+ visState = syncTimeFilterWithLayerTimelineUpdater(visState, {
+ idx: 0,
+ enable: true
+ });
+
+ let newFilter = visState.filters[0];
+
+ // check syncedWithLayerTimeline
+ t.equal(
+ newFilter.syncedWithLayerTimeline,
+ true,
+ 'Should have set syncedWithLayerTimeline to true'
+ );
+
+ // check animation window wasn't updated
+ t.equal(newFilter.animationWindow, visState.filters[0].animationWindow);
+
+ // check syncTimelineMode
+ t.equal(
+ newFilter.syncTimelineMode,
+ SYNC_TIMELINE_MODES.end,
+ 'Should have set syncTimelineMode to SYNC_TIMELINE_MODES.end (1)'
+ );
+
+ // check filter domains
+ t.deepEqual(newFilter.domain, originalDomain, 'Should not change the domain value');
+
+ // check filter value
+ t.deepEqual(
+ newFilter.value,
+ [1474588800000, 1565578836000],
+ 'Should have set filter value by combining filter and animationConfig domains'
+ );
+
+ // check animationConfig value
+ t.equal(
+ visState.animationConfig.currentTime,
+ 1474588800000,
+ 'Should have set animationConfig value to filter value[0]'
+ );
+
+ // update syncTimelineMode
+ visState = setTimeFilterTimelineModeUpdater(visState, {
+ id: newFilter.id,
+ mode: SYNC_TIMELINE_MODES.start
+ });
+
+ newFilter = visState.filters[0];
+
+ // check syncTimelineMode
+ t.equal(
+ newFilter.syncTimelineMode,
+ SYNC_TIMELINE_MODES.start,
+ 'Should have set syncTimelineMode to SYNC_TIMELINE_MODES.start'
+ );
+
+ // ============
+ // Disable sync
+ // ============
+
+ visState = syncTimeFilterWithLayerTimelineUpdater(visState, {
+ idx: 0,
+ enable: false
+ });
+
+ newFilter = visState.filters[0];
+
+ // check syncedWithLayerTimeline
+ t.equal(
+ newFilter.syncedWithLayerTimeline,
+ false,
+ 'Should have set syncedWithLayerTimeline to false'
+ );
+
+ // check syncTimelineMode
+ t.equal(
+ newFilter.syncTimelineMode,
+ SYNC_TIMELINE_MODES.end,
+ 'Should have set syncTimelineMode to end (1)'
+ );
+
+ // check filter domains
+ t.deepEqual(newFilter.domain, originalDomain, 'Should not change the domain value');
+
+ // check filter value
+ t.deepEqual(newFilter.value, newFilter.domain, 'Should have set filter value to match domain');
+
+ // check animationConfig value
+ t.equal(
+ visState.animationConfig.currentTime,
+ visState.animationConfig.domain[0],
+ 'Should have set animationConfig value to filter value[0]'
+ );
+
+ t.end();
+});
+
+function mockStateWithFilterAndIntervalBasedAnimationLayer() {
+ let visState = mockStateWithFilterAndTripLayer();
+ visState = reducer(visState, VisStateActions.addLayer());
+ const mockedMetaData = {
+ minZoom: 0,
+ maxZoom: 4,
+ fields: [
+ {
+ id: 'Fires',
+ name: 'Fires',
+ type: 'real',
+ analyzerType: 'FLOAT',
+ format: '',
+ filterProps: {
+ fieldType: 'real',
+ domain: [1, 400],
+ domainStops: {
+ z: [0, 1, 2, 3],
+ stops: [
+ [1, 100],
+ [1, 200],
+ [1, 300],
+ [1, 400]
+ ],
+ interpolation: 'interpolate'
+ },
+ domainQuantiles: {
+ z: [0, 1, 2, 3],
+ quantiles: Array.from({length: 4}).map(() => [0, 10])
+ },
+ histogram: null,
+ value: [1, 400],
+ type: 'range',
+ typeOptions: ['range'],
+ gpu: true,
+ step: 1
+ },
+ indexBy: {
+ format: 'x',
+ type: 'timestamp',
+ mappedValue: {
+ 1580515200000: 'Fires|1580515200000',
+ 1583020800000: 'Fires|1583020800000',
+ 1585699200000: 'Fires|1585699200000',
+ 1588291200000: 'Fires|1588291200000'
+ },
+ timeDomain: {
+ domain: [1580515200000, 1588291200000],
+ timeSteps: [1580515200000, 1583020800000, 1585699200000, 1588291200000],
+ duration: 1000
+ }
+ }
+ }
+ ],
+ resolutionOffset: 4,
+ targetTimeInterval: TileTimeInterval.DAY,
+ tilesetIndex: undefined,
+ zipUrl: undefined
+ };
+
+ const lastLayerIndex = visState.layers.length - 1;
+ const layer = visState.layers[lastLayerIndex];
+ layer.meta = mockedMetaData;
+ layer.config = {
+ ...visState.layers[lastLayerIndex].config,
+ animation: {
+ domain: visState.animationConfig.domain,
+ timeSteps: visState.animationConfig.domain,
+ duration: 1000,
+ enabled: true,
+ startTime: visState.animationConfig.domain[0]
+ }
+ };
+
+ visState.layers[lastLayerIndex] = layer;
+
+ return visState;
+}
+
+test('#visStateReducer -> sync with time filter with hextile layer', t => {
+ let visState = mockStateWithFilterAndIntervalBasedAnimationLayer();
+ const animatableLayers = getAnimatableVisibleLayers(visState.layers);
+ t.equal(animatableLayers.length, 2, 'Should find 1 animatable layer');
+ t.equal(animatableLayers[0].type, LAYER_TYPES.trip, 'Should find 1 animatable trip layer');
+
+ const originalDomain = [...visState.filters[0].domain];
+
+ // ============
+ // Enable sync
+ // ============
+ visState = syncTimeFilterWithLayerTimelineUpdater(visState, {
+ idx: 0,
+ enable: true
+ });
+
+ let newFilter = visState.filters[0];
+
+ // check syncedWithLayerTimeline
+ t.equal(
+ newFilter.syncedWithLayerTimeline,
+ true,
+ 'Should have set syncedWithLayerTimeline to true'
+ );
+
+ // check syncTimelineMode
+ t.equal(
+ newFilter.syncTimelineMode,
+ SYNC_TIMELINE_MODES.end,
+ 'Should have set syncTimelineMode to SYNC_TIMELINE_MODES.end (1)'
+ );
+
+ // check animation window wasn't updated
+ t.equal(
+ newFilter.animationWindow,
+ ANIMATION_WINDOW.interval,
+ 'Should have set filter animation window to interval'
+ );
+
+ // check plotType interval to match hextile interval
+ t.equal(
+ newFilter.plotType.interval,
+ INTERVAL['1-day'],
+ 'Should have set plotType interval to 1-day'
+ );
+
+ // check filter domains
+ t.deepEqual(newFilter.domain, originalDomain, 'Should not change the domain value');
+
+ // check filter value
+ t.deepEqual(
+ newFilter.value,
+ [1474588800000, 1474588800000],
+ 'Should have set filter value to the first interval step'
+ );
+
+ // check animationConfig value
+ t.equal(
+ visState.animationConfig.currentTime,
+ 1474588800000,
+ 'Should have set animationConfig value to filter value[0]'
+ );
+
+ // ============
+ // Disable sync
+ // ============
+ visState = syncTimeFilterWithLayerTimelineUpdater(visState, {
+ idx: 0,
+ enable: false
+ });
+
+ newFilter = visState.filters[0];
+
+ // check syncedWithLayerTimeline
+ t.equal(
+ newFilter.syncedWithLayerTimeline,
+ false,
+ 'Should have set syncedWithLayerTimeline to false'
+ );
+
+ // check syncTimelineMode
+ t.equal(
+ newFilter.syncTimelineMode,
+ SYNC_TIMELINE_MODES.end,
+ 'Should have set syncTimelineMode to end (1)'
+ );
+
+ // check filter domains
+ t.deepEqual(newFilter.domain, originalDomain, 'Should not change the domain value');
+
+ // check filter value
+ t.deepEqual(newFilter.value, newFilter.domain, 'Should have set filter value to match domain');
+
+ // check animationConfig value
+ t.equal(
+ visState.animationConfig.currentTime,
+ visState.animationConfig.domain[0],
+ 'Should have set animationConfig value to filter value[0]'
+ );
+
+ t.end();
+});
+
test('VisStateUpdater -> prepareStateForDatasetReplace', t => {
const oldTooltipConfigFields =
StateWFilters.visState.interactionConfig.tooltip.config.fieldsToShow;