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
56
57
58
59
60
61
62
63
64
65
66
67
| <template>
| <div class="mini-chart">
| <div class="chart-content" :style="{height: 46}">
| <v-chart :force-fit="true" :height="height" :data="data" :padding="[36, 5, 18, 5]">
| <v-tooltip />
| <v-smooth-area position="x*y" />
| </v-chart>
| </div>
| </div>
| </template>
|
| <script>
| import moment from 'moment'
|
| const data = []
| const beginDay = new Date().getTime()
|
| const fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5]
| for (let i = 0; i < fakeY.length; i += 1) {
| data.push({
| x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'),
| y: fakeY[i]
| })
| }
|
| const tooltip = [
| 'x*y',
| (x, y) => ({
| name: x,
| value: y
| })
| ]
|
| const scale = [{
| dataKey: 'x',
| min: 2
| }, {
| dataKey: 'y',
| title: '时间',
| min: 1,
| max: 22
| }]
|
| export default {
| name: 'MiniArea',
| data () {
| return {
| data,
| scale,
| tooltip,
| height: 100
| }
| }
| }
| </script>
|
| <style scoped>
| .mini-chart {
| position: relative;
| width: 100%
| }
| .mini-chart .chart-content{
| position: absolute;
| bottom: -28px;
| width: 100%;
| }
| </style>
|
|