diff --git a/src/components/Discover/Map/Filter/Attributes.vue b/src/components/Discover/Map/Filter/Attributes.vue index aa8802a..15e12b3 100644 --- a/src/components/Discover/Map/Filter/Attributes.vue +++ b/src/components/Discover/Map/Filter/Attributes.vue @@ -20,9 +20,25 @@
@@ -150,47 +165,24 @@ export default { attRangeData: function() { let data = []; const type = this.selectedAttName.type; - - switch (type) { - case 'boolean': - data = [ - { - id: 1, - key: this.selectedAttName.key, - type: type, - value: true, - label: 'Yes' - }, - { - id: 2, - key: this.selectedAttName.key, - type: type, - value: false, - label: 'No' - }, - ] - return data; - case 'string': - let sum = this.selectedAttName.options.map(item => item.freq).reduce((acc, cur) => acc + cur, 0); - data = this.selectedAttName.options.map((item, index) => { - let result; - let ratio = item.freq / sum; - result = { - id: index + 1, - key: this.selectedAttName.key, - type: type, - value: item.value, - occ_progress_bar: ratio * 100, - occ_value: item.freq.toLocaleString('en-US'), - occ_ratio: this.getPercentLabel(ratio), - freq: item.freq - }; - return result; - }) - return data.sort((x, y) => y.freq - x.freq); - default: - return null; - } + let sum = this.selectedAttName.options.map(item => item.freq).reduce((acc, cur) => acc + cur, 0); + data = this.selectedAttName.options.map((item, index) => { + let result; + let ratio = item.freq / sum; + result = { + id: index + 1, + key: this.selectedAttName.key, + type: type, + value: item.value, + occ_progress_bar: ratio * 100, + occ_value: item.freq.toLocaleString('en-US'), + occ_ratio: this.getPercentLabel(ratio), + freq: item.freq + }; + result.label = type !== 'boolean' ? null : item.value ? 'Yes' : 'No'; + return result; + }) + return data.sort((x, y) => y.freq - x.freq); }, // 取出選取的 Attribute radio 數值型的資料 valueData: function() {