带注释的时间线 GWT 中的日期和时间
我正在 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:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将格式设置为 MMMM dd, yyyy 并尝试或尝试不设置任何格式。
Either set the format to MMMM dd, yyyy and try or try without setting any format.
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 ?