1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  | <template> 
 |    <div :style="{ padding: '0 0 32px 32px' }"> 
 |      <h3 :style="{ marginBottom: '20px' }">{{ title }}</h3> 
 |      <v-chart :forceFit="true" :height="height" :data="dataSource" :scale="scale" :padding="padding"> 
 |        <v-tooltip/> 
 |        <v-axis/> 
 |        <v-bar position="x*y" :color="color"/> 
 |      </v-chart> 
 |    </div> 
 |  </template> 
 |    
 |  <script> 
 |    import { triggerWindowResizeEvent } from '@/utils/util' 
 |    import { DEFAULT_COLOR } from "@/store/mutation-types" 
 |    import Vue from 'vue' 
 |    
 |    export default { 
 |      name: 'Bar', 
 |      props: { 
 |        dataSource: { 
 |          type: Array, 
 |          required: true 
 |        }, 
 |        yaxisText: { 
 |          type: String, 
 |          default: 'y' 
 |        }, 
 |        title: { 
 |          type: String, 
 |          default: '' 
 |        }, 
 |        height: { 
 |          type: Number, 
 |          default: 254 
 |        } 
 |      }, 
 |      data() { 
 |        return { 
 |          padding: ['auto', 'auto', '40', '50'], 
 |          color: Vue.ls.get(DEFAULT_COLOR) 
 |        } 
 |      }, 
 |      computed: { 
 |        scale() { 
 |          return [{ 
 |            dataKey: 'y', 
 |            alias: this.yaxisText 
 |          }] 
 |        } 
 |      }, 
 |      mounted() { 
 |        triggerWindowResizeEvent() 
 |      } 
 |    } 
 |  </script> 
 |  
  |