Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fractional second handling (millisecond time) #85

Closed
kuna-matata opened this issue Oct 7, 2015 · 4 comments
Closed

Fractional second handling (millisecond time) #85

kuna-matata opened this issue Oct 7, 2015 · 4 comments

Comments

@kuna-matata
Copy link

Please also see danvk/dygraphs#654.

When I use library(dygraphs) with fractional second time series data, it appears to truncate or round the abscissa to the nearest whole second. The above post demonstrates that the rounding issue does not happen with direct dygraphs.js usage. I wonder if the issue has to do with the R interface. Here's example code in R that illustrates the issue for me:

library(xts)
library(dygraphs)
r = 5
t = seq(0,2*pi,by=0.03)
x = r*cos(t)
y = r*sin(t)
t0 = Sys.time()
ts = xts(y,t0-unclass(t0)+x)
dygraph(ts)
@TonyDIRL
Copy link

TonyDIRL commented Oct 7, 2015

Bump on this query.

@kuna-matata and I have been trying to figure this out for quite a while!

dygraphs is quite powerful because of the volume of data it can quickly process but not been able to plot sub-second data is quite limiting.

@DaveRom
Copy link

DaveRom commented Oct 22, 2015

@TonyDIRL @kuna-matata @jjallaire

Were ye able to find a solution to this problem?
I am also trying to build sub second charts with dygraphs

@TonyDIRL
Copy link

No, unfortunately, I have not been able to find a solution to this issue

@TonyDIRL
Copy link

Hi,

As this question has been asked by several different people in different repo's I thought I'd summarize it here for future reference.

The problem is generating subsecond graphs with dygraphs.
The following jfiddle illustrates that this can be done with javascript: http://jsfiddle.net/kaliatech/DfWNz/3/

However, transferring the corresponding code to axisLabelFormatter and valueFormatter unfortunately doesn't yield the same results

   options(digits.secs=9)
   len <- 60 
   RDData <- xts(runif(len,0,1), seq(as.POSIXct("2015-04-01 10:00:00"),as.POSIXct("2015-04-01 10:00:01"), length = len),tz="GMT")

  dygraph(RDData) %>%
  dyAxis(
    "x",
    label = "Number",
    axisLabelFormatter = 'function(d,gran){ return Dygraph.zeropad(d.getHours()) + ":" + 
                                 Dygraph.zeropad(d.getMinutes()) + ":" + 
                                 Dygraph.zeropad(d.getSeconds()) + "." + 
                                 Dygraph.zeropad(d.getMilliseconds());}',
    valueFormatter = 'function(ms){    var d = new Date(ms);
                          return Dygraph.zeropad(d.getHours()) + ":" + 
                          Dygraph.zeropad(d.getMinutes()) + ":" + 
                          Dygraph.zeropad(d.getSeconds()) + "." + 
                          Dygraph.zeropad(d.getMilliseconds());}'
    ,ticker="Dygraph.dateTicker"
  )

Have tried numerous variations but can't get this to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants