requirements for timezone support in TimeSeriesAxisOptions ?

44 views
Skip to first unread message

Cyril Hansen

unread,
Oct 29, 2014, 10:56:13 AM10/29/14
to gf...@googlegroups.com
Hi,

I have been trying to use the timezone support from flot from GWT for a few hours, and I am stuck.

For now I have found the following requirements :


- Add timezone-js script to GWT project (either from gwt.xml or html page)
- Add jquery / fleegix library for ajax loading of tz data or custom js function (i used jquery)
- Add tz files in webapp

- Add init code ; sometjhing like :

public static native void initTimezoneJS() /*-{

      $wnd.$(function() {   
        $wnd.timezoneJS.timezone.zoneFileBasePath = 'myproject/tz/';
        $wnd.timezoneJS.timezone.defaultZoneFile = 'europe'
        $wnd.timezoneJS.timezone.init({ async: false });
    });

}-*/;

My project uses xsiframe linker, so I added scripts from the html page header:
      <script type="text/javascript" src="js/jquery-2.1.1.min.js"/>
      <script type="text/javascript" src="js/timezone-js/src/date.js"/>


Now the plot stays solid white when I use TimeSeriesAxisOptions.setTimeZone().

If I don't call setTimeZone() the plot displays successfully.

Any clues or link ? My impression is that this issue is due to the non global javascript environnement in GWT project.


Thank you in advance,

Cyril


Nicolas Morel

unread,
Jan 19, 2015, 2:45:04 PM1/19/15
to gf...@googlegroups.com
Sorry, I didn't see your message.

You could try to inject the script like I do for jquery and flot scripts.
Take a look at com.googlecode.gflot.client.resources.FlotJavaScriptLoader and com.googlecode.gflot.client.resources.JQueryLoader.
If you manage to inject the timezone-js just after the JQuery and call your init code, it should work.

Unfortunately, FlotJavaScriptLoader.SynchronousImpl has no protected field so you would have to copy the class and add in your gwt.xml file : 
<replace-with class="package.MyFlotSynchronousImpl">
  <when-type-is class="com.googlecode.gflot.client.resources.FlotJavaScriptLoader.Impl" />
</replace-with>

You could also override the JQueryLoader with the same mechanism. You will have less code to copy/paste.

If that works, you can report back and I'll change the impl to allow an easier process.

Reply all
Reply to author
Forward
0 new messages