tush1r / google-motion-charts-with-r

Automatically exported from code.google.com/p/google-motion-charts-with-r
0 stars 0 forks source link

Cannot set state in motion chart (googleVis_0.3.3 and RJSONIO_1.0-1) #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Generate a motion chart setting its initial state according to the 
documentation:

suppressPackageStartupMessages(library(googleVis))
data(Fruits)

state.json <- 
'{"nonSelectedAlpha":0.4,"time":"2008","showTrails":true,"iconKeySettings":[],"u
niColorForNonSelected":false,"xAxisOption":"_TIME","yZoomedDataMax":32,"playDura
tion":15000,"xZoomedDataMin":1199145600000,"colorOption":"2","orderedByY":false,
"yLambda":1,"sizeOption":"5","xLambda":1,"xZoomedIn":false,"duration":{"timeUnit
":"Y","multiplier":1},"yZoomedIn":false,"iconType":"BUBBLE","dimensions":{"iconD
imensions":["dim0"]},"yAxisOption":"5","yZoomedDataMin":7,"xZoomedDataMax":12623
04000000,"orderedByX":false}'

M <- gvisMotionChart(Fruits, idvar="Fruit", timevar="Year", 
options=list(state=state.json))
plot(M)

What is the expected output? What do you see instead?

Plot generated with Profit shown on the y axis and Time on the x axis. Instead, 
the plot is displayed with the default initial state (Expenses and Sales).

What version of the product are you using? On what operating system?

Mac OS 10.8.2.

> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

locale:
[1] en_US.utf-8/en_US.utf-8/en_US.utf-8/C/en_US.utf-8/en_US.utf-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] googleVis_0.3.3 RJSONIO_1.0-1  

loaded via a namespace (and not attached):
[1] tools_2.15.1

Please provide any additional information below.

This issue is similar to 
http://code.google.com/p/google-motion-charts-with-r/issues/detail?id=5

Original issue reported on code.google.com by ltrab...@gmail.com on 12 Nov 2012 at 10:04

GoogleCodeExporter commented 9 years ago
Thanks for your message. 
This is not so much a bug in the code as a lag of documentation.
The state string needs a newline at the start and at the end to work. 
Either you enter hard returns in your string or you use '\n'. 

Here is a minimal example which should work for you

myStateSettings <-'\n{"iconType":"LINE"}\n'
M <- gvisMotionChart(Fruits, "Fruit", "Year", 
options=list(state=myStateSettings))
plot(M)

I have updated the help file of gvisMotionChart for the state argument and 
added the 
above code to the example section to highlight the need for the newlines.

You can review the changes here:
http://code.google.com/p/google-motion-charts-with-r/source/diff?spec=svn346&r=3
46&format=side&path=/trunk/man/gvisMotionChart.Rd&old_path=/trunk/man/gvisMotion
Chart.Rd&old=339

I hope this helps.

Markus

Original comment by markus.g...@googlemail.com on 12 Nov 2012 at 7:50

GoogleCodeExporter commented 9 years ago
Perfect, thanks a lot for the quick response! I'm loving the package, congrats!

Original comment by ltrab...@gmail.com on 13 Nov 2012 at 7:33