11<script >
22import _ from " lodash" ;
33import d3 from " d3" ;
4- import { mapState , mapActions } from " vuex" ;
4+ import { mapState , mapMutations , mapActions } from " vuex" ;
55
66import NavigationBar from " @/components/NavigationBar" ;
77import SampleList from " @/components/SampleList" ;
@@ -29,20 +29,35 @@ export default {
2929 };
3030 },
3131 computed: {
32- ... mapState ([" meta" , " summary" , " table7" , " table8" , " table9" ]),
32+ ... mapState ([
33+ " meta" ,
34+ " summary" ,
35+ " table7" ,
36+ " table8" ,
37+ " table9" ,
38+ " selectedSampleType"
39+ ]),
3340 metaNames () {
3441 return this .meta .map (meta => meta .name );
3542 },
3643 sampleTypes () {
3744 var types = this .meta .map (meta => meta .material ).filter (value => value);
38- return _ .uniq (types);
45+ return Object .entries (_ .mapValues (_ .groupBy (types), " length" ));
46+ },
47+ featureTypes () {
48+ var types = this .meta .map (meta => meta .feature ).filter (value => value);
49+ return Object .entries (
50+ _ .mapValues (_ .groupBy (types, type => type), " length" )
51+ );
3952 },
4053 ecosystems () {
41- var ecosystems = this .meta .map (meta => meta .ecosystem ).filter (value => value);
42- return _ .uniq (ecosystems);
54+ var ecosystems = this .meta
55+ .map (meta => meta .ecosystem || meta .biome )
56+ .filter (value => value);
57+ return Object .entries (_ .mapValues (_ .groupBy (ecosystems), " length" ));
4358 },
4459 numberOfMetagenomes () {
45- return this .meta .filter ( meta => meta . Sequencing === " Metagenome " ). length ;
60+ return this .meta .length ;
4661 },
4762 numberOfMetatranscriptomes () {
4863 return this .meta .filter (meta => meta .Sequencing === " Metatranscriptomes" )
@@ -92,6 +107,7 @@ export default {
92107 }
93108 },
94109 methods: {
110+ ... mapMutations ([" setSelectedSampleType" ]),
95111 ... mapActions ([" load" ])
96112 }
97113};
@@ -112,41 +128,79 @@ export default {
112128 <SamplesLocation />
113129 </v-flex >
114130 <v-flex >
115- <v-card class =" fill-height" color =" teal darken-1" dark >
131+ <v-card class =" fill-height" color =" blue-grey darken-1" dark >
132+ <v-card-title >
133+ <h3 >Ecosystems</h3 >
134+ </v-card-title >
135+ <v-card-text >
136+ <h4 >
137+ <template v-for =" ([type , count ], i ) of ecosystems " >
138+ <span :key =" type" >{{ type }} ({{ count }})</span >
139+ <template v-if =" i !== ecosystems .length - 1 "
140+ >,
141+ </template >
142+ </template >
143+ </h4 >
144+ </v-card-text >
145+ </v-card >
146+ </v-flex >
147+ <v-flex >
148+ <v-card class =" fill-height" color =" indigo darken-1" dark >
116149 <v-responsive :aspect-ratio =" 16 / 10" >
117150 <v-card-title >
118- <h3 >Sample types </h3 >
151+ <h3 >Feature </h3 >
119152 </v-card-title >
120153 <v-card-text >
121- <h4 >{{ sampleTypes.join(",") }}</h4 >
154+ <h4 >
155+ <template v-for =" ([type , count ], i ) of featureTypes " >
156+ <span :key =" type" >{{ type }} ({{ count }})</span >
157+ <template v-if =" i !== featureTypes .length - 1 "
158+ >,
159+ </template >
160+ </template >
161+ </h4 >
122162 </v-card-text >
123163 </v-responsive >
124164 </v-card >
125165 </v-flex >
126166 <v-flex >
127- <v-card class =" fill-height" color =" blue-grey darken-1" dark >
128- <v-card-title >
129- <h3 >Ecosystems</h3 >
130- </v-card-title >
131- <v-card-text >
132- <h4 >{{ ecosystems.join(",") }}</h4 >
133- </v-card-text >
167+ <v-card class =" fill-height" color =" teal darken-1" dark >
168+ <v-responsive :aspect-ratio =" 16 / 10" >
169+ <v-card-title >
170+ <h3 >Sample types</h3 >
171+ </v-card-title >
172+ <v-card-text >
173+ <h4 >
174+ <template v-for =" ([type , count ], i ) of sampleTypes " >
175+ <span
176+ :key =" type"
177+ class =" sample-type"
178+ :class =" { selected: type === selectedSampleType }"
179+ @click ="
180+ selectedSampleType === type
181+ ? setSelectedSampleType(null)
182+ : setSelectedSampleType(type)
183+ "
184+ >{{ type }} ({{ count }})</span
185+ >
186+ <template v-if =" i !== sampleTypes .length - 1 "
187+ >,
188+ </template >
189+ </template >
190+ </h4 >
191+ </v-card-text >
192+ </v-responsive >
134193 </v-card >
135194 </v-flex >
136195 <!-- 4 -->
137196 <v-flex >
138- <v-card class =" fill-height" color =" indigo darken-1 " dark >
197+ <v-card class =" fill-height" color =" orange darken-2 " dark >
139198 <v-card-title >
140199 <h3 ># metagenome</h3 >
141200 </v-card-title >
142201 <v-card-text
143202 ><h4 >{{ numberOfMetagenomes }}</h4 >
144203 </v-card-text >
145- </v-card >
146- </v-flex >
147- <!-- 5 -->
148- <v-flex >
149- <v-card class =" fill-height" color =" orange darken-2" dark >
150204 <v-card-title >
151205 <h3 ># Metatranscriptomes</h3 >
152206 </v-card-title >
@@ -292,4 +346,15 @@ export default {
292346 }
293347 }
294348}
349+
350+ .sample-type {
351+ & .selected {
352+ text-decoration : underline ;
353+ }
354+
355+ & :hover {
356+ cursor : pointer ;
357+ text-decoration : underline ;
358+ }
359+ }
295360 </style >
0 commit comments