Functional date filter
Этот коммит содержится в:
		
							родитель
							
								
									0c0b0b0d25
								
							
						
					
					
						Коммит
						09891a8959
					
				| @ -14,12 +14,16 @@ | |||||||
| 		attributionScoreFilter, | 		attributionScoreFilter, | ||||||
| 		attributionScoreDef, | 		attributionScoreDef, | ||||||
| 		textSearchFilter, | 		textSearchFilter, | ||||||
|  | 		timeRangeFilter, | ||||||
|  | 		fullTimeRange | ||||||
| 	} from '../../stores/filters'; | 	} from '../../stores/filters'; | ||||||
| 
 | 
 | ||||||
| 	export let cases; | 	export let cases; | ||||||
| 
 | 
 | ||||||
| 	function handleButtonClick() { | 	function handleButtonClick() { | ||||||
| 		selectAllFilters(); | 		selectAllFilters(); | ||||||
|  | 		timeRangeFilter.set($fullTimeRange); | ||||||
|  | 		timeDummyRange = [0, 10] | ||||||
| 		/*contextData.unselectAll(); | 		/*contextData.unselectAll(); | ||||||
|     $highlightPolarization = false; |     $highlightPolarization = false; | ||||||
|     $highlightCib = false; |     $highlightCib = false; | ||||||
| @ -44,6 +48,8 @@ | |||||||
| 				.filter((a) => a === d.id).length | 				.filter((a) => a === d.id).length | ||||||
| 		})); | 		})); | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	let timeDummyRange = [0, 10] | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| {#if cases} | {#if cases} | ||||||
| @ -96,11 +102,11 @@ | |||||||
| 				on:itemsRemoved={(e) => methodFilter.unselect(e.detail)} | 				on:itemsRemoved={(e) => methodFilter.unselect(e.detail)} | ||||||
| 			></Dropdown> | 			></Dropdown> | ||||||
| 			<DateRangeSlider | 			<DateRangeSlider | ||||||
| 				value={[0, 20]} | 				value={timeDummyRange} | ||||||
| 				label="Date range" | 				label="Date Range" | ||||||
| 				min={0} | 				min={0} | ||||||
| 				max={20} | 				max={10} | ||||||
| 				showHandleLabels={true} | 				showHandleLabels={false} | ||||||
| 				startColor={'#ffffff'} | 				startColor={'#ffffff'} | ||||||
| 				stopColor={'#000000'} | 				stopColor={'#000000'} | ||||||
| 			/> | 			/> | ||||||
|  | |||||||
| @ -15,16 +15,16 @@ | |||||||
| 	export let metrics; | 	export let metrics; | ||||||
| 
 | 
 | ||||||
| 	const margins = { | 	const margins = { | ||||||
| 		top: 24, | 		top: 0, | ||||||
| 		right: 24, | 		right: 24, | ||||||
| 		bottom: 38, | 		bottom: 28, | ||||||
| 		left: 120 | 		left: 120 | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 	let width; | 	let width; | ||||||
| 	let height = 280; | 	let height = 200; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 	$: dateExtent = extent(cases.map((d) => new Date(d.attribution_date))); |  | ||||||
| 
 | 
 | ||||||
| 	$: xScale = scaleTime($timeRangeFilter, [0, width - margins.right - margins.left]); | 	$: xScale = scaleTime($timeRangeFilter, [0, width - margins.right - margins.left]); | ||||||
| 	$: ticks = xScale.ticks(5); | 	$: ticks = xScale.ticks(5); | ||||||
| @ -32,7 +32,7 @@ | |||||||
| 	const actorNations = ['Key event', 'China', 'Iran', 'North Korea', 'Russia']; | 	const actorNations = ['Key event', 'China', 'Iran', 'North Korea', 'Russia']; | ||||||
| 	const colors = ['#555555', '#0f4c8a', '#8a0f8a', '#8a4d0f', '#0f8a0f']; | 	const colors = ['#555555', '#0f4c8a', '#8a0f8a', '#8a4d0f', '#0f8a0f']; | ||||||
| 
 | 
 | ||||||
| 	let yScale = scalePoint(actorNations, [height - margins.bottom - margins.top, 0]).padding(1); | 	let yScale = scalePoint(actorNations, [height - margins.bottom - margins.top, 0]).padding(0.5); | ||||||
| 	let colorScale = scaleOrdinal(actorNations, colors); | 	let colorScale = scaleOrdinal(actorNations, colors); | ||||||
| 
 | 
 | ||||||
| 	$: displayCountryMetrics = $actorNationFilter.filter(d => d.selected).map(d => d.name) | 	$: displayCountryMetrics = $actorNationFilter.filter(d => d.selected).map(d => d.name) | ||||||
|  | |||||||
| @ -81,7 +81,6 @@ | |||||||
|         })      |         })      | ||||||
| 	}); | 	}); | ||||||
|      |      | ||||||
|     $: console.log($timeRangeFilter) |  | ||||||
|     $: if (cases) { |     $: if (cases) { | ||||||
|         cases = cases.map(d => ({ |         cases = cases.map(d => ({ | ||||||
|             ...d, |             ...d, | ||||||
| @ -91,6 +90,7 @@ | |||||||
|                 && haveOverlap($sourceCategoryFilter, d.Source_Category) |                 && haveOverlap($sourceCategoryFilter, d.Source_Category) | ||||||
|                 && haveOverlap($methodFilter, d.methods) |                 && haveOverlap($methodFilter, d.methods) | ||||||
|                 && withinRange($attributionScoreFilter, d.attribution_total_score) |                 && withinRange($attributionScoreFilter, d.attribution_total_score) | ||||||
|  |                 && withinRange($timeRangeFilter, d.attribution_date) | ||||||
|                 && includesTextSearch($textSearchFilter, d.search) |                 && includesTextSearch($textSearchFilter, d.search) | ||||||
|         })) |         })) | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,4 +1,6 @@ | |||||||
| import { writable } from 'svelte/store'; | import { writable } from 'svelte/store'; | ||||||
|  | import { tweened } from 'svelte/motion'; | ||||||
|  | import { cubicOut } from 'svelte/easing'; | ||||||
| //import { uniq } from 'lodash';
 | //import { uniq } from 'lodash';
 | ||||||
| 
 | 
 | ||||||
| function createRangeFilter() { | function createRangeFilter() { | ||||||
| @ -13,7 +15,10 @@ function createRangeFilter() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function createTimeRangeFilter() { | function createTimeRangeFilter() { | ||||||
|   const { subscribe, set, update } = writable([new Date('2024-01-01'), new Date()]); |   const { subscribe, set, update } = tweened([new Date('2024-01-01'), new Date()], { | ||||||
|  | 		duration: 750, | ||||||
|  | 		easing: cubicOut | ||||||
|  | 	}); | ||||||
| 
 | 
 | ||||||
|   return { |   return { | ||||||
|     subscribe, |     subscribe, | ||||||
|  | |||||||
		Загрузка…
	
	
			
			x
			
			
		
	
		Ссылка в новой задаче
	
	Block a user
	 Maarten
						Maarten