Closed jamessawyer closed 6 years ago
请尝试给你的app-line-echarts固定宽度
@xieziyu 给固定宽度就达不到宽度自适应的效果了,还有就是依然会有警告,我准备放弃用tabset组件了,准备直接使用按钮的方式。
这个问题和tabset组件的实现机制有关系。可以试一下一些workaround: 1、使用ngx-bootstrap的tabset组件 or 2、利用chartInstance的resize()函数 or 3、利用空的options或者*ngIf等其他方式延缓app-total-line渲染时间点到tab切换完成之后
2、3方法我觉得只是理论上可行的,但并不推荐这么做。重要的是要理解为什么tabset组件中,echarts无法获取到父容器的clientWidth或者clientHeight,然后以此改进。
第2种方式使用过了,没有效果。第3种方式尝试使用setTimeout延迟echarts渲染,但是没起作用。tabset组件中为什么无法获取父容器宽高,但是最后还是渲染了,并且给了100px的宽,这是我最想不通的地方。这个暂时一下无法理解其中的原理,待进一步去学习了,谢谢大佬了 @xieziyu
我想在tabset组件中使用二次封装的折线图组件,但是经常报
Can't get dom width or height
警告,但是所有折线图还是会被渲染出来。当前的tab(页面加载时显示的tab)中的折线图宽高正常,但是切换到其余tab中的折线图,折线图宽度只有100px
,我设置的宽度均为100%
(为了自适应),不知道大佬有没有遇到过这个问题?有没有什么解决办法 我个人觉得可能是tabset动态插入模板的时候,app-total-line
组件无法获取到父容器的宽高导致的。部分代码如下:
tabset
tabset
组件模板app-total-line 组件
app-line-echarts
是对echarts
指令的二次封装