fsex.vue
4.68 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!-- 业态客群洞察 -->
<template>
<div>
<!-- 顶部区域 S-->
<div class="ipage_top">
<div class="tit">
<img :src="bindIcon('ziyuan')" />{{title||chartData.title}}
</div>
<div class="acts"></div>
</div>
<div class="ichart">
<bars-chart ref="chart" :cdata="chartData"></bars-chart>
</div>
</div>
</template>
<script>
import mixin from "./mixin";
import mallData from "@/components/Echarts/data";
/**********************************************************/
const chartsConfig = {
default: {
//默认
otherConf: {
_color: ["#3e8dfd", "#ffd48b"],
labelShow: true,
isSex: true,
},
},
};
/*******************************************************/
export default {
mixins: [mixin],
data() {
return {
configObj: {},
};
},
created() {},
methods: {
getChartsConfig() {
return chartsConfig;
},
loadChartData(params) {
// this.setChartData();
this.chartId = this.getChartId(this.ckey);
if (this.chartId) {
this.ajaxModuleData().then((data) => {
this.setChartData(data);
});
} else {
this.setChartData();
}
},
setChartData(data) {
let sdata1, sdata2;
let total = data.series.map((item) =>item.data);
let ydata = {
data: data.series.map((item) => item.name)
};
// 男性占比
sdata1 = {
type: "bar",
data: data.series.map((item) =>
((item.data[0] / item.data[2]) * 100).toFixed(2)
),
};
// 女性占比
sdata2 = {
type: "bar",
data: data.series.map((item) =>
((item.data[1] / item.data[2]) * 100).toFixed(2)
),
};
let grids = [
{
left: "5%",
width: "30%",
top: 10,
bottom: 20,
},
{
left: "65%",
width: "30%",
top: 10,
bottom: 20,
},
];
let series = [
{
...JSON.parse(JSON.stringify(sdata1)),
// data: [1, 2, 3, 4],
// type: "bar",
xAxisIndex: 0,
yAxisIndex: 0,
barWidth: 25,
label: { show: false },
},
{
// data: [5, 6, 7, 8],
// type: "bar",
...JSON.parse(JSON.stringify(sdata2)),
xAxisIndex: 1,
yAxisIndex: 1,
barWidth: 25,
},
];
let xAxis = [
{
gridIndex: 0,
name:this.$t('format.perNum'),
nameLocation:'start',
nameTextStyle:{
verticalAlign:'top',
lineHeight:28
},
inverse: true,
type: "value",
position: "bottom",
splitNumber: 3,
splitLine: { show: true, lineStyle: { color: "#f7f4f8" } },
axisTick: { show: false },
axisLine: { show: false },
},
{
gridIndex: 1,
name:this.$t('format.perNum'),
nameLocation:'start',
nameTextStyle:{
verticalAlign:'top',
lineHeight:28
},
type: "value",
splitNumber: 3,
splitLine: { show: true, lineStyle: { color: "#f7f4f8" } },
axisTick: { show: false },
axisLine: { show: false },
},
];
let yAxis = [
{
...ydata,
// data: ["测试1", "测试1", "测试1", "测试1"],
type: "category",
gridIndex: 0,
position: "bottom",
axisLine: { show: true, lineStyle: { color: "#d9d9d9" } },
axisTick: { show: false },
position: "right",
type: "category",
},
{
...ydata,
// data: ["测试1", "测试1", "测试1", "测试1"],
type: "category",
gridIndex: 1,
axisLine: { show: true, lineStyle: { color: "#d9d9d9" } },
axisTick: { show: false },
type: "category",
},
];
let graphic = [
{
type: "text",
left: 0,
top: "45%",
style: {
font: "normal 15px sans-serif",
text: "男性",
},
},
{
type: "text",
right: 0,
top: "45%",
style: {
font: "normal 15px sans-serif",
text: "女性",
},
},
];
let chartData = {
xAxis,
yAxis,
series,
graphic,
noProcess: true,
};
this.chartData = Object.assign({}, chartData, {
otherConf: { ...(this.configObj.otherConf || {}), grid: grids,total},
});
},
},
};
</script>
<style scoped lang="less">
</style>