Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] filter fields based on timestamp #2714

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/components/src/common/histogram-plot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,18 @@
);

const barWidth = useMemo(() => {
const maxBins = max(groupKeys, key => {
if (histogramsByGroup[key].length > 1)
return (
(domain[1] - domain[0]) / (histogramsByGroup[key][1].x1 - histogramsByGroup[key][1].x0)
);
// TODO this part should be removed with follow ups
return (
(domain[1] - domain[0]) / (histogramsByGroup[key][0].x1 - histogramsByGroup[key][0].x0)
);
});
// find histogramsByGroup with max number of bins
const maxGroup = groupKeys.reduce((accu, key, idx) => {

Check warning on line 98 in src/components/src/common/histogram-plot.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

'idx' is defined but never used
if (histogramsByGroup[key].length > accu.length) {
return histogramsByGroup[key];
}
return accu;
}, histogramsByGroup[groupKeys[0]]);

// find the bin for measuring step
const stdBinIdx = maxGroup.length > 1 ? 1 : 0;
const xStep = maxGroup[stdBinIdx].x1 - maxGroup[stdBinIdx].x0;
const maxBins = (domain[1] - domain[0]) / xStep;
if (!maxBins) return 0;
return width / maxBins / groupKeys.length;
}, [histogramsByGroup, domain, groupKeys, width]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import FilterPanelHeaderFactory from '../../side-panel/filter-panel/filter-panel
import SourceSelectorFactory from '../../side-panel/common/source-selector';
import SourceDataSelectorFactory from '../../side-panel/common/source-data-selector';

const TIME_FIELD_ANALYZER_TYPES = ['DATE', 'TIME', 'DATETIME'];

const SyncedDatasetsArea = styled.div`
display: grid;
align-items: center;
Expand Down Expand Up @@ -50,7 +48,7 @@ function getDatasetsWithTimeField(datasets) {
}

function getTimeFields(dataset) {
return dataset.fields.filter(f => TIME_FIELD_ANALYZER_TYPES.includes(f.analyzerType));
return dataset.fields.filter(f => f.type === ALL_FIELD_TYPES.timestamp);
}

FilterSyncedDatasetPanelFactory.deps = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
import React, {useCallback, useMemo} from 'react';
import TimeRangeFilterFactory from '../time-range-filter';
import {Clock} from '../../common/icons';
import FieldPanelWithFieldSelectFactory from './filter-panel-with-field-select';
import {TimeRangeFilterPanelComponent} from './types';
import {isSideFilter, getTimelineFromFilter} from '@kepler.gl/utils';
import FilterPanelHeaderFactory from '../../side-panel/filter-panel/filter-panel-header';
import PanelHeaderActionFactory from '../../side-panel/panel-header-action';
import SourceDataSelectorFactory from '../../side-panel/common/source-data-selector';
import FieldSelectorFactory from '../../common/field-selector';
import {StyledFilterContent} from '../../common/styled-components';
import {getSupportedFilterFields} from './new-filter-panel';
Expand All @@ -20,21 +18,17 @@ import FilterSyncedDatasetPanelFactory from './filter-synced-dataset-panel';
const SYNC_FILTER_ID_LENGTH = 2;

TimeRangeFilterPanelFactory.deps = [
FieldPanelWithFieldSelectFactory,
TimeRangeFilterFactory,
FilterPanelHeaderFactory,
SourceDataSelectorFactory,
FieldSelectorFactory,
PanelHeaderActionFactory,
TimeSyncedFieldSelectorFactory,
FilterSyncedDatasetPanelFactory
];

function TimeRangeFilterPanelFactory(
FieldPanelWithFieldSelect: ReturnType<typeof FieldPanelWithFieldSelectFactory>,
TimeRangeFilter: ReturnType<typeof TimeRangeFilterFactory>,
FilterPanelHeader: ReturnType<typeof FilterPanelHeaderFactory>,
SourceDataSelector: ReturnType<typeof SourceDataSelectorFactory>,
FieldSelector: ReturnType<typeof FieldSelectorFactory>,
PanelHeaderAction: ReturnType<typeof PanelHeaderActionFactory>,
TimeSyncedFieldSelector: ReturnType<typeof TimeSyncedFieldSelectorFactory>,
Expand Down
Loading