Skip to content

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

[Bug] Correctly copy over field.filterProps when merging multiple filters (#884)

Shan Hebf8b6f32ea77
diff --git a/src/reducers/vis-state-merger.js b/src/reducers/vis-state-merger.js
index a625649be..fd8c5b43b 100644
--- a/src/reducers/vis-state-merger.js
+++ b/src/reducers/vis-state-merger.js
@@ -61,8 +61,9 @@ export function mergeFilters(state, filtersToMerge) {
// all datasetIds in filter must be present the state datasets
const {filter: validatedFilter, applyToDatasets, augmentedDatasets} = datasetIds.reduce((acc, datasetId) => {
- const dataset = datasets[datasetId];
- const {filter: updatedFilter, dataset: updatedDataset} = validateFilterWithData(dataset, filter);
+ const dataset = updatedDatasets[datasetId];
+ const {filter: updatedFilter, dataset: updatedDataset} =
+ validateFilterWithData(acc.augmentedDatasets[datasetId] || dataset, filter);
if (updatedFilter) {
return {
@@ -80,7 +81,7 @@ export function mergeFilters(state, filtersToMerge) {
augmentedDatasets: {
...acc.augmentedDatasets,
- [datasetId]: updatedDataset || dataset
+ [datasetId]: updatedDataset
}
};
}
diff --git a/src/schemas/schema-manager.js b/src/schemas/schema-manager.js
index 52f20975f..5d14ad445 100644
--- a/src/schemas/schema-manager.js
+++ b/src/schemas/schema-manager.js
@@ -26,6 +26,7 @@ import mapStyleSchema from './map-style-schema';
import mapStateSchema from './map-state-schema';
import {CURRENT_VERSION, VERSIONS} from './versions';
+import {isPlainObject} from 'utils/utils';
const REDUCER_SCHEMAS = {
visState: visStateSchema,
@@ -81,10 +82,29 @@ class KeplerGLSchema {
};
}
+ /**
+ * Load saved map, argument can be (datasets, config) or ({datasets, config})
+ * @param {Object|Array<Object>} savedDatasets
+ * @param {Object} savedConfig
+ */
load(savedDatasets, savedConfig) {
+ // if pass dataset and config in as a single object
+ if (
+ arguments.length === 1 &&
+ isPlainObject(arguments[0]) &&
+ (Array.isArray(arguments[0].datasets) ||
+ isPlainObject(arguments[0].config))
+ ) {
+ return this.load(arguments[0].datasets, arguments[0].config);
+ }
+
return {
- datasets: this.parseSavedData(savedDatasets),
- config: savedConfig ? this.parseSavedConfig(savedConfig) : undefined
+ ...(Array.isArray(savedDatasets)
+ ? {datasets: this.parseSavedData(savedDatasets)}
+ : {}),
+ ...(savedConfig
+ ? {config: this.parseSavedConfig(savedConfig)}
+ : {})
};
}
@@ -164,13 +184,11 @@ class KeplerGLSchema {
return Object.keys(config).reduce(
(accu, key) => ({
- ...accu,
- ...(key in this._reducerSchemas
- ? this._reducerSchemas[key][validVersion].load(
- config[key]
- )
- : {})
- }),
+ ...accu,
+ ...(key in this._reducerSchemas
+ ? this._reducerSchemas[key][validVersion].load(config[key])
+ : {})
+ }),
{}
);
}
diff --git a/src/utils/filter-utils.js b/src/utils/filter-utils.js
index e8e4cd851..671fd4725 100644
--- a/src/utils/filter-utils.js
+++ b/src/utils/filter-utils.js
@@ -798,7 +798,6 @@ export function mergeFilterDomainStep(filter, filterProps) {
return {
...newFilter,
step
- // step: Math.min(filter.step, filterProps.step)
};
case ALL_FIELD_TYPES.real:
case ALL_FIELD_TYPES.integer:
diff --git a/test/fixtures/geojson.js b/test/fixtures/geojson.js
index fc882e3c1..f7c591dd3 100644
--- a/test/fixtures/geojson.js
+++ b/test/fixtures/geojson.js
@@ -105,7 +105,7 @@ export const geojsonData = {
properties: {
OBJECTID: 4,
ZIP_CODE: 94111,
- ID: 9411,
+ ID: 94111,
RATE: 'c'
},
geometry: {
@@ -128,6 +128,8 @@ export const geojsonData = {
]
};
+export const geoJsonDataId = 'ieukmgne';
+
export const fields = [
{
type: 'geojson',
@@ -173,6 +175,11 @@ export const fields = [
}
];
+export const datasetFields = fields.map(f => ({
+ ...f,
+ id: f.name
+}));
+
export const rows = [
[
{
@@ -280,7 +287,7 @@ export const rows = [
properties: {
OBJECTID: 4,
ZIP_CODE: 94111,
- ID: 9411,
+ ID: 94111,
RATE: 'c'
},
geometry: {
@@ -302,12 +309,199 @@ export const rows = [
},
4,
94111,
- 9411,
+ 94111,
null,
'c'
]
];
+// add index to properties
+export const datasetAllData = rows.map((row, index) =>
+ row.map((cell, i) =>
+ i === 0
+ ? {
+ ...cell,
+ properties: {
+ ...cell.properties,
+ index
+ }
+ }
+ : cell
+ )
+);
+
+export const geoJsonTripHistogram = [
+ {count: 1, x0: 4, x1: 4.5},
+ {count: 0, x0: 4.5, x1: 5},
+ {count: 0, x0: 5, x1: 5.5},
+ {count: 0, x0: 5.5, x1: 6},
+ {count: 0, x0: 6, x1: 6.5},
+ {count: 0, x0: 6.5, x1: 7},
+ {count: 0, x0: 7, x1: 7.5},
+ {count: 0, x0: 7.5, x1: 8},
+ {count: 0, x0: 8, x1: 8.5},
+ {count: 0, x0: 8.5, x1: 9},
+ {count: 0, x0: 9, x1: 9.5},
+ {count: 0, x0: 9.5, x1: 10},
+ {count: 0, x0: 10, x1: 10.5},
+ {count: 0, x0: 10.5, x1: 11},
+ {count: 1, x0: 11, x1: 11.5},
+ {count: 0, x0: 11.5, x1: 12},
+ {count: 0, x0: 12, x1: 12.5},
+ {count: 0, x0: 12.5, x1: 13},
+ {count: 0, x0: 13, x1: 13.5},
+ {count: 0, x0: 13.5, x1: 14},
+ {count: 0, x0: 14, x1: 14.5},
+ {count: 0, x0: 14.5, x1: 15},
+ {count: 0, x0: 15, x1: 15.5},
+ {count: 0, x0: 15.5, x1: 16},
+ {count: 0, x0: 16, x1: 16.5},
+ {count: 0, x0: 16.5, x1: 17},
+ {count: 0, x0: 17, x1: 17.5},
+ {count: 0, x0: 17.5, x1: 18},
+ {count: 0, x0: 18, x1: 18.5},
+ {count: 0, x0: 18.5, x1: 19},
+ {count: 0, x0: 19, x1: 19.5},
+ {count: 0, x0: 19.5, x1: 20},
+ {count: 1, x0: 20, x1: 20}
+];
+
+export const geoJsonTripHistogramEnlarged = [
+ {count: 1, x0: 4, x1: 4.2},
+ {count: 0, x0: 4.2, x1: 4.4},
+ {count: 0, x0: 4.4, x1: 4.6},
+ {count: 0, x0: 4.6, x1: 4.8},
+ {count: 0, x0: 4.8, x1: 5},
+ {count: 0, x0: 5, x1: 5.2},
+ {count: 0, x0: 5.2, x1: 5.4},
+ {count: 0, x0: 5.4, x1: 5.6},
+ {count: 0, x0: 5.6, x1: 5.8},
+ {count: 0, x0: 5.8, x1: 6},
+ {count: 0, x0: 6, x1: 6.2},
+ {count: 0, x0: 6.2, x1: 6.4},
+ {count: 0, x0: 6.4, x1: 6.6},
+ {count: 0, x0: 6.6, x1: 6.8},
+ {count: 0, x0: 6.8, x1: 7},
+ {count: 0, x0: 7, x1: 7.2},
+ {count: 0, x0: 7.2, x1: 7.4},
+ {count: 0, x0: 7.4, x1: 7.6},
+ {count: 0, x0: 7.6, x1: 7.8},
+ {count: 0, x0: 7.8, x1: 8},
+ {count: 0, x0: 8, x1: 8.2},
+ {count: 0, x0: 8.2, x1: 8.4},
+ {count: 0, x0: 8.4, x1: 8.6},
+ {count: 0, x0: 8.6, x1: 8.8},
+ {count: 0, x0: 8.8, x1: 9},
+ {count: 0, x0: 9, x1: 9.2},
+ {count: 0, x0: 9.2, x1: 9.4},
+ {count: 0, x0: 9.4, x1: 9.6},
+ {count: 0, x0: 9.6, x1: 9.8},
+ {count: 0, x0: 9.8, x1: 10},
+ {count: 0, x0: 10, x1: 10.2},
+ {count: 0, x0: 10.2, x1: 10.4},
+ {count: 0, x0: 10.4, x1: 10.6},
+ {count: 0, x0: 10.6, x1: 10.8},
+ {count: 0, x0: 10.8, x1: 11},
+ {count: 1, x0: 11, x1: 11.2},
+ {count: 0, x0: 11.2, x1: 11.4},
+ {count: 0, x0: 11.4, x1: 11.6},
+ {count: 0, x0: 11.6, x1: 11.8},
+ {count: 0, x0: 11.8, x1: 12},
+ {count: 0, x0: 12, x1: 12.2},
+ {count: 0, x0: 12.2, x1: 12.4},
+ {count: 0, x0: 12.4, x1: 12.6},
+ {count: 0, x0: 12.6, x1: 12.8},
+ {count: 0, x0: 12.8, x1: 13},
+ {count: 0, x0: 13, x1: 13.2},
+ {count: 0, x0: 13.2, x1: 13.4},
+ {count: 0, x0: 13.4, x1: 13.6},
+ {count: 0, x0: 13.6, x1: 13.8},
+ {count: 0, x0: 13.8, x1: 14},
+ {count: 0, x0: 14, x1: 14.2},
+ {count: 0, x0: 14.2, x1: 14.4},
+ {count: 0, x0: 14.4, x1: 14.6},
+ {count: 0, x0: 14.6, x1: 14.8},
+ {count: 0, x0: 14.8, x1: 15},
+ {count: 0, x0: 15, x1: 15.2},
+ {count: 0, x0: 15.2, x1: 15.4},
+ {count: 0, x0: 15.4, x1: 15.6},
+ {count: 0, x0: 15.6, x1: 15.8},
+ {count: 0, x0: 15.8, x1: 16},
+ {count: 0, x0: 16, x1: 16.2},
+ {count: 0, x0: 16.2, x1: 16.4},
+ {count: 0, x0: 16.4, x1: 16.6},
+ {count: 0, x0: 16.6, x1: 16.8},
+ {count: 0, x0: 16.8, x1: 17},
+ {count: 0, x0: 17, x1: 17.2},
+ {count: 0, x0: 17.2, x1: 17.4},
+ {count: 0, x0: 17.4, x1: 17.6},
+ {count: 0, x0: 17.6, x1: 17.8},
+ {count: 0, x0: 17.8, x1: 18},
+ {count: 0, x0: 18, x1: 18.2},
+ {count: 0, x0: 18.2, x1: 18.4},
+ {count: 0, x0: 18.4, x1: 18.6},
+ {count: 0, x0: 18.6, x1: 18.8},
+ {count: 0, x0: 18.8, x1: 19},
+ {count: 0, x0: 19, x1: 19.2},
+ {count: 0, x0: 19.2, x1: 19.4},
+ {count: 0, x0: 19.4, x1: 19.6},
+ {count: 0, x0: 19.6, x1: 19.8},
+ {count: 0, x0: 19.8, x1: 20},
+ {count: 1, x0: 20, x1: 20}
+];
+
+export const geoJsonTripFilterProps = {
+ domain: [4, 20],
+ fieldType: 'integer',
+ histogram: geoJsonTripHistogram,
+ enlargedHistogram: geoJsonTripHistogramEnlarged,
+ step: 0.01,
+ type: 'range',
+ typeOptions: ['range'],
+ value: [4, 20]
+};
+
+export const mergedTripFilter = {
+ ...geoJsonTripFilterProps,
+ dataId: [geoJsonDataId],
+ freeze: true,
+ id: 'TRIPS-3',
+ fixedDomain: false,
+ enlarged: false,
+ isAnimating: false,
+ speed: 1,
+ name: ['TRIPS'],
+ fieldIdx: [4],
+ value: [4, 12],
+ plotType: 'histogram',
+ yAxis: null,
+ interval: null
+};
+
+export const geoJsonRateFilterProps = {
+ domain: ['a', 'b', 'c'],
+ fieldType: 'string',
+ type: 'multiSelect',
+ value: []
+};
+
+export const mergedRateFilter = {
+ ...geoJsonRateFilterProps,
+ name: ['RATE'],
+ dataId: [geoJsonDataId],
+ freeze: true,
+ id: 'RATE-1',
+ fixedDomain: false,
+ enlarged: false,
+ isAnimating: false,
+ speed: 1,
+ fieldIdx: [5],
+ value: ['a'],
+ plotType: 'histogram',
+ yAxis: null,
+ interval: null
+};
+
export const geoBounds = [
-122.40115971858505,
37.78202426695214,
@@ -321,8 +515,8 @@ export const geoJsonWithStyle = {
{
type: 'Feature',
properties: {
- fillColor: [1,2,3],
- lineColor: [4,5,6],
+ fillColor: [1, 2, 3],
+ lineColor: [4, 5, 6],
lineWidth: 1,
elevation: 10,
radius: 5
@@ -332,8 +526,8 @@ export const geoJsonWithStyle = {
{
type: 'Feature',
properties: {
- fillColor: [7,8,9],
- lineColor: [4,5,6],
+ fillColor: [7, 8, 9],
+ lineColor: [4, 5, 6],
lineWidth: 3,
elevation: 10,
radius: 5
@@ -343,8 +537,8 @@ export const geoJsonWithStyle = {
{
type: 'Feature',
properties: {
- fillColor: [1,2,3],
- lineColor: [4,5,6],
+ fillColor: [1, 2, 3],
+ lineColor: [4, 5, 6],
lineWidth: 4,
elevation: 10,
radius: 5
@@ -356,12 +550,48 @@ export const geoJsonWithStyle = {
// parsed fields and rows
export const geoStyleFields = [
- {name: '_geojson', format: '', tableFieldIndex: 1, type: 'geojson', analyzerType: 'GEOMETRY'},
- {name: 'fillColor', format: '', tableFieldIndex: 2, type: 'geojson', analyzerType: 'ARRAY'},
- {name: 'lineColor', format: '', tableFieldIndex: 3, type: 'geojson', analyzerType: 'ARRAY'},
- {name: 'lineWidth', format: '', tableFieldIndex: 4, type: 'integer', analyzerType: 'INT'},
- {name: 'elevation', format: '', tableFieldIndex: 5, type: 'integer', analyzerType: 'INT'},
- {name: 'radius', format: '', tableFieldIndex: 6, type: 'integer', analyzerType: 'INT'}
+ {
+ name: '_geojson',
+ format: '',
+ tableFieldIndex: 1,
+ type: 'geojson',
+ analyzerType: 'GEOMETRY'
+ },
+ {
+ name: 'fillColor',
+ format: '',
+ tableFieldIndex: 2,
+ type: 'geojson',
+ analyzerType: 'ARRAY'
+ },
+ {
+ name: 'lineColor',
+ format: '',
+ tableFieldIndex: 3,
+ type: 'geojson',
+ analyzerType: 'ARRAY'
+ },
+ {
+ name: 'lineWidth',
+ format: '',
+ tableFieldIndex: 4,
+ type: 'integer',
+ analyzerType: 'INT'
+ },
+ {
+ name: 'elevation',
+ format: '',
+ tableFieldIndex: 5,
+ type: 'integer',
+ analyzerType: 'INT'
+ },
+ {
+ name: 'radius',
+ format: '',
+ tableFieldIndex: 6,
+ type: 'integer',
+ analyzerType: 'INT'
+ }
];
export const geoStyleRows = [
diff --git a/test/fixtures/test-csv-data.js b/test/fixtures/test-csv-data.js
index dfdc77061..69ac1d843 100644
--- a/test/fixtures/test-csv-data.js
+++ b/test/fixtures/test-csv-data.js
@@ -45,7 +45,7 @@ const data = `gps_data.utc_timestamp,gps_data.lat,gps_data.lng,gps_data.types,ep
2016-09-17 00:30:03,30.0612697,31.2191059,driver_gps,1472774400000,True,7,2016-09-23T08:00:00.000Z,2016-10-01 09:53:35+00:00,2016-10-01 16:53:35+00:00,2016-10-10
2016-09-17 00:30:08,30.0610977,31.2194728,driver_gps,1472774400000,True,,2016-09-23T08:00:00.000Z,,,`;
-const dataId = 'test_trip_data';
+export const dataId = '190vdll3di';
export const config = {
version: 'v1',
@@ -460,6 +460,7 @@ export const wktCsv = `a_zip,simplified_shape_v2,simplified_shape,m_rate,c_zip_t
7023,"{""type"":""LineString"",""coordinates"":[[-74.387589,40.632238],[-74.387589,40.632238]]}","LINESTRING (-74.387589 40.632238, -74.387589 40.632238)",7.6,C_Medium_High,23.85239437
`;
+// csv data
export const testFields = [
{
type: 'timestamp',
@@ -540,6 +541,277 @@ export const testFields = [
}
];
+// add id to fields
+// TODO: cleaning up after filter refractor
+export const datasetCsvFields = testFields.map(f => ({
+ ...f,
+ id: f.name
+}));
+
+export const timeMappedValue = [
+ 1474588800000,
+ 1474588800000,
+ 1474588800000,
+ 1474588800000,
+ 1474588800000,
+ 1474606800000,
+ 1474606800000,
+ 1474588800000,
+ 1474588800000,
+ 1474610400000,
+ 1474606800000,
+ null,
+ null,
+ 1474610400000,
+ 1474610400000,
+ 1474588800000,
+ 1474614000000,
+ 1474614000000,
+ 1474614000000,
+ 1474614000000,
+ 1474614000000,
+ 1474617600000,
+ 1474617600000,
+ 1474617600000
+];
+
+export const timeHistogram = [
+ {count: 8, x0: 1474588800000, x1: 1474589000000},
+ {count: 0, x0: 1474589000000, x1: 1474590000000},
+ {count: 0, x0: 1474590000000, x1: 1474591000000},
+ {count: 0, x0: 1474591000000, x1: 1474592000000},
+ {count: 0, x0: 1474592000000, x1: 1474593000000},
+ {count: 0, x0: 1474593000000, x1: 1474594000000},
+ {count: 0, x0: 1474594000000, x1: 1474595000000},
+ {count: 0, x0: 1474595000000, x1: 1474596000000},
+ {count: 0, x0: 1474596000000, x1: 1474597000000},
+ {count: 0, x0: 1474597000000, x1: 1474598000000},
+ {count: 0, x0: 1474598000000, x1: 1474599000000},
+ {count: 0, x0: 1474599000000, x1: 1474600000000},
+ {count: 0, x0: 1474600000000, x1: 1474601000000},
+ {count: 0, x0: 1474601000000, x1: 1474602000000},
+ {count: 0, x0: 1474602000000, x1: 1474603000000},
+ {count: 0, x0: 1474603000000, x1: 1474604000000},
+ {count: 0, x0: 1474604000000, x1: 1474605000000},
+ {count: 0, x0: 1474605000000, x1: 1474606000000},
+ {count: 3, x0: 1474606000000, x1: 1474607000000},
+ {count: 0, x0: 1474607000000, x1: 1474608000000},
+ {count: 0, x0: 1474608000000, x1: 1474609000000},
+ {count: 0, x0: 1474609000000, x1: 1474610000000},
+ {count: 3, x0: 1474610000000, x1: 1474611000000},
+ {count: 0, x0: 1474611000000, x1: 1474612000000},
+ {count: 0, x0: 1474612000000, x1: 1474613000000},
+ {count: 0, x0: 1474613000000, x1: 1474614000000},
+ {count: 5, x0: 1474614000000, x1: 1474615000000},
+ {count: 0, x0: 1474615000000, x1: 1474616000000},
+ {count: 0, x0: 1474616000000, x1: 1474617000000},
+ {count: 3, x0: 1474617000000, x1: 1474617600000}
+];
+
+export const enlargedTimeHistogram = [
+ {count: 8, x0: 1474588800000, x1: 1474589000000},
+ {count: 0, x0: 1474589000000, x1: 1474589200000},
+ {count: 0, x0: 1474589200000, x1: 1474589400000},
+ {count: 0, x0: 1474589400000, x1: 1474589600000},
+ {count: 0, x0: 1474589600000, x1: 1474589800000},
+ {count: 0, x0: 1474589800000, x1: 1474590000000},
+ {count: 0, x0: 1474590000000, x1: 1474590200000},
+ {count: 0, x0: 1474590200000, x1: 1474590400000},
+ {count: 0, x0: 1474590400000, x1: 1474590600000},
+ {count: 0, x0: 1474590600000, x1: 1474590800000},
+ {count: 0, x0: 1474590800000, x1: 1474591000000},
+ {count: 0, x0: 1474591000000, x1: 1474591200000},
+ {count: 0, x0: 1474591200000, x1: 1474591400000},
+ {count: 0, x0: 1474591400000, x1: 1474591600000},
+ {count: 0, x0: 1474591600000, x1: 1474591800000},
+ {count: 0, x0: 1474591800000, x1: 1474592000000},
+ {count: 0, x0: 1474592000000, x1: 1474592200000},
+ {count: 0, x0: 1474592200000, x1: 1474592400000},
+ {count: 0, x0: 1474592400000, x1: 1474592600000},
+ {count: 0, x0: 1474592600000, x1: 1474592800000},
+ {count: 0, x0: 1474592800000, x1: 1474593000000},
+ {count: 0, x0: 1474593000000, x1: 1474593200000},
+ {count: 0, x0: 1474593200000, x1: 1474593400000},
+ {count: 0, x0: 1474593400000, x1: 1474593600000},
+ {count: 0, x0: 1474593600000, x1: 1474593800000},
+ {count: 0, x0: 1474593800000, x1: 1474594000000},
+ {count: 0, x0: 1474594000000, x1: 1474594200000},
+ {count: 0, x0: 1474594200000, x1: 1474594400000},
+ {count: 0, x0: 1474594400000, x1: 1474594600000},
+ {count: 0, x0: 1474594600000, x1: 1474594800000},
+ {count: 0, x0: 1474594800000, x1: 1474595000000},
+ {count: 0, x0: 1474595000000, x1: 1474595200000},
+ {count: 0, x0: 1474595200000, x1: 1474595400000},
+ {count: 0, x0: 1474595400000, x1: 1474595600000},
+ {count: 0, x0: 1474595600000, x1: 1474595800000},
+ {count: 0, x0: 1474595800000, x1: 1474596000000},
+ {count: 0, x0: 1474596000000, x1: 1474596200000},
+ {count: 0, x0: 1474596200000, x1: 1474596400000},
+ {count: 0, x0: 1474596400000, x1: 1474596600000},
+ {count: 0, x0: 1474596600000, x1: 1474596800000},
+ {count: 0, x0: 1474596800000, x1: 1474597000000},
+ {count: 0, x0: 1474597000000, x1: 1474597200000},
+ {count: 0, x0: 1474597200000, x1: 1474597400000},
+ {count: 0, x0: 1474597400000, x1: 1474597600000},
+ {count: 0, x0: 1474597600000, x1: 1474597800000},
+ {count: 0, x0: 1474597800000, x1: 1474598000000},
+ {count: 0, x0: 1474598000000, x1: 1474598200000},
+ {count: 0, x0: 1474598200000, x1: 1474598400000},
+ {count: 0, x0: 1474598400000, x1: 1474598600000},
+ {count: 0, x0: 1474598600000, x1: 1474598800000},
+ {count: 0, x0: 1474598800000, x1: 1474599000000},
+ {count: 0, x0: 1474599000000, x1: 1474599200000},
+ {count: 0, x0: 1474599200000, x1: 1474599400000},
+ {count: 0, x0: 1474599400000, x1: 1474599600000},
+ {count: 0, x0: 1474599600000, x1: 1474599800000},
+ {count: 0, x0: 1474599800000, x1: 1474600000000},
+ {count: 0, x0: 1474600000000, x1: 1474600200000},
+ {count: 0, x0: 1474600200000, x1: 1474600400000},
+ {count: 0, x0: 1474600400000, x1: 1474600600000},
+ {count: 0, x0: 1474600600000, x1: 1474600800000},
+ {count: 0, x0: 1474600800000, x1: 1474601000000},
+ {count: 0, x0: 1474601000000, x1: 1474601200000},
+ {count: 0, x0: 1474601200000, x1: 1474601400000},
+ {count: 0, x0: 1474601400000, x1: 1474601600000},
+ {count: 0, x0: 1474601600000, x1: 1474601800000},
+ {count: 0, x0: 1474601800000, x1: 1474602000000},
+ {count: 0, x0: 1474602000000, x1: 1474602200000},
+ {count: 0, x0: 1474602200000, x1: 1474602400000},
+ {count: 0, x0: 1474602400000, x1: 1474602600000},
+ {count: 0, x0: 1474602600000, x1: 1474602800000},
+ {count: 0, x0: 1474602800000, x1: 1474603000000},
+ {count: 0, x0: 1474603000000, x1: 1474603200000},
+ {count: 0, x0: 1474603200000, x1: 1474603400000},
+ {count: 0, x0: 1474603400000, x1: 1474603600000},
+ {count: 0, x0: 1474603600000, x1: 1474603800000},
+ {count: 0, x0: 1474603800000, x1: 1474604000000},
+ {count: 0, x0: 1474604000000, x1: 1474604200000},
+ {count: 0, x0: 1474604200000, x1: 1474604400000},
+ {count: 0, x0: 1474604400000, x1: 1474604600000},
+ {count: 0, x0: 1474604600000, x1: 1474604800000},
+ {count: 0, x0: 1474604800000, x1: 1474605000000},
+ {count: 0, x0: 1474605000000, x1: 1474605200000},
+ {count: 0, x0: 1474605200000, x1: 1474605400000},
+ {count: 0, x0: 1474605400000, x1: 1474605600000},
+ {count: 0, x0: 1474605600000, x1: 1474605800000},
+ {count: 0, x0: 1474605800000, x1: 1474606000000},
+ {count: 0, x0: 1474606000000, x1: 1474606200000},
+ {count: 0, x0: 1474606200000, x1: 1474606400000},
+ {count: 0, x0: 1474606400000, x1: 1474606600000},
+ {count: 0, x0: 1474606600000, x1: 1474606800000},
+ {count: 3, x0: 1474606800000, x1: 1474607000000},
+ {count: 0, x0: 1474607000000, x1: 1474607200000},
+ {count: 0, x0: 1474607200000, x1: 1474607400000},
+ {count: 0, x0: 1474607400000, x1: 1474607600000},
+ {count: 0, x0: 1474607600000, x1: 1474607800000},
+ {count: 0, x0: 1474607800000, x1: 1474608000000},
+ {count: 0, x0: 1474608000000, x1: 1474608200000},
+ {count: 0, x0: 1474608200000, x1: 1474608400000},
+ {count: 0, x0: 1474608400000, x1: 1474608600000},
+ {count: 0, x0: 1474608600000, x1: 1474608800000},
+ {count: 0, x0: 1474608800000, x1: 1474609000000},
+ {count: 0, x0: 1474609000000, x1: 1474609200000},
+ {count: 0, x0: 1474609200000, x1: 1474609400000},
+ {count: 0, x0: 1474609400000, x1: 1474609600000},
+ {count: 0, x0: 1474609600000, x1: 1474609800000},
+ {count: 0, x0: 1474609800000, x1: 1474610000000},
+ {count: 0, x0: 1474610000000, x1: 1474610200000},
+ {count: 0, x0: 1474610200000, x1: 1474610400000},
+ {count: 3, x0: 1474610400000, x1: 1474610600000},
+ {count: 0, x0: 1474610600000, x1: 1474610800000},
+ {count: 0, x0: 1474610800000, x1: 1474611000000},
+ {count: 0, x0: 1474611000000, x1: 1474611200000},
+ {count: 0, x0: 1474611200000, x1: 1474611400000},
+ {count: 0, x0: 1474611400000, x1: 1474611600000},
+ {count: 0, x0: 1474611600000, x1: 1474611800000},
+ {count: 0, x0: 1474611800000, x1: 1474612000000},
+ {count: 0, x0: 1474612000000, x1: 1474612200000},
+ {count: 0, x0: 1474612200000, x1: 1474612400000},
+ {count: 0, x0: 1474612400000, x1: 1474612600000},
+ {count: 0, x0: 1474612600000, x1: 1474612800000},
+ {count: 0, x0: 1474612800000, x1: 1474613000000},
+ {count: 0, x0: 1474613000000, x1: 1474613200000},
+ {count: 0, x0: 1474613200000, x1: 1474613400000},
+ {count: 0, x0: 1474613400000, x1: 1474613600000},
+ {count: 0, x0: 1474613600000, x1: 1474613800000},
+ {count: 0, x0: 1474613800000, x1: 1474614000000},
+ {count: 5, x0: 1474614000000, x1: 1474614200000},
+ {count: 0, x0: 1474614200000, x1: 1474614400000},
+ {count: 0, x0: 1474614400000, x1: 1474614600000},
+ {count: 0, x0: 1474614600000, x1: 1474614800000},
+ {count: 0, x0: 1474614800000, x1: 1474615000000},
+ {count: 0, x0: 1474615000000, x1: 1474615200000},
+ {count: 0, x0: 1474615200000, x1: 1474615400000},
+ {count: 0, x0: 1474615400000, x1: 1474615600000},
+ {count: 0, x0: 1474615600000, x1: 1474615800000},
+ {count: 0, x0: 1474615800000, x1: 1474616000000},
+ {count: 0, x0: 1474616000000, x1: 1474616200000},
+ {count: 0, x0: 1474616200000, x1: 1474616400000},
+ {count: 0, x0: 1474616400000, x1: 1474616600000},
+ {count: 0, x0: 1474616600000, x1: 1474616800000},
+ {count: 0, x0: 1474616800000, x1: 1474617000000},
+ {count: 0, x0: 1474617000000, x1: 1474617200000},
+ {count: 0, x0: 1474617200000, x1: 1474617400000},
+ {count: 0, x0: 1474617400000, x1: 1474617600000},
+ {count: 3, x0: 1474617600000, x1: 1474617600000}
+];
+
+export const timeFilterProps = {
+ domain: [1474588800000, 1474617600000],
+ step: 1000,
+ mappedValue: timeMappedValue,
+ histogram: timeHistogram,
+ enlargedHistogram: enlargedTimeHistogram,
+ fieldType: 'timestamp',
+ type: 'timeRange',
+ enlarged: true,
+ fixedDomain: true,
+ value: [1474588800000, 1474617600000]
+};
+
+export const mergedTimeFilter = {
+ ...timeFilterProps,
+ dataId: [dataId],
+ freeze: true,
+ id: 'time-0',
+ fixedDomain: true,
+ enlarged: true,
+ isAnimating: false,
+ speed: 1,
+ name: ['time'],
+ type: 'timeRange',
+ fieldIdx: [7],
+ plotType: 'histogram',
+ yAxis: null,
+ interval: null,
+ value: [1474606800000, 1474617600000]
+};
+
+export const dateFilterProps ={
+ domain: ['2016-09-23', '2016-09-24', '2016-10-10'],
+ fieldType: 'date',
+ type: 'multiSelect',
+ value: []
+}
+
+export const mergedDateFilter = {
+ ...dateFilterProps,
+ dataId: [dataId],
+ freeze: true,
+ id: 'date-2',
+ fixedDomain: false,
+ enlarged: false,
+ isAnimating: false,
+ speed: 1,
+ name: ['date'],
+ type: 'multiSelect',
+ fieldIdx: [10],
+ value: ['2016-09-24', '2016-09-23'],
+ plotType: 'histogram',
+ yAxis: null,
+ interval: null
+}
+
export const wktCsvFields = [
{
type: 'integer',
@@ -944,7 +1216,12 @@ export const updatedLayerV2 = {
},
geometry: {
type: 'Polygon',
- coordinates: [[[-74.387589, 40.632238], [-74.387589, 40.632238]]]
+ coordinates: [
+ [
+ [-74.387589, 40.632238],
+ [-74.387589, 40.632238]
+ ]
+ ]
}
},
{
@@ -979,7 +1256,12 @@ export const updatedLayerV2 = {
[-74.566993, 41.087294]
]
],
- [[[-74.593264, 41.088526], [-74.593264, 41.088526]]]
+ [
+ [
+ [-74.593264, 41.088526],
+ [-74.593264, 41.088526]
+ ]
+ ]
]
}
},
@@ -990,7 +1272,10 @@ export const updatedLayerV2 = {
},
geometry: {
type: 'LineString',
- coordinates: [[-74.387589, 40.632238], [-74.387589, 40.632238]]
+ coordinates: [
+ [-74.387589, 40.632238],
+ [-74.387589, 40.632238]
+ ]
}
}
],
diff --git a/test/helpers/mock-state.js b/test/helpers/mock-state.js
index f984eefb9..4a35d12fe 100644
--- a/test/helpers/mock-state.js
+++ b/test/helpers/mock-state.js
@@ -30,8 +30,16 @@ import {addDataToMap} from 'actions/actions';
import {DEFAULT_TEXT_LABEL, DEFAULT_COLOR_RANGE, DEFAULT_LAYER_OPACITY} from 'layers/layer-factory';
// fixtures
-import {testFields, testAllData} from 'test/fixtures/test-csv-data';
-import {fields, rows} from 'test/fixtures/geojson';
+import {
+ dataId as csvDataId,
+ testFields,
+ testAllData
+} from 'test/fixtures/test-csv-data';
+import {
+ fields,
+ rows,
+ geoJsonDataId
+} from 'test/fixtures/geojson';
import {
fields as tripFields,
rows as tripRows,
@@ -43,17 +51,19 @@ import {processGeojson} from 'processors/data-processor';
const geojsonFields = cloneDeep(fields);
const geojsonRows = cloneDeep(rows);
+export const testCsvDataId = csvDataId;
+export const testGeoJsonDataId = geoJsonDataId;
-const csvInfo = {
- id: '190vdll3di',
+export const csvInfo = {
+ id: testCsvDataId,
label: 'hello.csv',
queryType: 'file',
queryOption: 'csv',
params: {file: null}
};
-const geojsonInfo = {
- id: 'ieukmgne',
+export const geojsonInfo = {
+ id: testGeoJsonDataId,
label: 'zip.geojson',
queryType: 'file',
queryOption: 'geojson',
@@ -134,7 +144,7 @@ function mockStateWithFilters(state) {
const prepareState = applyActions(keplerGlReducer, initialState, [
// add filter
- {action: VisStateActions.addFilter, payload: ['190vdll3di']},
+ {action: VisStateActions.addFilter, payload: [testCsvDataId]},
// set filter to 'time'
{action: VisStateActions.setFilter, payload: [0, 'name', 'time']},
@@ -146,7 +156,7 @@ function mockStateWithFilters(state) {
},
// add another filter
- {action: VisStateActions.addFilter, payload: ['ieukmgne']},
+ {action: VisStateActions.addFilter, payload: [testGeoJsonDataId]},
// set filter to 'RATE'
{action: VisStateActions.setFilter, payload: [1, 'name', 'RATE']},
@@ -163,6 +173,40 @@ function mockStateWithFilters(state) {
return prepareState;
}
+function mockStateWithMultiFilters() {
+ const initialState = mockStateWithFilters();
+
+ const prepareState = applyActions(keplerGlReducer, initialState, [
+ // add filter
+ {action: VisStateActions.addFilter, payload: [testCsvDataId]},
+
+ // set filter to 'time'
+ {action: VisStateActions.setFilter, payload: [2, 'name', 'date']},
+
+ // set filter value
+ {
+ action: VisStateActions.setFilter,
+ payload: [2, 'value', ['2016-09-24', '2016-09-23']]
+ },
+
+ // add another filter
+ {action: VisStateActions.addFilter, payload: [testGeoJsonDataId]},
+
+ // set filter to 'RATE'
+ {action: VisStateActions.setFilter, payload: [3, 'name', 'TRIPS']},
+
+ // set filter value
+ {action: VisStateActions.setFilter, payload: [3, 'value', [4, 12]]}
+ ]);
+
+ // replace filter id with controlled value for easy testing
+ prepareState.visState.filters.forEach((f, i) => {
+ f.id = `${f.name}-${i}`;
+ });
+
+ return prepareState;
+}
+
/**
* Mock state will contain 1 heatmap, 1 point and 1 arc layer, 1 hexbin layer and 1 time filter
* @param {*} state
@@ -186,10 +230,10 @@ function mockStateWithLayerDimensions(state) {
const initialState = state || mockStateWithFileUpload();
const layer0 = initialState.visState.layers.find(
- l => l.config.dataId === '190vdll3di' && l.type === 'point'
+ l => l.config.dataId === testCsvDataId && l.type === 'point'
);
- const colorField = initialState.visState.datasets['190vdll3di'].fields.find(
+ const colorField = initialState.visState.datasets[testCsvDataId].fields.find(
f => f.name === 'gps_data.types'
);
@@ -202,7 +246,7 @@ function mockStateWithLayerDimensions(state) {
];
const textLabelField = initialState.visState.datasets[
- '190vdll3di'
+ testCsvDataId
].fields.find(f => f.name === 'date');
const textLabelPayload1 = [layer0, 0, 'field', textLabelField];
@@ -243,7 +287,7 @@ function mockStateWithLayerDimensions(state) {
hexagonLayer.id = 'hexagon-2';
const updateLayerConfig = {
- dataId: '190vdll3di',
+ dataId: testCsvDataId,
columns: {
lat: {value: 'gps_data.lat', fieldIdx: 1},
lng: {value: 'gps_data.lng', fieldIdx: 2}
@@ -329,7 +373,7 @@ export const expectedSavedLayer0 = {
id: 'hexagon-2',
type: 'hexagon',
config: {
- dataId: '190vdll3di',
+ dataId: testCsvDataId,
label: 'new layer',
color: [2, 2, 2],
columns: {
@@ -365,7 +409,7 @@ export const expectedLoadedLayer0 = {
id: 'hexagon-2',
type: 'hexagon',
config: {
- dataId: '190vdll3di',
+ dataId: testCsvDataId,
label: 'new layer',
color: [2, 2, 2],
columns: {
@@ -399,7 +443,7 @@ export const expectedSavedLayer1 = {
id: 'point-0',
type: 'point',
config: {
- dataId: '190vdll3di',
+ dataId: testCsvDataId,
label: 'gps data',
color: [0, 0, 0],
columns: {
@@ -453,7 +497,7 @@ export const expectedLoadedLayer1 = {
id: 'point-0',
type: 'point',
config: {
- dataId: '190vdll3di',
+ dataId: testCsvDataId,
label: 'gps data',
color: [0, 0, 0],
columns: {
@@ -505,7 +549,7 @@ export const expectedSavedLayer2 = {
id: 'geojson-1',
type: 'geojson',
config: {
- dataId: 'ieukmgne',
+ dataId: testGeoJsonDataId,
label: 'zip',
color: [1, 1, 1],
columns: {
@@ -548,7 +592,7 @@ export const expectedLoadedLayer2 = {
id: 'geojson-1',
type: 'geojson',
config: {
- dataId: 'ieukmgne',
+ dataId: testGeoJsonDataId,
label: 'zip',
color: [1, 1, 1],
columns: {
@@ -590,6 +634,7 @@ export const StateWFilters = mockStateWithFilters();
export const StateWFilesFiltersLayerColor = mockStateWithLayerDimensions(
StateWFilters
);
+export const StateWMultiFilters = mockStateWithMultiFilters();
export const StateWCustomMapStyle = mockStateWithCustomMapStyle();
export const StateWSplitMaps = mockStateWithSplitMaps();
diff --git a/test/node/reducers/vis-state-merger-test.js b/test/node/reducers/vis-state-merger-test.js
index 555e61a61..fd54ea8f4 100644
--- a/test/node/reducers/vis-state-merger-test.js
+++ b/test/node/reducers/vis-state-merger-test.js
@@ -44,17 +44,20 @@ import {
mergedLayers as mergedLayersV0,
mergedInteractions as mergedInteractionsV0
} from 'test/fixtures/state-saved-v0';
+
import {
savedStateV1,
mergedFilters as mergedFiltersV1,
mergedLayers as mergedLayersV1,
mergedInteraction as MergedInteractionV1,
} from 'test/fixtures/state-saved-v1-1';
+
import {
savedStateV1 as savedStateV1Split,
mergedLayers as mergedLayersV1Split,
mergedSplitMaps as mergedSplitMapsV1
} from 'test/fixtures/state-saved-v1-3';
+
import {
stateSavedV1 as savedStateV1Label,
mergedLayers as mergedLayersV1Label
@@ -70,16 +73,37 @@ import {
} from 'test/fixtures/state-saved-v1-6';
// helpers
-import {cmpFilters, cmpLayers} from 'test/helpers/comparison-utils';
+import {cmpFilters, cmpLayers, cmpDatasets} from 'test/helpers/comparison-utils';
// mock app state
import {
InitialState,
StateWFilters,
+ StateWMultiFilters,
StateWFilesFiltersLayerColor,
- StateWSplitMaps
+ StateWSplitMaps,
+ testCsvDataId,
+ testGeoJsonDataId
} from 'test/helpers/mock-state';
+import {
+ datasetCsvFields,
+ testAllData,
+ timeFilterProps,
+ dateFilterProps,
+ mergedTimeFilter,
+ mergedDateFilter
+} from 'test/fixtures/test-csv-data';
+
+import {
+ datasetFields as testGeoJsonFields,
+ datasetAllData as testGeoJsonAllData,
+ geoJsonRateFilterProps,
+ geoJsonTripFilterProps,
+ mergedTripFilter,
+ mergedRateFilter
+} from 'test/fixtures/geojson';
+
test('VisStateMerger.v0 -> mergeFilters -> toEmptyState', t => {
const savedConfig = cloneDeep(savedStateV0);
const oldState = cloneDeep(InitialState);
@@ -661,14 +685,14 @@ test('VisStateMerger.v0 -> mergeInteractions -> toWorkingState', t => {
enabled: true,
config: {
fieldsToShow: {
- '190vdll3di': [
+ [testCsvDataId]: [
'gps_data.utc_timestamp',
'gps_data.types',
'epoch',
'has_result',
'id'
],
- ieukmgne: ['OBJECTID', 'ZIP_CODE', 'ID', 'TRIPS', 'RATE'],
+ [testGeoJsonDataId]: ['OBJECTID', 'ZIP_CODE', 'ID', 'TRIPS', 'RATE'],
'9h10t7fyb': ['int_range', 'detail', 'type_boolean'],
v79816te8: ['ID', 'ZIP_CODE']
}
@@ -816,14 +840,14 @@ test('VisStateMerger.v1 -> mergeInteractions -> toWorkingState', t => {
enabled: false,
config: {
fieldsToShow: {
- '190vdll3di': [
+ [testCsvDataId]: [
'gps_data.utc_timestamp',
'gps_data.types',
'epoch',
'has_result',
'id'
],
- ieukmgne: ['OBJECTID', 'ZIP_CODE', 'ID', 'TRIPS', 'RATE']
+ [testGeoJsonDataId]: ['OBJECTID', 'ZIP_CODE', 'ID', 'TRIPS', 'RATE']
}
}
},
@@ -860,14 +884,14 @@ test('VisStateMerger.v1 -> mergeInteractions -> toWorkingState', t => {
enabled: false,
config: {
fieldsToShow: {
- '190vdll3di': [
+ [testCsvDataId]: [
'gps_data.utc_timestamp',
'gps_data.types',
'epoch',
'has_result',
'id'
],
- ieukmgne: ['OBJECTID', 'ZIP_CODE', 'ID', 'TRIPS', 'RATE'],
+ [testGeoJsonDataId]: ['OBJECTID', 'ZIP_CODE', 'ID', 'TRIPS', 'RATE'],
a5ybmwl2d: ['a_zip', 'str_type', 'int_type']
}
}
@@ -1146,3 +1170,76 @@ test('VisStateMerger.v1 -> mergeFilters -> nonValidFilter', t => {
cmpFilters(t, [], stateWData.filters);
t.end();
});
+
+test('VisStateMerger.v1 -> mergeFilters -> multiFilters', t => {
+ const stateToSave = cloneDeep(StateWMultiFilters);
+ const oldCsvData = stateToSave.visState.datasets[testCsvDataId];
+ const oldGeoJsonData = stateToSave.visState.datasets[testGeoJsonDataId];
+ const appStateToSave = SchemaManager.save(stateToSave);
+ const stateParsed = SchemaManager.load(appStateToSave);
+
+ const oldState = cloneDeep(InitialState);
+ const oldVisState = oldState.visState;
+
+ const mergedState = visStateReducer(oldVisState,
+ updateVisData(
+ stateParsed.datasets,
+ {},
+ stateParsed.config
+ ));
+ // check datasets is filtered
+ // and field has filterProps
+ const expectedDatasets = {
+ [testCsvDataId]: {
+ fields: datasetCsvFields.map(f => ({
+ ...f,
+ ...(
+ f.name === 'time' ?
+ {filterProps: timeFilterProps} : f.name === 'date' ?
+ {filterProps: dateFilterProps} : {}
+ )
+ })),
+ allData: testAllData,
+ id: testCsvDataId,
+ label: 'hello.csv',
+ color: 'donot test me',
+ data: [
+ testAllData[9],
+ testAllData[10]
+ ],
+ filteredIndex: [9, 10],
+ filteredIndexForDomain: [0, 1, 2, 3, 7, 8, 9, 10, 11, 12],
+ fieldPairs: oldCsvData.fieldPairs
+ },
+ [testGeoJsonDataId]: {
+ fields: testGeoJsonFields.map(f => ({
+ ...f,
+ ...(
+ f.name === 'TRIPS' ?
+ {filterProps: geoJsonTripFilterProps} : f.name === 'RATE' ?
+ {filterProps: geoJsonRateFilterProps} : {}
+ )
+ })),
+ allData: testGeoJsonAllData,
+ id: testGeoJsonDataId,
+ label: 'zip.geojson',
+ color: 'donot test me',
+ data: [testGeoJsonAllData[0]],
+ filteredIndex: [0],
+ filteredIndexForDomain: [0],
+ fieldPairs: oldGeoJsonData.fieldPairs
+ }
+ };
+
+ cmpDatasets(t, expectedDatasets, mergedState.datasets);
+
+ const expectedFilters = [
+ mergedTimeFilter,
+ mergedRateFilter,
+ mergedDateFilter,
+ mergedTripFilter
+ ];
+
+ cmpFilters(t, expectedFilters, mergedState.filters);
+ t.end();
+});
diff --git a/test/node/reducers/vis-state-test.js b/test/node/reducers/vis-state-test.js
index cf2e930f6..85d38eba1 100644
--- a/test/node/reducers/vis-state-test.js
+++ b/test/node/reducers/vis-state-test.js
@@ -49,6 +49,7 @@ import testData, {testFields, testAllData} from 'test/fixtures/test-csv-data';
import {
geojsonData,
geoBounds,
+ geoJsonTripFilterProps,
fields as geojsonFields
} from 'test/fixtures/geojson';
@@ -66,7 +67,9 @@ import {
StateWTripGeojson,
StateWSplitMaps,
StateWFilters,
- StateWFiles
+ StateWFiles,
+ testCsvDataId,
+ testGeoJsonDataId
} from 'test/helpers/mock-state';
import {
LAYER_VIS_CONFIGS,
@@ -2045,7 +2048,7 @@ test('#visStateReducer -> SET_FILTER.name', t => {
const expectedFilter0 = oldFilter0;
const expectedFilter1 = {
- dataId: ['ieukmgne'],
+ dataId: [testGeoJsonDataId],
freeze: true,
id: 'RATE-1',
fixedDomain: false,
@@ -2102,126 +2105,6 @@ test('#visStateReducer -> SET_FILTER (processGeojson)', t => {
VisStateActions.setFilter(0, 'name', 'TRIPS')
);
- const expectedHistogram = [
- {count: 1, x0: 4, x1: 4.5},
- {count: 0, x0: 4.5, x1: 5},
- {count: 0, x0: 5, x1: 5.5},
- {count: 0, x0: 5.5, x1: 6},
- {count: 0, x0: 6, x1: 6.5},
- {count: 0, x0: 6.5, x1: 7},
- {count: 0, x0: 7, x1: 7.5},
- {count: 0, x0: 7.5, x1: 8},
- {count: 0, x0: 8, x1: 8.5},
- {count: 0, x0: 8.5, x1: 9},
- {count: 0, x0: 9, x1: 9.5},
- {count: 0, x0: 9.5, x1: 10},
- {count: 0, x0: 10, x1: 10.5},
- {count: 0, x0: 10.5, x1: 11},
- {count: 1, x0: 11, x1: 11.5},
- {count: 0, x0: 11.5, x1: 12},
- {count: 0, x0: 12, x1: 12.5},
- {count: 0, x0: 12.5, x1: 13},
- {count: 0, x0: 13, x1: 13.5},
- {count: 0, x0: 13.5, x1: 14},
- {count: 0, x0: 14, x1: 14.5},
- {count: 0, x0: 14.5, x1: 15},
- {count: 0, x0: 15, x1: 15.5},
- {count: 0, x0: 15.5, x1: 16},
- {count: 0, x0: 16, x1: 16.5},
- {count: 0, x0: 16.5, x1: 17},
- {count: 0, x0: 17, x1: 17.5},
- {count: 0, x0: 17.5, x1: 18},
- {count: 0, x0: 18, x1: 18.5},
- {count: 0, x0: 18.5, x1: 19},
- {count: 0, x0: 19, x1: 19.5},
- {count: 0, x0: 19.5, x1: 20},
- {count: 1, x0: 20, x1: 20}
- ];
-
- const expectedEnlarged = [
- {count: 1, x0: 4, x1: 4.2},
- {count: 0, x0: 4.2, x1: 4.4},
- {count: 0, x0: 4.4, x1: 4.6},
- {count: 0, x0: 4.6, x1: 4.8},
- {count: 0, x0: 4.8, x1: 5},
- {count: 0, x0: 5, x1: 5.2},
- {count: 0, x0: 5.2, x1: 5.4},
- {count: 0, x0: 5.4, x1: 5.6},
- {count: 0, x0: 5.6, x1: 5.8},
- {count: 0, x0: 5.8, x1: 6},
- {count: 0, x0: 6, x1: 6.2},
- {count: 0, x0: 6.2, x1: 6.4},
- {count: 0, x0: 6.4, x1: 6.6},
- {count: 0, x0: 6.6, x1: 6.8},
- {count: 0, x0: 6.8, x1: 7},
- {count: 0, x0: 7, x1: 7.2},
- {count: 0, x0: 7.2, x1: 7.4},
- {count: 0, x0: 7.4, x1: 7.6},
- {count: 0, x0: 7.6, x1: 7.8},
- {count: 0, x0: 7.8, x1: 8},
- {count: 0, x0: 8, x1: 8.2},
- {count: 0, x0: 8.2, x1: 8.4},
- {count: 0, x0: 8.4, x1: 8.6},
- {count: 0, x0: 8.6, x1: 8.8},
- {count: 0, x0: 8.8, x1: 9},
- {count: 0, x0: 9, x1: 9.2},
- {count: 0, x0: 9.2, x1: 9.4},
- {count: 0, x0: 9.4, x1: 9.6},
- {count: 0, x0: 9.6, x1: 9.8},
- {count: 0, x0: 9.8, x1: 10},
- {count: 0, x0: 10, x1: 10.2},
- {count: 0, x0: 10.2, x1: 10.4},
- {count: 0, x0: 10.4, x1: 10.6},
- {count: 0, x0: 10.6, x1: 10.8},
- {count: 0, x0: 10.8, x1: 11},
- {count: 1, x0: 11, x1: 11.2},
- {count: 0, x0: 11.2, x1: 11.4},
- {count: 0, x0: 11.4, x1: 11.6},
- {count: 0, x0: 11.6, x1: 11.8},
- {count: 0, x0: 11.8, x1: 12},
- {count: 0, x0: 12, x1: 12.2},
- {count: 0, x0: 12.2, x1: 12.4},
- {count: 0, x0: 12.4, x1: 12.6},
- {count: 0, x0: 12.6, x1: 12.8},
- {count: 0, x0: 12.8, x1: 13},
- {count: 0, x0: 13, x1: 13.2},
- {count: 0, x0: 13.2, x1: 13.4},
- {count: 0, x0: 13.4, x1: 13.6},
- {count: 0, x0: 13.6, x1: 13.8},
- {count: 0, x0: 13.8, x1: 14},
- {count: 0, x0: 14, x1: 14.2},
- {count: 0, x0: 14.2, x1: 14.4},
- {count: 0, x0: 14.4, x1: 14.6},
- {count: 0, x0: 14.6, x1: 14.8},
- {count: 0, x0: 14.8, x1: 15},
- {count: 0, x0: 15, x1: 15.2},
- {count: 0, x0: 15.2, x1: 15.4},
- {count: 0, x0: 15.4, x1: 15.6},
- {count: 0, x0: 15.6, x1: 15.8},
- {count: 0, x0: 15.8, x1: 16},
- {count: 0, x0: 16, x1: 16.2},
- {count: 0, x0: 16.2, x1: 16.4},
- {count: 0, x0: 16.4, x1: 16.6},
- {count: 0, x0: 16.6, x1: 16.8},
- {count: 0, x0: 16.8, x1: 17},
- {count: 0, x0: 17, x1: 17.2},
- {count: 0, x0: 17.2, x1: 17.4},
- {count: 0, x0: 17.4, x1: 17.6},
- {count: 0, x0: 17.6, x1: 17.8},
- {count: 0, x0: 17.8, x1: 18},
- {count: 0, x0: 18, x1: 18.2},
- {count: 0, x0: 18.2, x1: 18.4},
- {count: 0, x0: 18.4, x1: 18.6},
- {count: 0, x0: 18.6, x1: 18.8},
- {count: 0, x0: 18.8, x1: 19},
- {count: 0, x0: 19, x1: 19.2},
- {count: 0, x0: 19.2, x1: 19.4},
- {count: 0, x0: 19.4, x1: 19.6},
- {count: 0, x0: 19.6, x1: 19.8},
- {count: 0, x0: 19.8, x1: 20},
- {count: 1, x0: 20, x1: 20}
- ];
-
const expectedFilterWName = {
dataId: ['milkshake'],
freeze: true,
@@ -2343,16 +2226,7 @@ test('#visStateReducer -> SET_FILTER (processGeojson)', t => {
? {
...f,
id: f.name,
- filterProps: {
- domain: [4, 20],
- fieldType: 'integer',
- histogram: expectedHistogram,
- enlargedHistogram: expectedEnlarged,
- step: 0.01,
- type: 'range',
- typeOptions: ['range'],
- value: [4, 20]
- }
+ filterProps: geoJsonTripFilterProps
}
: {...f, id: f.name}
),
@@ -2755,7 +2629,7 @@ test('#visStateReducer -> REMOVE_DATASET w filter and layer', t => {
layerData: [oldState.layerData[1]],
layerOrder: [0],
datasets: {
- ieukmgne: oldState.datasets.ieukmgne
+ [testGeoJsonDataId]: oldState.datasets[testGeoJsonDataId]
},
interactionConfig: {
tooltip: {
@@ -2764,7 +2638,7 @@ test('#visStateReducer -> REMOVE_DATASET w filter and layer', t => {
iconComponent: oldState.interactionConfig.tooltip.iconComponent,
config: {
fieldsToShow: {
- ieukmgne: ['OBJECTID', 'ZIP_CODE', 'ID', 'TRIPS', 'RATE']
+ [testGeoJsonDataId]: ['OBJECTID', 'ZIP_CODE', 'ID', 'TRIPS', 'RATE']
}
}
},
@@ -2788,7 +2662,7 @@ test('#visStateReducer -> REMOVE_DATASET w filter and layer', t => {
const newReducer = reducer(
oldState,
- VisStateActions.removeDataset('190vdll3di')
+ VisStateActions.removeDataset(testCsvDataId)
);
t.deepEqual(
@@ -2966,7 +2840,7 @@ test('#visStateReducer -> SPLIT_MAP: REMOVE_DATASET', t => {
layerData: [oldState.layerData[0]],
layerOrder: [0],
datasets: {
- '190vdll3di': oldState.datasets['190vdll3di']
+ [testCsvDataId]: oldState.datasets[testCsvDataId]
},
filters: [],
interactionConfig: {
@@ -2976,7 +2850,7 @@ test('#visStateReducer -> SPLIT_MAP: REMOVE_DATASET', t => {
iconComponent: oldState.interactionConfig.tooltip.iconComponent,
config: {
fieldsToShow: {
- '190vdll3di': [
+ [testCsvDataId]: [
'gps_data.utc_timestamp',
'gps_data.types',
'epoch',
@@ -3006,7 +2880,7 @@ test('#visStateReducer -> SPLIT_MAP: REMOVE_DATASET', t => {
const newReducer = reducer(
oldState,
- VisStateActions.removeDataset('ieukmgne')
+ VisStateActions.removeDataset(testGeoJsonDataId)
);
t.deepEqual(
diff --git a/test/node/schemas/vis-state-schema-test.js b/test/node/schemas/vis-state-schema-test.js
index ab7309a06..27f08d62a 100644
--- a/test/node/schemas/vis-state-schema-test.js
+++ b/test/node/schemas/vis-state-schema-test.js
@@ -32,7 +32,9 @@ import {
expectedSavedLayer2,
expectedLoadedLayer2,
StateWTripGeojson,
- expectedSavedTripLayer
+ expectedSavedTripLayer,
+ testCsvDataId,
+ testGeoJsonDataId
} from 'test/helpers/mock-state';
test('#visStateSchema -> v1 -> save layers', t => {
@@ -93,7 +95,7 @@ test('#visStateSchema -> v1 -> save load filters', t => {
const filtersToSave = vsToSave.filters;
const expectedSavedFilters = [{
- dataId: ['190vdll3di'],
+ dataId: [testCsvDataId],
id: 'hjpn8frza',
name: ['time'],
type: 'timeRange',
@@ -102,7 +104,7 @@ test('#visStateSchema -> v1 -> save load filters', t => {
plotType: 'histogram',
yAxis: null
}, {
- dataId: ['ieukmgne'],
+ dataId: [testGeoJsonDataId],
id: 'vpk2466o',
name: ['RATE'],
type: 'multiSelect',
@@ -130,14 +132,14 @@ test('#visStateSchema -> v1 -> save load interaction', t => {
tooltip: {
enabled: true,
fieldsToShow: {
- '190vdll3di': [
+ [testCsvDataId]: [
'gps_data.utc_timestamp',
'gps_data.types',
'epoch',
'has_result',
'id'
],
- ieukmgne: [
+ [testGeoJsonDataId]: [
'OBJECTID', 'ZIP_CODE', 'ID', 'TRIPS', 'RATE'
]}},
brush: {