zoukankan      html  css  js  c++  java
  • 遍历生成多个echarts(遍历echarts)

    <template>
        <!-- //地区分布 -->
        <div>
            <ul style=" 100%">
                <template v-for="(item, index) in chartList_values">
                    <li :id="forId(index)" style="height: 225px" :key="index"></li>
                </template>
            </ul>
        </div>
    </template>

    <script>
    //引入基本模板
    import echarts from 'echarts';
    function compare(property) {
        return function (a, b) {
            var value1 = a[property];
            var value2 = b[property];
            return value1 - value2;
        };
    }
    export default {
        data() {
            return {
                chartList: [], //
                getId: [], //用来生成echarts
                chartList_values: [], //取其值
                chartList_Key: [] //没用到
            };
        },
        mounted() {},
        methods: {
            forId(index) {
                return 'geo_' + index;
            },
            show(option) {
                console.log(option.level_incite_user_list, '每个等级的占比情况11');
                this.chartList = option.level_incite_user_list;
                this.mapTree();
            },
            mapTree() {
                this.getId = [];
                this.chartList_values = Object.values(this.chartList);
                this.chartList_Key = Object.keys(this.chartList);
                console.log(this.chartList_values, 'this.chartList_values');
                console.log(this.chartList_Key, 'this.chartList_Key');
                this.$nextTick(function () {
                    for (var i = 0; i < this.chartList_values.length; i++) {
                        let arr = [];
                        this.chartList_values[i].datum.forEach((item) => {
                            arr.push({
                                value: item.user_coun,
                                name: item.score_level
                            });
                        });
                        console.log(arr, 'arr========');
                        //拿到channel_grade_name作为变量key
                        this.getId.push(echarts.init(document.getElementById('geo_' + i)));
                        console.log(this.getId, 'this.getId');
                        console.log(this.chartList_values[i], ' this.chartList[i]');
                        this.getId[i].setOption({
                            title: {
                                text: this.chartList_values[i].channel_name,
                                left: 'center'
                            },
                            tooltip: {
                                trigger: 'item',
                                formatter: '{a} <br/>{b} : {c} ({d}%)'
                            },
                            legend: {
                                orient: 'vertical',
                                left: 'left',
                                data: this.temp
                            },
                            series: [
                                {
                                    name: '访问来源',
                                    type: 'pie',
                                    radius: '55%',
                                    center: ['50%', '60%'],
                                    // {value: this.dataVal[i].normalSum, name: ''}
                                    data: arr,
                                    emphasis: {
                                        itemStyle: {
                                            shadowBlur: 10,
                                            shadowOffsetX: 0,
                                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                                        }
                                    }
                                }
                            ]
                        });
                    }
                });
            }
        }
    };
    </script>

    <style scoped>
    ul {
        display: flex;
        flex-wrap: wrap;
    }
    li {
        list-style-type: none;
         33%;
    }
    </style>
  • 相关阅读:
    pongo英雄会-幸运数题解
    求最大公约数的算法
    第二课、GUI程序实例分析------------------狄泰软件学院
    第一课、GUI程序原理分析------------------狄泰软件学院
    第六十八课、拾遗:令人迷惑的写法
    第六十七课、经典问题解析五
    第六十六课、c++中的类型识别
    第六十五课、c++中的异常处理(下)
    第六十四课、c++中的异常处理(上)
    第六十三课、C语言的异常处理
  • 原文地址:https://www.cnblogs.com/xiaoxiaoxun/p/13953036.html
Copyright © 2011-2022 走看看