Date and Time in Annotated TimeLine GWT

72 views
Skip to first unread message

Jose Luis Hernandez

unread,
Dec 29, 2011, 6:10:08 AM12/29/11
to Google Web Toolkit
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:

http://i.stack.imgur.com/0j2BX.jpg

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!

Sean

unread,
Dec 30, 2011, 8:09:27 AM12/30/11
to google-we...@googlegroups.com
What happens when you zoom in further? I only see the time when I am sub-day in my zoom. Also, do you have more then one data point / day? With these options I get a time when I zoom in:

m_chartOptions = AnnotatedTimeLine.Options.create();
m_chartOptions.setDisplayAnnotations(true);
m_chartOptions.setDisplayZoomButtons(true);
m_chartOptions.setDisplayRangeSelector(true);
m_chartOptions.setScaleType(AnnotatedTimeLine.ScaleType.ALLFIXED); 
m_chartOptions.setDateFormat("yyyy.MM.dd 'at' hh:mm:ss aaa"); 
Good luck!
Reply all
Reply to author
Forward
0 new messages