开发者社区 问答 正文

柱状图不报错,但不显示数据?报错

@Kener-林峰 你好,想跟你请教个问题:

是script引入的,这是ajax的代码

 function getData()
        {
            var arr = new Array();
            $.ajax({
                type:"get",
                url:"http://localhost:9090/height/getHeightData.json",
                dataType:"json",
                success:function(json){
                    for(var i in json)
                    {
                        arr[i] = json[i].height;
                    }
                },
                error:function(){
                    alert("error");
                }
            });
            return arr;
        }

下面这样调用的

 series : [
                            {
                                name: '身高',
                                type: 'bar',
                                data:getData()
                            }
                        ]
                    };
                    myChart.setOption(option);

调试的时候option中有值

展开
收起
爱吃鱼的程序员 2020-06-20 17:01:03 447 分享
分享
版权
举报
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    ajax请求中加个参数:async:false

    晕,同步、异步啊。。
    2020-06-20 17:01:21 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论
问答分类:
问答地址:
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等