带注释的时间线 GWT 中的日期和时间

发布于 2024-12-23 10:51:36 字数 1828 浏览 5 评论 0原文

我正在 GWT 中绘制趋势图。具体来说,AnnotatedTimeLine。我的Java代码是:

Runnable onLoadCallback = new Runnable() {
        public void run() {
            ArrayList<AttributeDTO> occAttrs = new   ArrayList<AttributeDTO>();
            for(AttributeDTO attr : attrs){
                if(attr.getName().toLowerCase().contains("temp")){
                    occAttrs.add(attr);
                }
            }
            DataTable data = DataTable.create();
            data.addColumn(ColumnType.DATE, "Date");
            data.addColumn(ColumnType.NUMBER, "Temperature");
            data.addRows(occAttrs.size());
            RootPanel.get().add(new Label(occAttrs.toString()));
            DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy.MM.dd 'at' hh:mm:ss aaa");
            for(int i = 0; i < occAttrs.size(); i++){
                data.setValue(i, 0, dtf.parse(occAttrs.get(i).getDate()));
                data.setValue(i, 1, Integer.valueOf(occAttrs.get(i).getValue()));
            }

            AnnotatedTimeLine.Options options = AnnotatedTimeLine.Options.create();
            options.setDisplayAnnotations(true);
            options.setDisplayZoomButtons(true);
            options.setScaleType(AnnotatedTimeLine.ScaleType.ALLFIXED);
            options.setDateFormat("yyyy.MM.dd 'at' hh:mm:ss aaa");
            options.setLegendPosition(AnnotatedTimeLine.AnnotatedLegendPosition.SAME_ROW);
            AnnotatedTimeLine atl = new AnnotatedTimeLine(data, options, "600px", "400px");

            vPanel.add(atl);
        }

    };
    VisualizationUtils.loadVisualizationApi(onLoadCallback, AnnotatedTimeLine.PACKAGE);

嗯,当我显示图表时,我得到下图:

在此处输入图像描述

在 x 轴上我有没有时间的日期。我想包括时间。我怎样才能得到它?

提前致谢!!

国王致意,圣诞快乐!

I am plotting a trend chart in GWT. In concrete, AnnotatedTimeLine. My Java code is:

Runnable onLoadCallback = new Runnable() {
        public void run() {
            ArrayList<AttributeDTO> occAttrs = new   ArrayList<AttributeDTO>();
            for(AttributeDTO attr : attrs){
                if(attr.getName().toLowerCase().contains("temp")){
                    occAttrs.add(attr);
                }
            }
            DataTable data = DataTable.create();
            data.addColumn(ColumnType.DATE, "Date");
            data.addColumn(ColumnType.NUMBER, "Temperature");
            data.addRows(occAttrs.size());
            RootPanel.get().add(new Label(occAttrs.toString()));
            DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy.MM.dd 'at' hh:mm:ss aaa");
            for(int i = 0; i < occAttrs.size(); i++){
                data.setValue(i, 0, dtf.parse(occAttrs.get(i).getDate()));
                data.setValue(i, 1, Integer.valueOf(occAttrs.get(i).getValue()));
            }

            AnnotatedTimeLine.Options options = AnnotatedTimeLine.Options.create();
            options.setDisplayAnnotations(true);
            options.setDisplayZoomButtons(true);
            options.setScaleType(AnnotatedTimeLine.ScaleType.ALLFIXED);
            options.setDateFormat("yyyy.MM.dd 'at' hh:mm:ss aaa");
            options.setLegendPosition(AnnotatedTimeLine.AnnotatedLegendPosition.SAME_ROW);
            AnnotatedTimeLine atl = new AnnotatedTimeLine(data, options, "600px", "400px");

            vPanel.add(atl);
        }

    };
    VisualizationUtils.loadVisualizationApi(onLoadCallback, AnnotatedTimeLine.PACKAGE);

Well, when I show graph I obtain the following figure:

enter image description here

In x axis I have date without time. I would like to include time. How could I get it?

Thanks in advance!!

King regard and merry christmas!

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

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

发布评论

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

评论(2

戏蝶舞 2024-12-30 10:51:36

将格式设置为 MMMM dd, yyyy 并尝试或尝试不设置任何格式。

Either set the format to MMMM dd, yyyy and try or try without setting any format.

那请放手 2024-12-30 10:51:36

google的api文档中明确解释,它仅支持DATE,不支持datetime。

我面临着将多个值存储到同一日期的相同要求。您是否找到任何其他库可以正确处理这个问题?

It is clearly explained in google's api documentation, that it supports only DATE and datetime is not supported.

I'm facing the same requirement to store multiple values into same date. Did you find any other library, which can handle this problem correctly ?

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