0

When I use below World bank example code, it works. That means browser etc are good.

WorldBank <- droplevels(subset(wdiData, !region %in% "Aggregates"))

M <- gvisMotionChart(WorldBank,idvar="country", timevar="year",xvar="life.expectancy", yvar="fertility.rate",colorvar="region", sizevar="population",options=list(width=700, height=600),chartid="WorldBank")

## Display the chart in the browser
plot(M)

But when I use below program. No error appears but on plot command blank browser appears...see below program, data frame and out put.

Program

# This demo shows how to use Google Motion Chart

library(googleVis)

metro<-read.csv("c:/Ram/metromotion.txt",stringsAsFactors=FALSE,header=F) # reads d=from metro.txt into data frame metro

# Naming columns. 

colnames(metro)[1]="Time"
colnames(metro)[2]="Station"
colnames(metro)[3]="Latitude"
colnames(metro)[4]="Longitude"
colnames(metro)[5]="Traffic"
colnames(metro)[6]="Kside"
colnames(metro)[7]="Uside"
colnames(metro)[8]="Line"


N <- gvisMotionChart(metro,idvar="Station", timevar="Time",xvar="Kside",yvar="Uside",colorvar="Line", sizevar="Traffic",options=list(width=700, height=600),
chartid="Metro")

# Display the chart in the browser
plot(N)

Sample Truncated Data Frame

   Time    Station Latitude Longitude Traffic Kside Uside Line
1     1      abc      17.41     78.58    1000  1000     0    1
2     1      pqr      17.42     78.55    2000  1000  1000    2
3     1      xyz      17.42     78.52    1000   500   500    3
4     1      mno      17.50     78.50    1000  1000     0    4
5     1      def      17.51     78.36    1000     0  1000    5
6     2      abc      17.41     78.58   10000  8000     0    1
7     2      pqr      17.42     78.55    5000  4000  1000    2
8     2      xyz      17.42     78.52    1000   500   500    3
9     2      mno      17.50     78.50   10000  1000  9000    4
10    2      def      17.51     78.36   10000     0  8000    5

Browser shows

Data: metro • Chart ID: Metro • googleVis-0.5.8 R version 3.1.2 (2014-10-31) • Google Terms of Use • Documentation and Data Policy

Questions

Is the issue with the way data frame is built? Can somebody help me understand and provide solution?

Flakes
  • 2,422
  • 8
  • 28
  • 32
  • can you provide your entire file? Also, try starting with a more basic version of the `gvisMotionChart` statement, like not adding parameters for height, width, etc. – Hack-R Jan 26 '15 at 08:38
  • Yeah! I found the issue. I think it would useful to note this bug in googlevis. I removed space between chartid="City Metro" to "CityMetro". It worked – Meenakshi Kumar Feb 02 '15 at 12:03
  • I found bug like that last Summer and got a credit in a documentation file. You might want to email the author and get yourself a credit in the `THANKS` file too! :) – Hack-R Feb 02 '15 at 16:04

0 Answers0