Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function selectTimePoint(...timepoints: ITacoTimePoint[]) {
// remove timepoints that are already selected
timepoints = timepoints.filter((d) => selectedTimePoints.indexOf(d) === -1);
if (timepoints.length > 2) {
timepoints = timepoints.slice(0, 2);
}
selectedTimePoints.push(...timepoints);
// sort elements by time -> [0] = earlier = source; [1] = later = destination
selectedTimePoints = selectedTimePoints.sort((a, b) => d3.ascending(a.time.toISOString(), b.time.toISOString()));
hash.setProp(AppConstants.HASH_PROPS.TIME_POINTS, selectedTimePoints.map((d) => d.key).join(','));
hash.removeProp(AppConstants.HASH_PROPS.DETAIL_VIEW);
events.fire(AppConstants.EVENT_TIME_POINTS_SELECTED, selectedTimePoints);
// clear after 2 selected time points
if (selectedTimePoints.length === 2) {
selectedTimePoints = [];
}
}
private updateSelectionHash() {
if (!this.trackedSelections) {
return;
}
const ranges = this.trackedSelections.productSelections();
const value = ranges.map((r) => r.toString()).join(';');
hash.setProp(AppConstants.HASH_PROPS.SELECTION, value);
}
static updateFilterHash() {
hash.setProp(AppConstants.HASH_PROPS.FILTER, ChangeTypes.TYPE_ARRAY.filter((d) => d.isActive).map((d) => d.abbr).join(''));
}
}
.on('change', () => {
const selectedData = this.$select.selectAll('option')
.filter((d, i) => i === this.$select.property('selectedIndex'))
.data();
hash.setProp(AppConstants.HASH_PROPS.DATASET, selectedData[0].key);
hash.removeProp(AppConstants.HASH_PROPS.TIME_POINTS);
hash.removeProp(AppConstants.HASH_PROPS.DETAIL_VIEW);
hash.removeProp(AppConstants.HASH_PROPS.SELECTION);
if (selectedData.length > 0) {
events.fire(AppConstants.EVENT_DATA_COLLECTION_SELECTED, selectedData[0].values);
this.trackSelections(selectedData[0].values[0].item);
}
});
}