commit | author | age
|
9bcb19
|
1 |
<template> |
I |
2 |
<div class="antv-chart-mini"> |
|
3 |
<div class="chart-wrapper" :style="{ height: 46 }"> |
|
4 |
<v-chart :force-fit="true" :height="height" :data="data" :padding="[36, 5, 18, 5]"> |
|
5 |
<v-tooltip /> |
|
6 |
<v-bar position="x*y" /> |
|
7 |
</v-chart> |
|
8 |
</div> |
|
9 |
</div> |
|
10 |
</template> |
|
11 |
|
|
12 |
<script> |
|
13 |
import moment from 'moment' |
|
14 |
const data = [] |
|
15 |
const beginDay = new Date().getTime() |
|
16 |
|
|
17 |
for (let i = 0; i < 10; i++) { |
|
18 |
data.push({ |
|
19 |
x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'), |
|
20 |
y: Math.round(Math.random() * 10) |
|
21 |
}) |
|
22 |
} |
|
23 |
|
|
24 |
const tooltip = [ |
|
25 |
'x*y', |
|
26 |
(x, y) => ({ |
|
27 |
name: x, |
|
28 |
value: y |
|
29 |
}) |
|
30 |
] |
|
31 |
|
|
32 |
const scale = [{ |
|
33 |
dataKey: 'x', |
|
34 |
min: 2 |
|
35 |
}, { |
|
36 |
dataKey: 'y', |
|
37 |
title: '时间', |
|
38 |
min: 1, |
|
39 |
max: 30 |
|
40 |
}] |
|
41 |
|
|
42 |
export default { |
|
43 |
name: 'MiniBar', |
|
44 |
data () { |
|
45 |
return { |
|
46 |
data, |
|
47 |
tooltip, |
|
48 |
scale, |
|
49 |
height: 100 |
|
50 |
} |
|
51 |
} |
|
52 |
} |
|
53 |
</script> |
|
54 |
|
|
55 |
<style lang="less" scoped> |
|
56 |
@import "chart"; |
|
57 |
</style> |