3

I am plotting a chart using highcharter function. You can notice the timestamp starts from June 29th. But i when plot it , the graph shows data plotting from June 28,18.30. How do i change this time zone??

> head(d)
                   timestamps  x1  x2  x3  x4  x5  x6  x7  x8  x9 x10  x11     x12
    47948 2017-06-29 00:00:00 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 48.5 1210.87
    47949 2017-06-29 00:01:00 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 49.2 1213.91
    47950 2017-06-29 00:02:00 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 49.0 1213.59
    47951 2017-06-29 00:03:00 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 50.0 1214.28
    47952 2017-06-29 00:04:00 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 50.0 1212.13
    47953 2017-06-29 00:05:00 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 49.8 1216.06

PIC

library(highcharter)
highchart() %>% 
  hc_title(text = "A nice chart") %>% 
  hc_add_series_times_values(d$timestamps, 
                             d$x12, name = "x12")

Any help is appreciated. Thank you.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Magg_rs
  • 323
  • 2
  • 3
  • 12
  • Looks like a duplicate of https://stackoverflow.com/questions/25266392/how-to-set-highchart-global-options-in-r - have you tried to change the `timezoneOffset` ? – Paweł Fus Sep 19 '17 at 11:18
  • It is not clear enough how to set off UTC with highchart package. There is actually no timezoneoffset in highchart package and i even checked with R documentation. – Magg_rs Sep 19 '17 at 12:01
  • 1
    In `Highcharts` it's quite clear how to disable `useUTC`, [docs with sample](http://api.highcharts.com/highcharts/global). In `highcharter`, it looks like you should add your comment [to this ticket](https://github.com/jbkunst/highcharter/issues/69). It's about setting global options in Highcharter. – Paweł Fus Sep 19 '17 at 12:24

1 Answers1

4

This is how I managed to deactivate UTC in highcharter.

hcGopts <- getOption("highcharter.global")
hcGopts$useUTC <- FALSE
options(highcharter.global = hcGopts)

The global options are not directly accessible from R. From JavaScript, it would be like this:

Highcharts.setOptions({
    global: {
        useUTC: false
    }
});
f0nzie
  • 1,086
  • 14
  • 17