2
回答
力导向图二次加载失败

@pissang ,您好

我在使用force的时候出现下面的问题,是后台传入的数据,但是第二次点击按钮(不是刷新页面)的时候就会出现下面的问题,force图也没有出来,错误出在force.js的515行,代码和错误如下,能帮我看下吗

  require(
            [
                'echarts',
                'echarts/chart/force',
                'echarts/chart/bar'
            ],
            function(ec) {
                var myChart = ec.init(document.getElementById('main'));
                myChart.clear();
                myChart.setOption(option);
            }
        )

 

举报
九指神丐
发帖于5年前 2回/193阅
共有2个答案 最后回答: 5年前
能具体点么?比如你的option...点击的是什么按钮
--- 共有 4 条评论 ---
pissangsetOption后是会重置的, 检查一下数据是否正确? 5年前 回复
九指神丐按钮点击查询后,添加一个jsp include标签,引入的内容就是force相关,第一次可以正常显示,刷新页面也正常,但是后面再次点击此按钮时就会出现这个错误,感觉应该是缓存方面的。那个clear不能移除内容吗 5年前 回复
九指神丐按钮是一个查询,从后台查询的数据在前台显示出来,option的东西比较多,我贴在下面 5年前 回复

require.config({
            packages: [
                {
                    name: 'echarts',
                    location: '../../echarts/src',
                    main: 'echarts'
                },
                {
                    name: 'zrender',
                    location: '../../zrender/src',
                    main: 'zrender'
                }
            ]
        });

  
        var option={
        tooltip:{
        tooltip : 'item' ,
        formatter : '{a}:{b}'
        },
       
        legend: {
        x: 'left',
        data:['个人正式客户','对公正式客户','不能区分','crm个人潜在客户','crm对公潜在客户','信贷个人潜在客户','信贷对公潜在客户']
    },  
        series : [
        {
            type:'force',
            categories : [
           
                 {
     name : '被查询客户',
     itemStyle: {
                        normal: {
                            color : '#ff7f50'
                        }
                    }
                },
                {
                    name: '个人正式客户',
                    itemStyle: {
                        normal: {
                            color : '#87cdfa'
                        }
                    }
                },
                {
                    name:'对公正式客户',
                    itemStyle: {
                        normal: {
                            color : '#9acd32'
                        }
                    }
                },
                 {
                    name:'不能区分',
                    itemStyle: {
                        normal: {
                            color : '#CC99090'
                        }
                    }
                },
                 {
                    name:'crm个人潜在客户',
                    itemStyle: {
                        normal: {
                            color : '#CC3300'
                        }
                    }
                },
                 {
                    name:'crm对公潜在客户',
                    itemStyle: {
                        normal: {
                            color : '#00CC33'
                        }
                    }
                },
                 {
                    name:'信贷个人潜在客户',
                    itemStyle: {
                        normal: {
                            color : '#006666'
                        }
                    }
                },
                 {
                    name:'信贷对公潜在客户',
                    itemStyle: {
                        normal: {
                            color : '#ff33ff'
                        }
                    }
                }
            ],
            itemStyle: {
                normal: {
                    label: {
                        show: true,
                        textStyle: {
                            color: '#800080'
                        }
                    },
                    nodeStyle : {
                        brushType : 'both',
                        strokeColor : 'rgba(255,215,0,0.4)',
                        lineWidth : 8
                    }
                },
                emphasis: {
                    label: {
                        show: false
                      
                    },
                    nodeStyle : {
                        r: 30
                    },
                    linkStyle : {}
                }
            },
          
            minRadius : 15,
            maxRadius : 25,
            density : 0.05,
            attractiveness: 1.2,
            nodes:[
              
             <%
             
             for(Map<String, Object> dotSingle : dotList){
               %>
              {category:<%=dotSingle.get("category")%>, name: '<%=dotSingle.get("name") %>', value : <%=dotSingle.get("value")%>},
              
              <%
  
    } 
             
             %>
            ],
           
            links : [
             <%
             
             for(Map<String, Object> lineSingle : lineList){
           
             if((lineList.indexOf(lineSingle) == lineList.size()-1)){
             
             %>
             {source : <%=lineSingle.get("source")%>, target : <%=lineSingle.get("target")%>, weight : <%=lineSingle.get("weight")%>}
             <%
             }
             else{
                
    %>
     {source : <%=lineSingle.get("source")%>, target : <%=lineSingle.get("target")%>, weight : <%=lineSingle.get("weight")%>},
  
    <%
     }
    }
              %>

            ]
        }
    ]
        }


  require(
            [
                'echarts',
                'echarts/chart/force',
                'echarts/chart/bar'
            ],
            function(ec) {
                var myChart1 = ec.init(document.getElementById('main'));
                myChart1.clear();
                myChart.setOption(option);
            }
        )

这基本是全部的代码了,按钮是个点击查询的

顶部