Vaadin 14 FlagItems 在 ListSeries 上未正确对齐

发布于 2025-01-11 07:42:16 字数 1441 浏览 5 评论 0原文

我在 Vaadin 14 中遇到了有关 FlagItem 的问题。

我正在尝试为 ListSeries 中的特定点设置 FlagItem,我按以下方式执行此操作:

PlotOptionsFlags plotOptionsFlags = new PlotOptionsFlags();
plotOptionsFlags.setOnSeries(wageEntry.getEmployeeCode());
plotOptionsFlags.setShape(FlagShape.SQUAREPIN);
plotOptionsFlags.getTooltip().setPointFormat("Wage: {point.y}");
plotOptionsFlags.getTooltip().setHeaderFormat("");
plotOptionsFlags.setShowInLegend(false);
DataSeries flagsSeries = new DataSeries();
flagsSeries.setName(wageEntry.getEmployeeCode().concat(" Current Wage"));
flagsSeries.setPlotOptions(plotOptionsFlags);
for (WageEntry wage : employeeWageEntries) {
    if (wage.getWageYear() == LocalDate.now().getYear()) {
       flagsSeries.add(new FlagItem(wage.getAge() - 22, wage.getEmployeeCode().concat(" - ").concat(String.valueOf(wage.getWageAmount()))));
    }
}
comparisonChartConfiguration.addSeries(flagsSeries);

如您所见,我设置了相对于的 x 值条目的年龄和文本。更重要的是,FlagItem 仅在满足特定条件时才会创建。 (我使用 Vaadin 图表演示作为参考:https://demo.vaadin.com/charts/Flags< /a>)

现在的问题是,当构建图表时,FlagItem 出现在 x 轴上,如下所示:

在此处输入图像描述

我真的不明白为什么会发生这种情况。

也许知道图表上正在绘制三个 RangeSeries 和多个 ListSeries 是有用的。

感谢您的帮助!

I've got a problem regarding the FlagItem in Vaadin 14.

I'm trying to set a FlagItem for a specific point in a ListSeries, I'm doing this the following way:

PlotOptionsFlags plotOptionsFlags = new PlotOptionsFlags();
plotOptionsFlags.setOnSeries(wageEntry.getEmployeeCode());
plotOptionsFlags.setShape(FlagShape.SQUAREPIN);
plotOptionsFlags.getTooltip().setPointFormat("Wage: {point.y}");
plotOptionsFlags.getTooltip().setHeaderFormat("");
plotOptionsFlags.setShowInLegend(false);
DataSeries flagsSeries = new DataSeries();
flagsSeries.setName(wageEntry.getEmployeeCode().concat(" Current Wage"));
flagsSeries.setPlotOptions(plotOptionsFlags);
for (WageEntry wage : employeeWageEntries) {
    if (wage.getWageYear() == LocalDate.now().getYear()) {
       flagsSeries.add(new FlagItem(wage.getAge() - 22, wage.getEmployeeCode().concat(" - ").concat(String.valueOf(wage.getWageAmount()))));
    }
}
comparisonChartConfiguration.addSeries(flagsSeries);

As you can see, I set the x value relative to the age of an entry, and the text. More over the FlagItem is only created when a certain condition is met. (I used the Vaadin Chart Demo as reference: https://demo.vaadin.com/charts/Flags)

The problem now is, that when the chart is being built, the FlagItem appear on the x axis instead as you can see here:

enter image description here

I really don't understand why this happens.

Maybe it's useful to know, that on the chart three RangeSeries and multiple ListSeries are being drawn.

Thanks for the help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街角迷惘 2025-01-18 07:42:16

所以我知道问题出在哪里了。这是上面代码中没有添加的内容,所以请仁慈。

问题在于,在创建 flagsSeries 之前,我没有将 ListSeries 添加到 comparisonChartConfiguration 中。

简而言之,您需要将要附加标志的系列添加到 ChartConfiguration 中,然后才能将 flagsSeries 附加到另一个系列上。

So I've found out where the problem was. It was something that wasn't added to the code above, so please have mercy.

The issues lied withing the fact that I didn't add the ListSeries to the comparisonChartConfiguration before creating the flagsSeries.

In short, you need to add the Series you want to append flags on to the ChartConfiguration before you can attach the flagsSeries onto another.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文