开发者社区> 问答> 正文

echart的图表类型(series里的type参数)能用ajax异步加载吗??报错

echart的图表类型(series里的type参数)能用ajax异步加载吗?

补充一下代码:

运行会报错js:Uncaught TypeError: Cannot read property 'width' of undefined

如果改成option.series[0].name = result.type 代码也能正常运行。

展开
收起
爱吃鱼的程序员 2020-06-08 16:55:45 1288 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    我用过highCharts可以异步加载参数再生成图标 

    虽然没用过,但是应该是可以的啊

    $.post('url',function(ret){varmyChart=echarts.init(document.getElementById('main'));varoption={series:[{name:'销量',type:ret.type,data:[5,20,36,10,10,20]}]}myChart.setOption(option);})

    这样不行么

    应该是可以的

    2020-06-08 16:55:55
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
利用编译将 Vue 组件转成 React 组件 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载