Handling dates and large numbers with rCharts + polychart

317 views Asked by At

In the following sample I build a data.frame with sample data: timestamp and a value associated with it. I then try plotting these data using rCharts with polychart as a backend, once using original time stamp, and once after converting it to intiger:

    dtf <- data.frame(timestamp=c("2013-02-01 00:02:16", "2013-02-01 00:02:21", "2013-02-02 05:02:27", 
                                               "2013-02-02 10:02:54", "2013-02-02 11:02:14", "2013-03-01 01:02:37", 
                                               "2013-03-01 02:02:07", "2013-03-01 02:12:09", "2013-03-01 13:02:30", 
                                               "2013-04-04 02:02:33", "2013-04-04 09:02:54", "2013-04-09 10:02:01", 
                                               "2013-04-09 21:02:22"), 

                      value=c(12.5, 16.7, 16.7, 16.7, 12.5, 12.6, 16.7, 16.8, 16.7, 16.8, 
                               16.8, 16.7, 16.8),
                      group=c("B", "A", "A", "A", "B", "A", "A", "A", "A", "A", "A", "A", 
                              "A")
    )
    dtf$x <-  as.double(as.POSIXct(dtf$timestamp))
    plt1 <- rPlot(x= 'timestamp',
                y='value' ,
                data=dtf, 
                type = 'point',
                size=list(const=2))

    plt2 <- rPlot(x= 'x',
                  y='value' ,
                  data=dtf, 
                  type = 'point',
                  size=list(const=2))

    print(plt1)
    print(plt2)

The first plot (plt1) looks like this :

plt1

The second one is as follows:

enter image description here

As you may see, the dates are truncated so that data points that fall in the same date have the same X coordinate, regardless the hour/minute value. The tooltip shown on both plots is also truncated. How can I keep the hour/minute resolution using polychart?

EDIT

Having played with this, I came to a conclusion that polychart does not deal well with X values above 10^9. I still could not find a way to solve this.

0

There are 0 answers