sankey2.vue 3.54 KB
<!-- 性别统计 -->
<template>
    <div>
        <!-- 顶部区域 S-->
        <div class="ipage_top">
            <div class="tit"><img :src="bindIcon('caigou1')"/>{{title||chartData.title}}</div>
        </div>
        <el-row class="ichart" v-loading="loading">
            <el-col :span="12" :style="{opacity:isEmpty?0:1}">
                <sankey-chart :cdata="chartData2" tval="sankey2"></sankey-chart>
                <p v-show="!isEmpty" class="ictit">客流流入</p>
            </el-col>
            <el-col :span="12" :style="{opacity:isEmpty?0:1}">
                <sankey-chart :cdata="chartData" tval="sankey3"></sankey-chart>
                <p v-show="!isEmpty" class="ictit">客流流出</p>
            </el-col>
            <div class="empty" v-show="isEmpty">
                <img src="@/assets/img/no_data.png">
                <p>{{$t('pholder.nodata')}}</p>
            </div>
        </el-row>
    </div>
</template>

<script>
import mixin from './mixin';
import mallData from '@/components/Echarts/data';
/**********************************************************/
const chartsConfig = {
    default:{ //默认
        otherConf:{
            orient:'horizontal'
        }
    }
};
/*******************************************************/
export default {
    mixins: [mixin],
    data() {
        return {
            isEmpty:false,
            loading:true,
            configObj:{},
            chartData2:{}
        }
    },
    created() {
        
    },
    methods: {
        getChartsConfig(){
            return chartsConfig;
        },
        loadChartData(params){
            this.loading = true;
            this.chartId = this.getChartId(this.ckey);
            if(this.chartId){
               this.ajaxModuleData().then(data=>{
                  this.setChartData(data);
               });
            }
        },
        setChartData(data){
            this.loading = false;
            if(!data||data.series.length==0){
                this.isEmpty = true;
                return;
            }
            this.isEmpty = false;
            data.series.forEach((item,idx)=>{
                item.type = 'sankey';
                let [idata,links] = [[],[]];
                item.data.forEach(it=>{
                    it.source = String(it.source);
                    links.push(JSON.parse(JSON.stringify(it)));
                    idata.push({name:item.name=='from'?it.source:it.target})
                });
                if(item.name=='from'){
                    idata.unshift({name:item.data[0].target});
                    item.data = idata;
                    item.links = links;
                    let chartData = {
                        series:[JSON.parse(JSON.stringify(item))]
                    }
                    this.chartData2 = Object.assign({},chartData,{
                        otherConf:this.configObj.otherConf||{}
                    });
                }else if(item.name=='to'){
                    idata.unshift({name:item.data[0].source});
                    item.data = idata;
                    item.links = links;
                    let chartData = {
                        series:[JSON.parse(JSON.stringify(item))]
                    }
                    this.chartData = Object.assign({},chartData,{
                        otherConf:this.configObj.otherConf||{}
                    }); 
                }

            })
        }
    }
}
</script>

<style  lang="less" scoped>
.ictit{
    position:absolute;
    left: 50%;
    transform: translateX(-50%);
    color: #000;
    font-size: 14px;
    bottom:0
}
</style>