sankey.vue 1.86 KB
<!-- 性别统计 -->
<template>
    <div>
        <!-- 顶部区域 S-->
        <div class="ipage_top">
            <div class="tit"><img :src="bindIcon('ziyuan')"/>{{title||chartData.title}}</div>
        </div>
        <div class="ichart">
            <sankey-chart :cdata="chartData" tval="sankey"></sankey-chart>
        </div>
    </div>
</template>

<script>
import mixin from './mixin';
import mallData from '@/components/Echarts/data';
/**********************************************************/
const chartsConfig = {
    default:{ //默认
        otherConf:{
            //_color:['#f00','#000','#fff']
        }
    }
};
/*******************************************************/
export default {
    mixins: [mixin],
    data() {
        return {
            configObj:{}
        }
    },
    created() {
        
    },
    methods: {
        getChartsConfig(){
            return chartsConfig;
        },
        loadChartData(params){
            this.chartId = this.getChartId(this.ckey);
            if(this.chartId){
               this.ajaxModuleData().then(data=>{
                  this.setChartData(data);
               });
            }
        },
        setChartData(data){
            data.series.forEach(item=>{
                item.type = 'sankey';
                let [data,links] = [[],[]];
                data.push({
                    name:item.name
                });
                item.data.forEach(it=>{
                    it.source = String(it.source);
                    links.push(JSON.parse(JSON.stringify(it)));
                    data.push({name:it.target})
                });
                item.data = data;
                item.links = links;
            })
            this.chartData = Object.assign({},data,{
                otherConf:this.configObj.otherConf||{}
            });
        }
    }
}
</script>

<style  lang="less">

</style>