antvis/G6

如何设置graph 100% height, width? #4672

neolee6053 posted onGitHub

问题描述

如何设置graph 100% height, width? 为什么一定要px 值呢? 为什么不可以set 100%?

重现链接

https://codesandbox.io/s/g6-p6fq42?file=/index.js

重现步骤

如上

预期行为

如上

平台

  • 操作系统: [ Windows]
  • 网页浏览器: [Google Chrome,]
  • G6 版本: [4.8.15]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response


不给 graph 配置 width height,默认就是 100% 填充容器

posted by Yanyan-Wang almost 2 years ago

不给 graph 配置 width height,默认就是 100% 填充容器

我试了,不能啊。整个graph不见了 image

posted by neolee6053 almost 2 years ago

首先你要保证容器有 width height,graph 才能 100%

https://codesandbox.io/s/romantic-river-pstn59?file=/index.js

posted by Yanyan-Wang almost 2 years ago

首先你要保证容器有 width height,graph 才能 100%

https://codesandbox.io/s/romantic-river-pstn59?file=/index.js

奇怪,应该是codesandbox的问题。在css file里,但不可以。 #container { height: 650px; width: 1000px; border: 2px solid #000; }

但html 就可以,奇怪。 style="width: 1000px; height: 800px;"

无论如何,谢谢!

posted by neolee6053 almost 2 years ago

Fund this Issue

$0.00
Funded

Pull requests