This repository was archived by the owner on Feb 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
This repository was archived by the owner on Feb 15, 2022. It is now read-only.
formatting labels by timezone in a datetime axis #42
Copy link
Copy link
Open
Description
What steps will reproduce the problem?
1. Create a DataTable:
myDataTable = DataTable.create();
myDataTable.addColumn(ColumnType.DATETIME);
myDataTable.addColumn(ColumnType.NUMBER);
2. Add bunch of rows:
myDataTable.setValue(recCount, 0, myDate);
myDataTable.setValue(recCount, 1, myFloat);
Each java.util.Date instance is constructed from a unix datetime long value
retrieved from a database. In this example there are 24 datapoints retrieved,
each pair separated by one hour, beginning at 0000 UTC and running through 2300
UTC (inclusive) on the day in question.
3. Use DateFormat to format the first column of the completed DataTable:
// this works correctly!
DateFormatOptions utcFmtOptions = DateFormatOptions.create();
utcFmtOptions.setTimeZone(0);
utcFmtOptions.setPattern("yyyy-MM-dd HH:mm:ss z");
DateFormat utcFmt = DateFormat.create(utcFmtOptions);
utcFmt.format(dataTable, 0);
4. Create a LineChart (this code snippet is somewhat abridged):
LineChart myChart = new LineChart();
LineChartOptions options = LineChartOptions.create();
options.setBackgroundColor("#f0f0f0");
options.setLineWidth(2);
HAxis xAxis = HAxis.create(xLabel);
// this is a PROBLEM -- displays in Browser/Client local time zone
xAxis.setFormat("MM/dd HH:mm");
options.setHAxis(xAxis);
VAxis yAxis = VAxis.create(yLabel);
yAxis.setViewWindowMode("maximized");
options.setVAxis(yAxis);
myChart.draw(dataTable, options);
What is the expected output? What do you see instead?
See two attached screen caps showing two views of the resulting chart. This is
a particularly obvious example because it covers Sunday, March 10, 2013, which
is when my local browser/client timezone begins daylight saving. The records
are retrieved correctly in unix datetimes for that day, exactly one hour apart,
and the xAxis title (which I constructed) is correctly showing UTC. The hover
text of every individual datapoint is also correct. But the xAxis labels are
showing not in UTC but some in EST and some in EDT (note the irregular grid
spacing, too).
In the first image the hover text is correctly showing a time of 0100 UTC but
that spot on the axis is labeled with 2000 (EST) the day before, five hours
off. In the second image the hover text is correctly showing a time of 1600
UTC but that spot on the axis is labeled with 1200 (EDT), which is four hours
off.
I would like some way of specifying not just a format mask but also a timezone
for the axis labels. Or perhaps some way of setting a global default timezone
that would override the browser/client locale. These data are all collected,
stored, and published in UTC and there is no reason anyone would ever want to
view them in their local time zone.
What operating system, browser and version are you using?
I'm not sure which details are relevant here (and I'd be happy to provide more)
but here are some:
Server: Scientific Linux 6.4, 2.6.32-358.11.1.el6.i686
Client: Mac OS X 10.8.4, Safari 6.0.5 (8536.30.1)
regards,
Mike J+
Original issue reported on code.google.com by n...@jankplus.users.panix.com on 16 Jul 2013 at 10:30
Attachments: