swiper使用loop导致echarts图形出不来,因为slide被克隆?

使用swiper loop:true后,slide被克隆导致id不再是唯一,所以echarts的图形出不来;求大神指点迷津!!!万分感谢!!!

阅读 5.3k
2 个回答

你用class选择器不就行了吗

 var myaaa=document.getElementsByClassName('a'); 
 for(var i=0;i<myaaa.length;i++){
            var myChart = echarts.init(myaaa[i]);
            myChart.setOption(option);     
         }

var myChart2 = echarts.init(document.getElementsByClassName('main-echarts-line-appSysd'));

                    var option2 = {
                            //设置标题

// title:{
// text:'应用系统物理表数量',
// subtext:'',
// x:'center'
// },

                            //设置提示
                            tooltip: {
                                show: true
                            },
                            grid: {x: '5%', y: '15%'},

                            //设置坐标轴
                            xAxis: {
                                type: 'value',
                                boundaryGap: [0, 0.01]
                            },
                            yAxis: {
                                show:false,
                                type: 'category',
                                data : [],
                                axisTick: {
                                    alignWithLabel: true
                                }
                            },
                            //设置数据
                            series : []
                        };
                    $.ajax({
                        type : "get",
                        url : "${ctx}/app/meta/mgr/getAppSysTableCount.do",
                        cache : true,
                        async : true,
                        dataType : "json",
                        success : function(data) {
                            if(data){
                                var yAxis_dataList = [];
                                var bar_dataList = [];
                                for(var item in data){
                                    if(typeof(data[item])== "function")
                                        continue;
                                    yAxis_dataList.push(item);
                                    bar_dataList.push(data[item]);
                                    //console.log("data中"+item+"的值="+data[item]);
                                }
                                option2.yAxis.data = yAxis_dataList;
                                option2.series = [{
                                                    name:"数量",
                                                    type:"bar",
                                                    data:bar_dataList,
                                                    //设置柱的宽度
                                                    "barWidth":"65%",
                                                    itemStyle: {
                                                        normal: {
                                                            //设置柱状不同颜色,
                                                            color: function(params) {
                                                                // build a color map as your need.
                                                                var colorList = [
                                                                    '#6495ed','#ff7f50','#87cefa','#ffb980','#468cf5',
                                                                    '#86a2de','#31d976','#FAD860','#F3A43B','#60C0DD',
                                                                    '#D7504B','#C6E579','#F4E001','#F0805A','#C1232B'
                                                                ];
                                                                return colorList[params.dataIndex]
                                                            },
                                                            //以下为是否显示,显示位置和显示格式的设置了
                                                            label: {
                                                                show: true,
                                                                position: 'insideLeft',
                                                                formatter: '{b}[{c}]',
                                                                textStyle: {
                                                                     color: '#333',
                                                                     fontWeight: 'bold',
                                                                     fontSize: 11
                                                                 }
                                                            }
                                                        }
                                                    },
                                                }];
                               // 为echarts对象加载数据
                               myChart2.setOption(option2);
                            }
                        }
                    });
                    
                    这是我的代码!!!然后报错:this.dom.getContext is not a function
                    
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题