worth-grossprofit.vue
2.62 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<template>
<Card class="worth-grossprofit">
<p slot="title">毛利额区间分布图</p>
<div class="grossprofit-chart" style="width:100%;height:400px;"></div>
</Card>
</template>
<script>
import echart from 'common/echart';
import * as service from 'service.pc';
let myChart;
export default {
name: 'worth-grossprofit',
props: ['config', 'searchFlag'],
data() {
return {
}
},
mounted() {
echart.then(chart => {
this.ECharts = chart;
myChart = this.ECharts.init(document.querySelector('.grossprofit-chart'), 'macarons');
this.initChart();
this.loadData();
});
},
watch: {
searchFlag() {
this.loadData();
}
},
methods: {
initChart() {
myChart.setOption({
tooltip : {
trigger: 'axis',
showDelay : 0,
axisPointer:{
show: true,
type : 'cross',
lineStyle: {
type : 'dashed',
width : 1
}
},
zlevel: 1
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataZoom : {show: true},
saveAsImage : {show: true}
}
},
xAxis: {
name: '毛利额',
type: 'value',
splitLine: {
show: true
}
},
yAxis: {
name: 'SKN数',
type: 'value',
splitLine: {
show: true
}
}
});
},
convert() {
return [];
},
loadData() {
service.get('worth/vp_distribution', this.config).then(ret => {
let data = ret.data || [];
let convert = this.convert();
_.forEach(data, d => {
convert.push([d.vp, d.count]);
});
// 绘制图表
myChart.setOption({
series: [{
type: 'scatter',
data: convert
}]
});
});
}
}
}
</script>
<style lang="scss">
.worth-grossprofit {
}
</style>