line.js
1.84 KB
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
68
69
70
71
72
import VeLine from 'v-charts/lib/line.common'
import VePie from 'v-charts/lib/pie.common'
import VeHistogram from 'v-charts/lib/histogram.common'
import VeFunnel from 'v-charts/lib/funnel.common'
import PropTypes from '@luban-h5/plugin-common-props'
import 'echarts/lib/component/legend'
import 'echarts/lib/component/markLine'
import 'echarts/lib/component/markPoint'
import 'echarts/lib/component/markArea'
import Parser from '../../../utils/excel-parser'
export default {
extra: {
defaultStyle: {
width: 320,
height: 400
}
},
name: 'lbp-line-chart',
// mixins: [ChartMixin],
props: {
dataset: PropTypes.excel({
defaultValue: () => [
['日期', '销售量'],
['1月1日', 123],
['1月2日', 1223],
['1月3日', 2123],
['1月4日', 4123],
['1月5日', 3123],
['1月6日', 7123]
]
}),
type: PropTypes.string({
label: '类型',
defaultValue: 'line',
visible: false
}),
colors: PropTypes.colors({
label: '颜色面板',
defaultValue: () => [
// https://github.com/ElemeFE/v-charts/blob/01ebb541a5d905047dd52957ae0898d529342235/src/constants.js#L20
'#19d4ae', '#5ab1ef', '#fa6e86',
'#ffb980', '#0067a6', '#c4b4e4',
'#d87a80', '#9cbbff', '#d9d0c7',
'#87a997', '#d49ea2', '#5b4947',
'#7ba3a8'
]
})
},
data () {
return {
option: {}
}
},
render () {
const chartData = Parser.csv2VChartJson(this.dataset)
switch (this.type) {
case 'line':
case 'histogram':
return <VeHistogram data={chartData} colors={this.colors} />
case 'pie':
return <VePie data={chartData} />
case 'funnel':
return <VeFunnel data={chartData} />
default:
return null
}
},
mounted () {
// this.renderChart()
}
}