You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
4.8 KiB

<!--
* @Author: your name
* @Date: 2021-10-16 11:36:20
* @LastEditTime: 2021-10-20 09:31:36
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /data-show/src/views/BrandComparison/weiboUserPortrait/index.vue
-->
<template>
<div class="wup-outter" v-loading="load">
<div class="wup-inner">
<div class="d1">
<v-label-div
title="微博用户画像"
:showLine="false"
:eStyle="{ 'border-style': 'none' }"
>
<span style="color: #3373cc">{{eventList[0]}}</span>
</v-label-div>
<div class="d1x">
<div class="dd1" style="width:53%">
<v-echarts :opt="opt1"></v-echarts>
</div>
<div class="dd2" style="width:47%">
<v-label-ctx
v-for="(item, index) in showData1"
:key="index"
:label="item.name"
:cont="item.value"
:percentage="((item.value / totalData1) * 100).toFixed(2) + '%'"
:color="colors[index]"
:eStyle="{ height: '96px' }"
></v-label-ctx>
</div>
</div>
</div>
<div class="d1">
<v-label-div
title=""
:showLine="false"
:eStyle="{ 'border-style': 'none' }"
>
<span style="color: #54bf93">{{eventList[1]}}</span>
</v-label-div>
<div class="d1x">
<div class="dd1" style="width:53%">
<v-echarts :opt="opt2"> </v-echarts>
</div>
<div class="dd2" style="width:47%;margin-right: 16px">
<v-label-ctx
v-for="(item, index) in showData2"
:key="index"
:label="item.name"
:cont="item.value"
:percentage="((item.value / totalData2) * 100).toFixed(2) + '%'"
:color="colors[index]"
:eStyle="{ height: '96px' }"
></v-label-ctx>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import { getSexMergeWeiBoC } from "@/api/EventComparison/index.js";
import createOpt1 from "./opt1";
import createOpt2 from "./opt2";
export default {
name: "wupEc",
data() {
return {
opt1: {},
opt2: {},
form: {
token: "",
sRele: "",
load: false,
},
colors: [
"#54BF93",
"#3373CC",
"#CC9D12",
"#f15c80",
"#e4d354",
"#8085e8",
"#8d4653",
"#91e8e1",
"#f7a35c",
"#90ed7d",
"#54BF93",
"#3373CC",
"#CC9D12",
"#f15c80",
"#e4d354",
"#8085e8",
"#8d4653",
"#91e8e1",
"#f7a35c",
"#90ed7d",
],
showData1: [],
showData2: [],
totalData1: 0,
totalData2: 0,
eventList: []
};
},
created() {
this.initData();
},
methods: {
initData() {
this.form.token = this.getToken;
let arr = [];
this.getEComparison.forEach((ele) => {
arr.push(ele.events_id);
});
this.form.sRele = arr.toString();
this.getData();
},
getData() {
let obj = Object.assign({}, this.getCtime2, this.form);
this.load = true;
getSexMergeWeiBoC(obj).then((res) => {
let data = res.data || [];
let eList = [];
data.forEach(e=> {
let subStr = e.Name.substr(0,7) + "...";
eList.push(subStr);
})
this.eventList = eList;
this.showData1 = this.toArr(data[0].Data.sex);
this.showData2 = this.toArr(data[1].Data.sex);
this.totalData1 =
this.showData1[0].value * 1 +
this.showData1[1].value * 1 +
this.showData1[2].value * 1;
this.totalData2 =
this.showData2[0].value * 1 +
this.showData2[1].value * 1 +
this.showData2[2].value * 1;
this.opt1 = createOpt1(this.showData1, this.colors);
this.opt2 = createOpt2(this.showData2, this.colors);
this.load = false;
});
},
//将对象变成数组
toArr(obj) {
let arr = [];
for (let key in obj) {
let o = {
name: key,
value: obj[key] * 1,
};
arr.push(o);
}
return arr;
},
},
};
</script>
<style lang="less" scoped>
.wup-outter {
width: 944px;
height: 412px;
.wup-inner {
width: 100%;
display: flex;
justify-content: flex-start;
.d1 {
width: 50%;
height: 100%;
overflow: hidden;
.d1x {
width: 100%;
height: calc(100% - 48px);
display: flex;
justify-content: flex-start;
align-items: center;
}
.dd1 {
width: 280px;
height: 280px;
}
.dd2 {
width: 160px;
height: 100%;
}
}
}
}
</style>