<!--
 * @Author: your name
 * @Date: 2021-10-14 19:15:58
 * @LastEditTime: 2021-11-11 09:45:04
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /data-show/src/views/WeiboDetails/weiboSpreadFission/index.vue
-->
<template>
    <div class="wsf-outter" v-loading="load">
        <v-label-div title="微博传播裂变">
        </v-label-div>
        <div class="wsf-inner">
            <v-echarts :opt="opt"></v-echarts>
        </div>
    </div>
</template>

<script>
import {getDiffuseZhuTi} from "@/api/WeiboDetails";
import createOpt from "./opt"
export default {
    name: "weiboSpreadFission",
    data() {
        return {
            opt: {},
            load: false,
            form: {
                token:"",
                sBrand:""
            },
            colors: [
                "#FFB600",
                "#886CFF",
                "#0084FF",
                "#4CB690",
                "#58B458",
                "#6C6C6C",
                "#F56161",
                "#FC754C",
                "#5F5EEC",
            ],
        }
    },
    created() {
        this.form.token = this.getToken;
        this.form.sBrand = this.getBrand.brandname || '奥迪';
        this.getData();
    },
    methods: {
        getData() {
            let obj = Object.assign({}, this.getCtime2, this.form);
            this.load = true;
            getDiffuseZhuTi(obj).then((res) => {
                let data = res.data;
                let getCoreDiffuseWeiBo = data.getCoreDiffuseWeiBo || [];
                let listIdName = data.listIdName || [];
                let listPid = data.listPid || [];
                let nodes = listIdName;
                let edges = listPid;
                getCoreDiffuseWeiBo.forEach((ele) => {
                    let _source = ele._source;
                    let xgmid = _source.xgmid;
                    let row = nodes.find((e) => e.id === xgmid);
                    if (row) {
                        row.value = _source.volume;
                    } else {
                        row.value = 0;
                    }
                });
                nodes.forEach((ele) => {
                    let colorSet = new Set(this.colors);
                    let curIndex = Math.round(
                        Math.random() * (colorSet.size - 1)
                    );
                    ele.color = this.colors[curIndex];
                });
                let o = { nodes, edges };
                this.opt = createOpt(o);
                this.load = false;
            });
        },
    }
    
}
</script>

<style lang="less" scoped>
.wsf-outter {
    width: 460px;
    height: 460px;
    border: 2px solid #0f2a4d;
    margin-left: 16px;
    .wsf-inner {
        width: 100%;
        height: calc(100% - 48px);
    }
}
</style>
