It is currently Mon Sep 24, 2018 6:51 am Advanced search

Using timezones with export server.

Technical support, bug reports and more.

Using timezones with export server.

Postby sjerman » Mon Mar 12, 2018 6:26 pm

Hi,

I have been playing with the export server and have been unable to generate charts with the correct timezone offset:

Using http://export.highcharts.com/, I tried the config below with no joy - it always shows data in UTC.

I did read in API docs, and they say the moment.js (and presumably moment-timezone) is needed. Is this included in the export server?

However, even setting timezoneOffset doesn't seem to change stuff ... so I'm probably doing something obviously wrong.

Steve

Code: Select all
{
    "time":{
         "timezone":"America/New_York",
         "useUTC":false
      },
      "chart":{
         "type":"areaspline"
      },
      "title":{
         "text":"MSteve"
      },
      "subtitle":{
         "text":"Steve Chart"
      },
      "series":[
         {
            "name":"Apples",
            "stacking": "normal",
            "data":[
               [
                  1520661600000,
                  29.9
               ],
               [
                  1520665200000,
                  71.5
               ],
               [
                  1520686800000,
                  106.4
               ]
            ]
         },
         {
            "name":"Oranges",
            "stacking": "normal",
            "data":[
               [
                  1520661600000,
                  35.9
               ],
               [
                  1520665200000,
                  60.5
               ],
               [
                  1520686800000,
                  156.4
               ]
            ]
         }
      ],
      "xAxis":{
         "type":"datetime",
         "dateTimeLabelFormats":{
            "hour":"%e. %b %H:%M",
            "month":"%e. %b",
            "year":"%b"
         },
         "title":{
            "text":"Time of day"
         }
      }
   }
sjerman
 
Posts: 6
Joined: Mon Mar 12, 2018 6:13 pm

Re: Using timezones with export server.

Postby ppotaczek » Tue Mar 13, 2018 3:33 pm

Hi sjerman,

Moment.js and moment-timezone.js are not included in the export server. You can set up your own export server - please check the link below to docs.
If you use: http://export.highcharts.com/ you would have to add all the code of libraries to 'JavaScript' section.

Docs: https://www.highcharts.com/docs/export- ... the-server

Best regards!
Paweł Potaczek,
Highcharts Developer
ppotaczek
 
Posts: 743
Joined: Mon Oct 02, 2017 5:12 pm

Re: Using timezones with export server.

Postby sjerman » Tue Mar 13, 2018 4:54 pm

Thanks. That answers my question.
sjerman
 
Posts: 6
Joined: Mon Mar 12, 2018 6:13 pm

Re: Using timezones with export server.

Postby sjerman » Tue Mar 13, 2018 8:39 pm

OK, I am still having issues.

I am trying to build a Docker container... attached is docker file.

Below is my test chart. I can shift the time using the timezoneOffset property. However, I can't use 'timezone'.. doesn't seem to have any effect. I do wonder if the issue is that moment/moment-timezone need to be in the context of the phantom server... but don't see how to do that.

Thanks
Steve

Code: Select all
{
   "type":"svg",
   
   "infile":{
     "time":{
         "timezoneOffset": 420
      },
      "chart":{
         "type":"areaspline"
      },
      "title":{
         "text":"MSteve"
      },
      "subtitle":{
         "text":"Steve Chart"
      },
      "series":[
         {
            "name":"Apples",
            "stacking": "normal"
         },
         {
            "name":"Oranges",
            "stacking": "normal"
         }
      ],
      "tooltip":{
         "headerFormat":"<b>{series.name}</b><br>",
         "pointFormat":"{point.x:%e. %b}: {point.y:.2f}"
      },
      "xAxis":{
         "type":"datetime",
         "title":{
            "text":"Time of day"
         }
      },
         "data":{
        "columns": [
            ["timestamp", 1520661600000, 1520665200000, 1520686800000],
            ["Oranges", 35.9, 60.5, 156.4],
            ["Apples", 29.9, 71.5, 106.4]
        ]
   }
   }
}


Docker file...

Code: Select all
from node:8.10.0

WORKDIR /usr/share/fonts/truetype
ADD fonts/OpenSans-Regular.ttf OpenSans-Regular.ttf
ADD fonts/OpenSans-Light.ttf OpenSans-Light.ttf
ADD fonts/OpenSans-Semibold.ttf OpenSans-Semibold.ttf
ADD fonts/OpenSans-Bold.ttf OpenSans-Bold.ttf
ADD fonts/OpenSans-ExtraBold.ttf OpenSans-ExtraBold.ttf
ADD fonts/OpenSans-Italic.ttf OpenSans-Italic.ttf
ADD fonts/OpenSans-LightItalic.ttf OpenSans-LightItalic.ttf
ADD fonts/OpenSans-BoldItalic.ttf OpenSans-BoldItalic.ttf
ADD fonts/OpenSans-SemiboldItalic.ttf OpenSans-SemiboldItalic.ttf
ADD fonts/OpenSans-ExtraBoldItalic.ttf OpenSans-ExtraBoldItalic.ttf

WORKDIR /

RUN git clone  https://github.com/highcharts/node-export-server.git && \
    chown -R node /node-export-server
   
WORKDIR /node-export-server

USER node

ENV ACCEPT_HIGHCHARTS_LICENSE="YES"

RUN rm package-lock.json && \
   npm install -S  moment moment-timezone && \
    npm install
   
USER root   
RUN npm link --unsafe-perm
   
USER node

WORKDIR /node-export-server

EXPOSE 7801
ENTRYPOINT ["highcharts-export-server", "--enableServer", "1", "--logLevel", "4"]

sjerman
 
Posts: 6
Joined: Mon Mar 12, 2018 6:13 pm

Re: Using timezones with export server.

Postby KacperMadej » Wed Mar 14, 2018 12:32 pm

Hi,

If Moment.js is not loaded you should get error #25 (https://www.highcharts.com/errors/25).

To check were are the errors generated you can try setting type of chart to something that is not a correct series type - you will get a different error, but it's an easy way of checking errors.

Another problem might be caused by loading wrong Moment.js library version / resources. Please check this demo and related required Moment.js files loaded in the HTML section of the demo: http://jsfiddle.net/gh/get/library/pure ... /timezone/

Best Regards
Kacper Madej
Highcharts Developer
KacperMadej
 
Posts: 4507
Joined: Mon Sep 15, 2014 2:43 pm

Re: Using timezones with export server.

Postby sjerman » Wed Mar 14, 2018 5:13 pm

Hi,

I never see errors in the LOG ... but as as I say I am using 'export server'' rather than the straight JS.

Note that if you paste the following into http://export.highcharts.com/ you get the same behaviour..

Code: Select all
{
      "time":{
         "timezone": "America/New_York"
      },
      "chart":{
         "type":"areaspline"
      },
      "series":[
         {
            "name":"Apples",
            "stacking": "normal"
         },
         {
            "name":"Oranges",
            "stacking": "normal"
         }
      ],
      "xAxis":{
         "type":"datetime",
      },
      "data":{
        "columns": [
            ["timestamp", 1520661600000, 1520665200000, 1520686800000],
            ["Oranges", 35.9, 60.5, 156.4],
            ["Apples", 29.9, 71.5, 106.4]
        ]
   }
}


Replacing timezone with
timezoneOffset: 240

Gives what you expect.

Steve
sjerman
 
Posts: 6
Joined: Mon Mar 12, 2018 6:13 pm

Re: Using timezones with export server.

Postby sjerman » Wed Mar 14, 2018 5:59 pm

sjerman
 
Posts: 6
Joined: Mon Mar 12, 2018 6:13 pm


Return to Highcharts Usage

Who is online

Users browsing this forum: Bing [Bot] and 4 guests