@@ -185,6 +185,15 @@ export class HomeComponent implements OnInit, AfterViewInit {
185185 timesPlayedLeftBound : number = 0 ;
186186 timesPlayedRightBound : number = Infinity ;
187187
188+ // ========================================================================
189+ // Year filter
190+ // ------------------------------------------------------------------------
191+
192+ yearMinCutoff : number = 0 ;
193+ yearCutoff : number = 0 ;
194+ yearLeftBound : number = 0 ;
195+ yearRightBound : number = Infinity ;
196+
188197 // ========================================================================
189198 // Frequency / histogram
190199 // ------------------------------------------------------------------------
@@ -719,6 +728,7 @@ export class HomeComponent implements OnInit, AfterViewInit {
719728 this . setUpDurationFilterValues ( this . imageElementService . imageElements ) ;
720729 this . setUpSizeFilterValues ( this . imageElementService . imageElements ) ;
721730 this . setUpTimesPlayedFilterValues ( this . imageElementService . imageElements ) ;
731+ this . setUpYearFilterValues ( this . imageElementService . imageElements ) ;
722732
723733 if ( this . sortOrderRef . sortFilterElement ) {
724734 this . sortOrderRef . sortFilterElement . nativeElement . value = this . sortType ;
@@ -2205,6 +2215,13 @@ export class HomeComponent implements OnInit, AfterViewInit {
22052215
22062216 }
22072217
2218+ newYearFilterSelected ( selection : number [ ] ) : void {
2219+
2220+ this . yearLeftBound = selection [ 0 ] ;
2221+ this . yearRightBound = selection [ 1 ] ;
2222+
2223+ }
2224+
22082225 setUpDurationFilterValues ( finalArray : ImageElement [ ] ) : void {
22092226 const durations : number [ ] = finalArray . map ( ( element ) => { return element . duration ; } ) ;
22102227
@@ -2225,6 +2242,14 @@ export class HomeComponent implements OnInit, AfterViewInit {
22252242 this . timesPlayedCutoff = Math . max ( ...timesPlayed ) ;
22262243 }
22272244
2245+ //need to filter otherwise cutoff will be NaN
2246+ setUpYearFilterValues ( finalArray : ImageElement [ ] ) : void {
2247+ const year : number [ ] = finalArray . map ( ( element ) => { return element . year ; } ) ;
2248+ const filtrate = el => Number . isInteger ( el ) && el > 0 ;
2249+ const yearFiltered = year . filter ( filtrate )
2250+ this . yearMinCutoff = Math . min ( ...yearFiltered ) - 1
2251+ this . yearCutoff = Math . max ( ...yearFiltered ) ;
2252+ }
22282253 /**
22292254 * Given an array of numbers
22302255 * returns the cutoff for outliers
0 commit comments