Browse Source

PanThumb/index.vue

luyanan 6 years ago
parent
commit
7195414776

+ 152 - 0
src/components/Charts/keyboard.vue

@ -0,0 +1,152 @@
1
<template>
2
  <div :class="className" :id="id" :style="{height:height,width:width}"></div>
3
</template>
4
5
<script>
6
import echarts from 'echarts'
7
import resize from './mixins/resize'
8
9
export default {
10
  mixins: [resize],
11
  props: {
12
    className: {
13
      type: String,
14
      default: 'chart'
15
    },
16
    id: {
17
      type: String,
18
      default: 'chart'
19
    },
20
    width: {
21
      type: String,
22
      default: '200px'
23
    },
24
    height: {
25
      type: String,
26
      default: '200px'
27
    }
28
  },
29
  data() {
30
    return {
31
      chart: null
32
    }
33
  },
34
  mounted() {
35
    this.initChart()
36
  },
37
  beforeDestroy() {
38
    if (!this.chart) {
39
      return
40
    }
41
    this.chart.dispose()
42
    this.chart = null
43
  },
44
  methods: {
45
    initChart() {
46
      this.chart = echarts.init(document.getElementById(this.id))
47
48
      const xAxisData = []
49
      const data = []
50
      const data2 = []
51
      for (let i = 0; i < 50; i++) {
52
        xAxisData.push(i)
53
        data.push((Math.sin(i / 5) * (i / 5 - 10) + i / 6) * 5)
54
        data2.push((Math.sin(i / 5) * (i / 5 + 10) + i / 6) * 3)
55
      }
56
      this.chart.setOption(
57
        {
58
          backgroundColor: '#08263a',
59
          xAxis: [{
60
            show: false,
61
            data: xAxisData
62
          }, {
63
            show: false,
64
            data: xAxisData
65
          }],
66
          visualMap: {
67
            show: false,
68
            min: 0,
69
            max: 50,
70
            dimension: 0,
71
            inRange: {
72
              color: ['#4a657a', '#308e92', '#b1cfa5', '#f5d69f', '#f5898b', '#ef5055']
73
            }
74
          },
75
          yAxis: {
76
            axisLine: {
77
              show: false
78
            },
79
            axisLabel: {
80
              textStyle: {
81
                color: '#4a657a'
82
              }
83
            },
84
            splitLine: {
85
              show: true,
86
              lineStyle: {
87
                color: '#08263f'
88
              }
89
            },
90
            axisTick: {
91
              show: false
92
            }
93
          },
94
          series: [{
95
            name: 'back',
96
            type: 'bar',
97
            data: data2,
98
            z: 1,
99
            itemStyle: {
100
              normal: {
101
                opacity: 0.4,
102
                barBorderRadius: 5,
103
                shadowBlur: 3,
104
                shadowColor: '#111'
105
              }
106
            }
107
          }, {
108
            name: 'Simulate Shadow',
109
            type: 'line',
110
            data,
111
            z: 2,
112
            showSymbol: false,
113
            animationDelay: 0,
114
            animationEasing: 'linear',
115
            animationDuration: 1200,
116
            lineStyle: {
117
              normal: {
118
                color: 'transparent'
119
              }
120
            },
121
            areaStyle: {
122
              normal: {
123
                color: '#08263a',
124
                shadowBlur: 50,
125
                shadowColor: '#000'
126
              }
127
            }
128
          }, {
129
            name: 'front',
130
            type: 'bar',
131
            data,
132
            xAxisIndex: 1,
133
            z: 3,
134
            itemStyle: {
135
              normal: {
136
                barBorderRadius: 5
137
              }
138
            }
139
          }],
140
          animationEasing: 'elasticOut',
141
          animationEasingUpdate: 'elasticOut',
142
          animationDelay(idx) {
143
            return idx * 20
144
          },
145
          animationDelayUpdate(idx) {
146
            return idx * 20
147
          }
148
        })
149
    }
150
  }
151
}
152
</script>

+ 227 - 0
src/components/Charts/lineMarker.vue

@ -0,0 +1,227 @@
1
<template>
2
  <div :class="className" :id="id" :style="{height:height,width:width}"></div>
3
</template>
4
5
<script>
6
import echarts from 'echarts'
7
import resize from './mixins/resize'
8
9
export default {
10
  mixins: [resize],
11
  props: {
12
    className: {
13
      type: String,
14
      default: 'chart'
15
    },
16
    id: {
17
      type: String,
18
      default: 'chart'
19
    },
20
    width: {
21
      type: String,
22
      default: '200px'
23
    },
24
    height: {
25
      type: String,
26
      default: '200px'
27
    }
28
  },
29
  data() {
30
    return {
31
      chart: null
32
    }
33
  },
34
  mounted() {
35
    this.initChart()
36
  },
37
  beforeDestroy() {
38
    if (!this.chart) {
39
      return
40
    }
41
    this.chart.dispose()
42
    this.chart = null
43
  },
44
  methods: {
45
    initChart() {
46
      this.chart = echarts.init(document.getElementById(this.id))
47
48
      this.chart.setOption({
49
        backgroundColor: '#394056',
50
        title: {
51
          top: 20,
52
          text: 'Requests',
53
          textStyle: {
54
            fontWeight: 'normal',
55
            fontSize: 16,
56
            color: '#F1F1F3'
57
          },
58
          left: '1%'
59
        },
60
        tooltip: {
61
          trigger: 'axis',
62
          axisPointer: {
63
            lineStyle: {
64
              color: '#57617B'
65
            }
66
          }
67
        },
68
        legend: {
69
          top: 20,
70
          icon: 'rect',
71
          itemWidth: 14,
72
          itemHeight: 5,
73
          itemGap: 13,
74
          data: ['CMCC', 'CTCC', 'CUCC'],
75
          right: '4%',
76
          textStyle: {
77
            fontSize: 12,
78
            color: '#F1F1F3'
79
          }
80
        },
81
        grid: {
82
          top: 100,
83
          left: '3%',
84
          right: '4%',
85
          bottom: '2%',
86
          containLabel: true
87
        },
88
        xAxis: [{
89
          type: 'category',
90
          boundaryGap: false,
91
          axisLine: {
92
            lineStyle: {
93
              color: '#57617B'
94
            }
95
          },
96
          data: ['13:00', '13:05', '13:10', '13:15', '13:20', '13:25', '13:30', '13:35', '13:40', '13:45', '13:50', '13:55']
97
        }],
98
        yAxis: [{
99
          type: 'value',
100
          name: '(%)',
101
          axisTick: {
102
            show: false
103
          },
104
          axisLine: {
105
            lineStyle: {
106
              color: '#57617B'
107
            }
108
          },
109
          axisLabel: {
110
            margin: 10,
111
            textStyle: {
112
              fontSize: 14
113
            }
114
          },
115
          splitLine: {
116
            lineStyle: {
117
              color: '#57617B'
118
            }
119
          }
120
        }],
121
        series: [{
122
          name: 'CMCC',
123
          type: 'line',
124
          smooth: true,
125
          symbol: 'circle',
126
          symbolSize: 5,
127
          showSymbol: false,
128
          lineStyle: {
129
            normal: {
130
              width: 1
131
            }
132
          },
133
          areaStyle: {
134
            normal: {
135
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
136
                offset: 0,
137
                color: 'rgba(137, 189, 27, 0.3)'
138
              }, {
139
                offset: 0.8,
140
                color: 'rgba(137, 189, 27, 0)'
141
              }], false),
142
              shadowColor: 'rgba(0, 0, 0, 0.1)',
143
              shadowBlur: 10
144
            }
145
          },
146
          itemStyle: {
147
            normal: {
148
              color: 'rgb(137,189,27)',
149
              borderColor: 'rgba(137,189,2,0.27)',
150
              borderWidth: 12
151
152
            }
153
          },
154
          data: [220, 182, 191, 134, 150, 120, 110, 125, 145, 122, 165, 122]
155
        }, {
156
          name: 'CTCC',
157
          type: 'line',
158
          smooth: true,
159
          symbol: 'circle',
160
          symbolSize: 5,
161
          showSymbol: false,
162
          lineStyle: {
163
            normal: {
164
              width: 1
165
            }
166
          },
167
          areaStyle: {
168
            normal: {
169
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
170
                offset: 0,
171
                color: 'rgba(0, 136, 212, 0.3)'
172
              }, {
173
                offset: 0.8,
174
                color: 'rgba(0, 136, 212, 0)'
175
              }], false),
176
              shadowColor: 'rgba(0, 0, 0, 0.1)',
177
              shadowBlur: 10
178
            }
179
          },
180
          itemStyle: {
181
            normal: {
182
              color: 'rgb(0,136,212)',
183
              borderColor: 'rgba(0,136,212,0.2)',
184
              borderWidth: 12
185
186
            }
187
          },
188
          data: [120, 110, 125, 145, 122, 165, 122, 220, 182, 191, 134, 150]
189
        }, {
190
          name: 'CUCC',
191
          type: 'line',
192
          smooth: true,
193
          symbol: 'circle',
194
          symbolSize: 5,
195
          showSymbol: false,
196
          lineStyle: {
197
            normal: {
198
              width: 1
199
            }
200
          },
201
          areaStyle: {
202
            normal: {
203
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
204
                offset: 0,
205
                color: 'rgba(219, 50, 51, 0.3)'
206
              }, {
207
                offset: 0.8,
208
                color: 'rgba(219, 50, 51, 0)'
209
              }], false),
210
              shadowColor: 'rgba(0, 0, 0, 0.1)',
211
              shadowBlur: 10
212
            }
213
          },
214
          itemStyle: {
215
            normal: {
216
              color: 'rgb(219,50,51)',
217
              borderColor: 'rgba(219,50,51,0.2)',
218
              borderWidth: 12
219
            }
220
          },
221
          data: [220, 182, 125, 145, 122, 191, 134, 150, 120, 110, 165, 122]
222
        }]
223
      })
224
    }
225
  }
226
}
227
</script>

+ 269 - 0
src/components/Charts/mixChart.vue

@ -0,0 +1,269 @@
1
<template>
2
  <div :class="className" :id="id" :style="{height:height,width:width}"></div>
3
</template>
4
5
<script>
6
import echarts from 'echarts'
7
import resize from './mixins/resize'
8
9
export default {
10
  mixins: [resize],
11
  props: {
12
    className: {
13
      type: String,
14
      default: 'chart'
15
    },
16
    id: {
17
      type: String,
18
      default: 'chart'
19
    },
20
    width: {
21
      type: String,
22
      default: '200px'
23
    },
24
    height: {
25
      type: String,
26
      default: '200px'
27
    }
28
  },
29
  data() {
30
    return {
31
      chart: null
32
    }
33
  },
34
  mounted() {
35
    this.initChart()
36
  },
37
  beforeDestroy() {
38
    if (!this.chart) {
39
      return
40
    }
41
    this.chart.dispose()
42
    this.chart = null
43
  },
44
  methods: {
45
    initChart() {
46
      this.chart = echarts.init(document.getElementById(this.id))
47
      const xData = (function() {
48
        const data = []
49
        for (let i = 1; i < 13; i++) {
50
          data.push(i + 'month')
51
        }
52
        return data
53
      }())
54
      this.chart.setOption({
55
        backgroundColor: '#344b58',
56
        title: {
57
          text: 'statistics',
58
          x: '20',
59
          top: '20',
60
          textStyle: {
61
            color: '#fff',
62
            fontSize: '22'
63
          },
64
          subtextStyle: {
65
            color: '#90979c',
66
            fontSize: '16'
67
          }
68
        },
69
        tooltip: {
70
          trigger: 'axis',
71
          axisPointer: {
72
            textStyle: {
73
              color: '#fff'
74
            }
75
          }
76
        },
77
        grid: {
78
          borderWidth: 0,
79
          top: 110,
80
          bottom: 95,
81
          textStyle: {
82
            color: '#fff'
83
          }
84
        },
85
        legend: {
86
          x: '5%',
87
          top: '10%',
88
          textStyle: {
89
            color: '#90979c'
90
          },
91
          data: ['female', 'male', 'average']
92
        },
93
        calculable: true,
94
        xAxis: [{
95
          type: 'category',
96
          axisLine: {
97
            lineStyle: {
98
              color: '#90979c'
99
            }
100
          },
101
          splitLine: {
102
            show: false
103
          },
104
          axisTick: {
105
            show: false
106
          },
107
          splitArea: {
108
            show: false
109
          },
110
          axisLabel: {
111
            interval: 0
112
113
          },
114
          data: xData
115
        }],
116
        yAxis: [{
117
          type: 'value',
118
          splitLine: {
119
            show: false
120
          },
121
          axisLine: {
122
            lineStyle: {
123
              color: '#90979c'
124
            }
125
          },
126
          axisTick: {
127
            show: false
128
          },
129
          axisLabel: {
130
            interval: 0
131
          },
132
          splitArea: {
133
            show: false
134
          }
135
        }],
136
        dataZoom: [{
137
          show: true,
138
          height: 30,
139
          xAxisIndex: [
140
            0
141
          ],
142
          bottom: 30,
143
          start: 10,
144
          end: 80,
145
          handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
146
          handleSize: '110%',
147
          handleStyle: {
148
            color: '#d3dee5'
149
150
          },
151
          textStyle: {
152
            color: '#fff' },
153
          borderColor: '#90979c'
154
155
        }, {
156
          type: 'inside',
157
          show: true,
158
          height: 15,
159
          start: 1,
160
          end: 35
161
        }],
162
        series: [{
163
          name: 'female',
164
          type: 'bar',
165
          stack: 'total',
166
          barMaxWidth: 35,
167
          barGap: '10%',
168
          itemStyle: {
169
            normal: {
170
              color: 'rgba(255,144,128,1)',
171
              label: {
172
                show: true,
173
                textStyle: {
174
                  color: '#fff'
175
                },
176
                position: 'insideTop',
177
                formatter(p) {
178
                  return p.value > 0 ? p.value : ''
179
                }
180
              }
181
            }
182
          },
183
          data: [
184
            709,
185
            1917,
186
            2455,
187
            2610,
188
            1719,
189
            1433,
190
            1544,
191
            3285,
192
            5208,
193
            3372,
194
            2484,
195
            4078
196
          ]
197
        },
198
199
        {
200
          name: 'male',
201
          type: 'bar',
202
          stack: 'total',
203
          itemStyle: {
204
            normal: {
205
              color: 'rgba(0,191,183,1)',
206
              barBorderRadius: 0,
207
              label: {
208
                show: true,
209
                position: 'top',
210
                formatter(p) {
211
                  return p.value > 0 ? p.value : ''
212
                }
213
              }
214
            }
215
          },
216
          data: [
217
            327,
218
            1776,
219
            507,
220
            1200,
221
            800,
222
            482,
223
            204,
224
            1390,
225
            1001,
226
            951,
227
            381,
228
            220
229
          ]
230
        }, {
231
          name: 'average',
232
          type: 'line',
233
          stack: 'total',
234
          symbolSize: 10,
235
          symbol: 'circle',
236
          itemStyle: {
237
            normal: {
238
              color: 'rgba(252,230,48,1)',
239
              barBorderRadius: 0,
240
              label: {
241
                show: true,
242
                position: 'top',
243
                formatter(p) {
244
                  return p.value > 0 ? p.value : ''
245
                }
246
              }
247
            }
248
          },
249
          data: [
250
            1036,
251
            3693,
252
            2962,
253
            3810,
254
            2519,
255
            1915,
256
            1748,
257
            4675,
258
            6209,
259
            4323,
260
            2865,
261
            4298
262
          ]
263
        }
264
        ]
265
      })
266
    }
267
  }
268
}
269
</script>

+ 15 - 0
src/components/Charts/mixins/resize.js

@ -0,0 +1,15 @@
1
import { debounce } from '@/utils'
2
3
export default {
4
  mounted() {
5
    this.__resizeHanlder = debounce(() => {
6
      if (this.chart) {
7
        this.chart.resize()
8
      }
9
    }, 100)
10
    window.addEventListener('resize', this.__resizeHanlder)
11
  },
12
  beforeDestroy() {
13
    window.removeEventListener('resize', this.__resizeHanlder)
14
  }
15
}

+ 140 - 0
src/components/PanThumb/index.vue

@ -0,0 +1,140 @@
1
<template>
2
  <div class="pan-item" :style="{zIndex:zIndex,height:height,width:width}">
3
    <div class="pan-info">
4
      <div class="pan-info-roles-container">
5
        <slot></slot>
6
      </div>
7
    </div>
8
    <img class="pan-thumb" :src="image">
9
  </div>
10
</template>
11
12
<script>
13
export default {
14
  name: 'PanThumb',
15
  props: {
16
    image: {
17
      type: String,
18
      required: true
19
    },
20
    zIndex: {
21
      type: Number,
22
      default: 1
23
    },
24
    width: {
25
      type: String,
26
      default: '150px'
27
    },
28
    height: {
29
      type: String,
30
      default: '150px'
31
    }
32
  }
33
}
34
</script>
35
36
<style scoped>
37
.pan-item {
38
  width: 200px;
39
  height: 200px;
40
  border-radius: 50%;
41
  display: inline-block;
42
  position: relative;
43
  cursor: default;
44
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
45
}
46
47
.pan-info-roles-container {
48
  padding: 20px;
49
  text-align: center;
50
}
51
52
.pan-thumb {
53
  width: 100%;
54
  height: 100%;
55
  background-size: 100%;
56
  border-radius: 50%;
57
  overflow: hidden;
58
  position: absolute;
59
  transform-origin: 95% 40%;
60
  transition: all 0.3s ease-in-out;
61
}
62
63
.pan-thumb:after {
64
  content: '';
65
  width: 8px;
66
  height: 8px;
67
  position: absolute;
68
  border-radius: 50%;
69
  top: 40%;
70
  left: 95%;
71
  margin: -4px 0 0 -4px;
72
  background: radial-gradient(ellipse at center, rgba(14, 14, 14, 1) 0%, rgba(125, 126, 125, 1) 100%);
73
  box-shadow: 0 0 1px rgba(255, 255, 255, 0.9);
74
}
75
76
.pan-info {
77
  position: absolute;
78
  width: inherit;
79
  height: inherit;
80
  border-radius: 50%;
81
  overflow: hidden;
82
  box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0.05);
83
}
84
85
.pan-info h3 {
86
  color: #fff;
87
  text-transform: uppercase;
88
  position: relative;
89
  letter-spacing: 2px;
90
  font-size: 18px;
91
  margin: 0 60px;
92
  padding: 22px 0 0 0;
93
  height: 85px;
94
  font-family: 'Open Sans', Arial, sans-serif;
95
  text-shadow: 0 0 1px #fff, 0 1px 2px rgba(0, 0, 0, 0.3);
96
}
97
98
.pan-info p {
99
  color: #fff;
100
  padding: 10px 5px;
101
  font-style: italic;
102
  margin: 0 30px;
103
  font-size: 12px;
104
  border-top: 1px solid rgba(255, 255, 255, 0.5);
105
}
106
107
.pan-info p a {
108
  display: block;
109
  color: #333;
110
  width: 80px;
111
  height: 80px;
112
  background: rgba(255, 255, 255, 0.3);
113
  border-radius: 50%;
114
  color: #fff;
115
  font-style: normal;
116
  font-weight: 700;
117
  text-transform: uppercase;
118
  font-size: 9px;
119
  letter-spacing: 1px;
120
  padding-top: 24px;
121
  margin: 7px auto 0;
122
  font-family: 'Open Sans', Arial, sans-serif;
123
  opacity: 0;
124
  transition: transform 0.3s ease-in-out 0.2s, opacity 0.3s ease-in-out 0.2s, background 0.2s linear 0s;
125
  transform: translateX(60px) rotate(90deg);
126
}
127
128
.pan-info p a:hover {
129
  background: rgba(255, 255, 255, 0.5);
130
}
131
132
.pan-item:hover .pan-thumb {
133
  transform: rotate(-110deg);
134
}
135
136
.pan-item:hover .pan-info p a {
137
  opacity: 1;
138
  transform: translateX(0px) rotate(0deg);
139
}
140
</style>