@@ -78,7 +78,6 @@ class FilterStore implements IFilterStore {
7878 dataByYears : observable ,
7979 chartDataRanges : observable ,
8080 chartHideOutOfRange : observable ,
81- chartOutOfRangeCounts : observable ,
8281 dataSource : observable
8382 } ) ;
8483 // where
@@ -251,37 +250,6 @@ class FilterStore implements IFilterStore {
251250 this . dataSource = sourceVal ;
252251 }
253252
254- // who (delegated to WhoFilterStore)
255- // ///////////////////////////////////////////////////////////////////////////////////////////////
256-
257- get genderTypes ( ) {
258- return this . whoStore . genderTypes ;
259- }
260-
261- updateGenderType = ( aType : number , val : boolean ) => {
262- this . whoStore . updateGenderType ( aType , val ) ;
263- }
264-
265- get ageTypes ( ) {
266- return this . whoStore . ageTypes ;
267- }
268-
269- updateAgeType = ( aType : number , val : boolean ) => {
270- this . whoStore . updateAgeType ( aType , val ) ;
271- }
272-
273- get populationTypes ( ) {
274- return this . whoStore . populationTypes ;
275- }
276-
277- updatePopulationType = ( aType : number , val : boolean ) => {
278- this . whoStore . updatePopulationType ( aType , val ) ;
279- }
280-
281- @computed get isValidWho ( ) {
282- return this . whoStore . isValidWho ;
283- }
284-
285253 // ///////////////////////////////////////////////////////////////////////////////////////////////
286254 // What (delegated to WhatFilterStore)
287255 // ///////////////////////////////////////////////////////////////////////////////////////////////
@@ -405,7 +373,7 @@ class FilterStore implements IFilterStore {
405373 }
406374
407375 @computed get isValidAllFilters ( ) {
408- const res = this . severityStore . isValidSeverity && this . timeStore . isValidWhen && this . isValidWho
376+ const res = this . severityStore . isValidSeverity && this . timeStore . isValidWhen && this . whoStore . isValidWho
409377 && this . isValidWhere && this . isValidWhat && this . vehicleStore . isValidWhatVehicle && this . isValidWhatRoad ;
410378 return res ;
411379 }
@@ -698,9 +666,9 @@ class FilterStore implements IFilterStore {
698666 query += this . roads . getFilter ( ) ;
699667 query += this . roadSegment . getFilter ( ) ;
700668 query += this . vehicleStore . injTypes . getFilter ( ) ;
701- query += this . genderTypes . getFilter ( ) ;
702- query += this . ageTypes . getFilter ( ) ;
703- query += this . populationTypes . getFilter ( ) ;
669+ query += this . whoStore . genderTypes . getFilter ( ) ;
670+ query += this . whoStore . ageTypes . getFilter ( ) ;
671+ query += this . whoStore . populationTypes . getFilter ( ) ;
704672 query += this . accidentType . getFilter ( ) ;
705673 query += this . vehicleStore . vehicleType . getFilter ( ) ;
706674 query += this . vehicleStore . involvedVehicle . getFilter ( ) ;
@@ -724,9 +692,7 @@ class FilterStore implements IFilterStore {
724692 this . timeStore . endYear . setText ( ) ;
725693 this . vehicleStore . injTypes . setText ( ignoreIfAll ) ;
726694 this . timeStore . dayNight . setText ( ignoreIfAll ) ;
727- this . genderTypes . setText ( ignoreIfAll ) ;
728- this . ageTypes . setText ( ignoreIfAll ) ;
729- this . populationTypes . setText ( ignoreIfAll ) ;
695+ this . whoStore . setText ( ignoreIfAll ) ;
730696 this . locationAccuracy . setText ( ignoreIfAll ) ;
731697 this . roadTypes . setText ( ignoreIfAll ) ;
732698 const cityNamesArr = getCitiesNames ( this . cities . arrValues ) ;
@@ -752,9 +718,7 @@ class FilterStore implements IFilterStore {
752718 this . severityStore . injurySeverity . setBrowserQueryString ( params , false ) ;
753719 this . roadTypes . setBrowserQueryString ( params ) ;
754720 this . vehicleStore . injTypes . setBrowserQueryString ( params ) ;
755- this . genderTypes . setBrowserQueryString ( params ) ;
756- this . ageTypes . setBrowserQueryString ( params ) ;
757- this . populationTypes . setBrowserQueryString ( params ) ;
721+ this . whoStore . setBrowserQueryString ( params ) ;
758722 this . cities . setBrowserQueryString ( params ) ;
759723 this . streets . setBrowserQueryString ( params ) ;
760724 this . roads . setBrowserQueryString ( params ) ;
@@ -793,9 +757,7 @@ class FilterStore implements IFilterStore {
793757 this . locationAccuracy . setValuesByQuery ( params ) ;
794758 this . roadTypes . setValuesByQuery ( params ) ;
795759 this . vehicleStore . injTypes . setValuesByQuery ( params ) ;
796- this . genderTypes . setValuesByQuery ( params ) ;
797- this . ageTypes . setValuesByQuery ( params ) ;
798- this . populationTypes . setValuesByQuery ( params ) ;
760+ this . whoStore . setValuesByQuery ( params ) ;
799761 this . accidentType . setValuesByQuery ( params ) ;
800762 this . vehicleStore . vehicleType . setValuesByQuery ( params ) ;
801763 this . vehicleStore . involvedVehicle . setValuesByQuery ( params ) ;
@@ -853,9 +815,6 @@ class FilterStore implements IFilterStore {
853815 @observable
854816 chartHideOutOfRange : Map < string , boolean > = new Map ( ) ;
855817
856- @observable
857- chartOutOfRangeCounts : Map < string , number > = new Map ( ) ;
858-
859818 @action
860819 setChartDataRange = ( id : string , start : number , end : number ) => {
861820 this . chartDataRanges . set ( id , { start, end } ) ;
@@ -874,7 +833,41 @@ class FilterStore implements IFilterStore {
874833 resetChartRanges = ( ) => {
875834 this . chartDataRanges . clear ( ) ;
876835 this . chartHideOutOfRange . clear ( ) ;
877- this . chartOutOfRangeCounts . clear ( ) ;
836+ }
837+
838+ getChartOutOfRangeCount = ( id : EchartId ) => {
839+ let data : any [ ] = [ ] ;
840+ let metaData : any [ ] | undefined ;
841+
842+ switch ( id ) {
843+ case EchartId . Group_1 :
844+ data = this . dataFilterd ;
845+ break ;
846+ case EchartId . Group_2 :
847+ data = this . dataGroupby2 ;
848+ metaData = ( this . group2Dict . groupBy as GroupBy2 ) . getBars ( ) ;
849+ break ;
850+ case EchartId . Years :
851+ data = this . dataFilterdByYears ;
852+ break ;
853+ default :
854+ return 0 ;
855+ }
856+
857+ const getItemValue = ( item : any ) => {
858+ if ( item . count !== undefined ) return Number ( item . count ) ;
859+ if ( metaData ) return Math . max ( ...metaData . map ( m => Number ( item [ m . key ] ) || 0 ) ) ;
860+ return 0 ;
861+ } ;
862+ const maxVal = data . reduce ( ( max , item ) => Math . max ( max , getItemValue ( item ) ) , 0 ) ;
863+ const range = this . chartDataRanges . get ( id ) || { start : 0 , end : maxVal } ;
864+ const outsideItem = sliceDataWithAggregation ( data , range , metaData )
865+ . find ( ( item : any ) => item . _id === 'outside_range' ) ;
866+
867+ if ( ! outsideItem ) return 0 ;
868+ return metaData
869+ ? metaData . reduce ( ( sum , m ) => sum + ( Number ( outsideItem [ m . key ] ) || 0 ) , 0 )
870+ : Number ( outsideItem . count ) || 0 ;
878871 }
879872
880873 getChartData = ( id : EchartId ) => {
@@ -909,15 +902,6 @@ class FilterStore implements IFilterStore {
909902 const maxVal = data . reduce ( ( max , item ) => Math . max ( max , getItemValue ( item ) ) , 0 ) ;
910903 const range = this . chartDataRanges . get ( id ) || { start : 0 , end : maxVal } ;
911904 let sliced = sliceDataWithAggregation ( data , range , metaData ) ;
912- const outsideItem = sliced . find ( ( item : any ) => item . _id === 'outside_range' ) ;
913- const outOfRangeCount = outsideItem
914- ? ( metaData
915- ? metaData . reduce ( ( sum , m ) => sum + ( Number ( outsideItem [ m . key ] ) || 0 ) , 0 )
916- : Number ( outsideItem . count ) || 0 )
917- : 0 ;
918- runInAction ( ( ) => {
919- this . chartOutOfRangeCounts . set ( id , outOfRangeCount ) ;
920- } ) ;
921905 if ( this . chartHideOutOfRange . get ( id ) ) {
922906 sliced = sliced . filter ( ( item : any ) => item . _id !== 'outside_range' ) ;
923907 }
0 commit comments