gpt4 book ai didi

charts - 谷歌图表 : timeline: dynamic height with scalebar position

转载 作者:行者123 更新时间:2023-12-04 21:52:40 25 4
gpt4 key购买 nike

感谢您的观看和回答。
我正在使用 Google Charts (TimeLine) 来显示数据库中的信息。
但是 Google Chart 引用仅提供图表的设置固定高度。
而我想根据从数据中获得的行数来更改图表高度。
所以我做了代码:

    var graph = $('#chart_timeLine').children()[0].children[0].children[1];
$(graph).css('height',graph.scrollHeight);
$(graph).css('overflow-y','auto');

现在图表没有垂直滚动条,我很满意。
但是我发现显示时间轴图表比例尺的比例尺不见了。(它实际上是隐藏在图表下方,而不是显示在图表底部)。

然后我将比例尺的位置更改为绝对位置并将其设置在图表的底部。
然后它很丑,因为它的高度为 200 像素,而比例尺在 200 像素的底部,在我的图表和比例尺之间留下了巨大的空白。

有解决办法吗?
谢谢你。

最佳答案

不要弄乱图表的内部工作,而是根据 DataTable 中的数据行数设置高度:

// set a padding value to cover the height of title and axis values
var paddingHeight = 40;
// set the height to be covered by the rows
var rowHeight = data.getNumberOfRows() * 15;
// set the total chart height
var chartHeight = rowHeight + paddingHeight;

然后在时间轴的选项中,设置高度:
height: chartHeight

关于charts - 谷歌图表 : timeline: dynamic height with scalebar position,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18640818/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com