-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I got some problems when using ZK Chart (1.3 now), one thing is that I never got the timezone right. I'm in GMT+8 timezone, and my time series chart always draws the point at 18:00pm (which should be at 0:00). So I tried to set the timezone right to solve the problem, but what i tried were all in vain.
Here are what I did.
Set up chart options.
Options options = new Options();
Global global = new Global();
global.setTimezoneOffset(8);
options.setGlobal(global);
chart.setOptions(options);
I tried to use this code at chart onCreate phase and ViewModel afterCompose phase and none of them was working. API Doc says there was a Charts.setOption(options) method, but I can't find it.
Then I tried to set up the org.zkoss.web.preferred.timeZone attribute in zk.xml, and of course it's not working.
It's hard to find any relevant example on the demo application or to search a valid solution. (ZK chart is really easy to confused with the old chart library for keyword search.)
So I come here and ask for help. Thank you.
I found the solution myself.
The reason why this code won't work is because the UTC time is still enabled. Here is the code that would work.
Options options = new Options();
Global global = new Global();
global.setTimezoneOffset(8);
global.setUseUTC(false);
options.setGlobal(global);
chart.setOptions(options);
Asked: 2014-11-14 07:13:32 +0800
Seen: 8 times
Last updated: Dec 26 '14