X axis date in googleVis LineChart

I am trying to get the x axis to support time using gvisLineChart. The problem is that she is always interpreted as a character.

library(googleVis)
dat <- data.frame(time=as.POSIXct(c("2012-09-23 12:00:00", "2012-04-25 18:00:00", "2011-03-01 02:34:00")), 
                  x=rnorm(3), y=rnorm(3))


plot(gvisLineChart(dat))

How to make the x axis correctly interpreted as a date? I am sure that options=list(hAxis.format:"...")this is a solution somehow, but various formats, including "yyyy-MM-dd HH: mm: ss", but they do not seem to fix my problem at all.

In conclusion, I want the Google datapartes to show the continuous datetime axis.

+5
source share
1 answer

, , . , CRAN- googleVis (0.3.3) ( R, POSIX Date).

0.3.3:

library(googleVis)
x <- as.Date(c(Sys.Date()+sample(1:100, 3)))

df <- data.frame(country=c("US", "GB", "BR"),
                 val1=c(1,3,4),
                 val2=c(23,12,32),
                 year=2011:2013,
                 num=c(1.2, 2.3, 3.4),
                 date=x)

Line4 <- gvisLineChart(df, xvar="date", yvar=c("val1", "val2"))

plot(Line4)

0.4.1, .

+7

All Articles