Vaadin DCharts在使用setExpandRatio时表现得太早。

时间:2022-09-15 10:41:08

I am currently experiencing a problem using the dChart widget addon (wrapper for jqPlot) in Vaadin v7.5.2. Here is a snippet of the code that is giving me a headache:

在Vaadin v7.5.2中,我正在使用dChart小部件addon (jqPlot包装器)遇到问题。下面是让我头疼的代码片段:

ComboBox comboBox = new ComboBox();
DCharts chart = new DCharts();

VerticalLayout content = new VerticalLayout();

content.addComponent(comboBox);
content.addComponent(chart);

content.setExpandRatio(chart, 1.0f);

setContent(content);

chart.setDataSeries(dataSeries).setOptions(options).show();

The problem is that when I use setExpandRatio, the chart is overflowing from the container when the page is loaded. Here is a picture to illustrate:

问题是当我使用setExpandRatio时,当页面加载时,图表会溢出容器。这里有一张图片说明:

Vaadin DCharts在使用setExpandRatio时表现得太早。

When I use web developer tools to hide the ComboBox and remove the margins, the plot looks OK. So it seems the plot gets drawn before the expand ratio is set, as if it doens't know the ComboBox is there.

当我使用web developer工具来隐藏ComboBox并删除页边距时,这个情节看起来很好。因此,在设定膨胀率之前,它似乎被绘制出来,好像它不知道ComboBox在那里。

However after selecting another item from the ComboBox (which loads another DataSeries), the chart is drawn within the expected boundaries and does not overflow. Also, when not setting an expand ratio or without adding the ComboBox, everything works as it should.

然而,在从ComboBox(加载另一个数据集)中选择另一个项目后,该图表将在预期的边界内绘制,不会溢出。此外,当没有设置扩展比或不添加ComboBox时,一切都是正常的。

Has anyone ever experienced similar issues, or has any idea what I could do to fix this? Any help is of course greatly appreciated!

有没有人遇到过类似的问题,或者我能做些什么来解决这个问题?任何帮助当然都非常感谢!

1 个解决方案

#1


0  

I know this is not an ideal solution, but I somehow managed to solve my problem by using an AbsoluteLayout, and drawing the plot using top: 40px. After that I add the ComboBox to the layout. That way the plot always gets drawn on the correct position.

我知道这不是一个理想的解决方案,但是我用一个绝对的方法解决了我的问题,并且用了40px的方法绘制了这个图。之后,我将ComboBox添加到布局中。这样,情节总是被正确的位置所吸引。

Just leaving this here as a temporary solution, so if anyone has a better one please do not hesitate!

把这个作为临时解决方案,所以如果有人有更好的,请不要犹豫!

#1


0  

I know this is not an ideal solution, but I somehow managed to solve my problem by using an AbsoluteLayout, and drawing the plot using top: 40px. After that I add the ComboBox to the layout. That way the plot always gets drawn on the correct position.

我知道这不是一个理想的解决方案,但是我用一个绝对的方法解决了我的问题,并且用了40px的方法绘制了这个图。之后,我将ComboBox添加到布局中。这样,情节总是被正确的位置所吸引。

Just leaving this here as a temporary solution, so if anyone has a better one please do not hesitate!

把这个作为临时解决方案,所以如果有人有更好的,请不要犹豫!