Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editing Google motion chart

Tags:

r

shiny

googlevis

I am using Google Motion Chart with Shiny R and I am not able to edit some of the basic things. I am new to Shiny R and already started loving it. Here is my code:

ui.R

 library(shiny)
    shinyUI((
    mainPanel( 
        h4("Interactive Analytics"),
        htmlOutput("view_gviz")
    )
 ))

shiny.R

 library(shiny)
 library(googleVis)     
 sample_data <- structure(list(YEAR = c(2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L), STORM = structure(c(3L, 9L, 16L, 25L, 36L, 40L, 46L, 58L, 64L, 70L, 75L, 86L, 91L, 97L, 100L, 8L, 10L, 22L, 29L, 32L, 39L, 52L, 53L, 67L, 72L, 80L, 84L, 5L, 13L, 20L, 24L, 35L, 38L, 51L, 56L, 66L, 73L, 77L, 81L, 92L, 95L, 99L, 106L), .Label = c("alberto", "alex", "allison", "alpha", "ana", "andrea", "arlene", "arthur", "barry", "bertha", "beryl", "beta", "bill", "bonnie", "bret", "chantal", "charley", "chris", "cindy", "claudette", "colin", "cristobal", "danielle", "danny", "dean", "debby", "delta", "dennis", "dolly", "don", "earl", "edouard", "emily", "epsilon", "erika", "erin", "ernesto", "fabian", "fay", "felix", "fiona", "florence", "frances", "franklin", "fred", "gabrielle", "gamma", "gaston", "gert", "gordon", "grace", "gustav", "hanna", "harvey", "helene", "henri", "hermine", "humberto", "ida", "igor", "ike", "ingrid", "irene", "iris", "isaac", "isabel", "isidore", "ivan", "jeanne", "jerry", "jose", "josephine", "juan", "julia", "karen", "karl", "kate", "katia", "katrina", "kyle", "larry", "laura", "lee", "lili", "lisa", "lorenzo", "marco", "maria", "matthew", "melissa", "michelle", "mindy", "nana", "nate", "nicholas", "nicole", "noel", "not named", "odette", "olga", "omar", "ophelia", "otto", "paloma", "paula", "peter", "philippe", "richard", "rina", "rita", "sean", "shary", "stan", "subtrop", "tammy", "tomas", "unnamed", "vince", "wilma", "zeta"), class = "factor"), MAX_PRESSURE = c(1012L, 1018L, 1012L, 1013L, 1015L, 1009L, 1010L, 1012L, 1011L, 1008L, 1009L, 1010L, 1006L, 1000L, 1006L, 1009L, 1013L, 1008L, 1009L, 1013L, 1009L, 1009L, 1014L, 1009L, 1016L, 1012L, 1009L, 1008L, 1009L, 1016L, 1024L, 1011L, 1009L, 1013L, 1013L, 1009L, 1009L, 1008L, 1009L, 1008L, 1014L, 1006L, 1009L), AVERAGE_PRESSURE = c(1006.05, 1006.37, 1006.78, 1005.37, 991, 991.32, 992.04, 993, 991.09, 1006.79, 992.15, 1008.5, 979.27, 991.25, 992.82, 1000.29, 1010.85, 1002.3, 1002.73, 1007.25, 1005.4, 983.81, 1003.86, 984.83, 1010.44, 1001.45, 992.67, 1001.64, 1006.14, 1002.25, 1014.29, 1001.7, 965.33, 1009.5, 1005.42, 955.5, 986.57, 984.46, 1002.58, 1006.5, 1004.62, 1000.4, 1002.13), MIN_PRESSURE = c(1000L, 990L, 997L, 994L, 968L, 962L, 975L, 970L, 948L, 1004L, 982L, 1007L, 934L, 986L, 973L, 992L, 1008L, 999L, 997L, 1002L, 998L, 960L, 1001L, 934L, 1004L, 980L, 940L, 994L, 997L, 982L, 1000L, 988L, 939L, 1007L, 997L, 915L, 969L, 952L, 993L, 1002L, 990L, 993L, 990L),     MAX_WIND_SPEED = c(60L, 70L, 70L, 70L, 120L, 115L, 80L, 105L,     145L, 50L, 80L, 40L, 140L, 75L, 90L, 60L, 40L, 50L, 60L,     65L, 60L, 100L, 60L, 125L, 60L, 85L, 145L, 60L, 60L, 85L,     75L, 75L, 145L, 40L, 60L, 165L, 105L, 125L, 65L, 45L, 70L,     65L, 70L), AVERAGE_WIND_SPEED = c(30.72, 36.45, 47.65, 44.48,     64.67, 62.6, 58.53, 69.23, 73.8, 42, 62.1, 36.87, 77.72,     62.5, 55.63, 47, 26, 43.07, 44.61, 37.25, 25.21, 56.48, 42,     61.03, 40.55, 48.46, 61.05, 43.12, 35.25, 54.88, 39.65, 52,     100.47, 30.41, 35.47, 115.43, 74.04, 73.1, 39.63, 37.85,     41.12, 50.9, 45), MIN_WIND_SPEED = c(15L, 10L, 30L, 30L,     15L, 30L, 30L, 30L, 30L, 30L, 35L, 35L, 35L, 50L, 30L, 35L,     15L, 35L, 25L, 25L, 0L, 25L, 25L, 25L, 35L, 30L, 30L, 0L,     25L, 30L, 25L, 30L, 30L, 15L, 30L, 30L, 30L, 35L, 15L, 30L,     25L, 35L, 35L), MAX_STORM_MOVEMENT_SPEED = c(31L, 13L, 37L,     37L, 36L, 23L, 37L, 32L, 21L, 23L, 48L, 32L, 35L, 23L, 20L,     39L, 11L, 23L, 23L, 12L, 17L, 46L, 14L, 57L, 36L, 24L, 28L,     34L, 24L, 31L, 21L, 26L, 48L, 25L, 18L, 47L, 44L, 56L, 10L,     14L, 23L, 36L, 24L), AVERAGE_STORM_MOVEMENT_SPEED = c(7.85,     6.86, 19.12, 17.82, 13.93, 11.22, 14.8, 13.16, 18.14, 18.88,     14, 13.59, 8.87, 11.18, 8.43, 21.89, 5.36, 5.58, 12.83, 4.89,     4.54, 18.61, 7.85, 11.94, 16.37, 6.97, 12.33, 14.64, 13.05,     14.59, 10.13, 18.55, 17.07, 11.81, 6.7, 12.19, 12.19, 17.61,     3.75, 9.38, 9.24, 17.14, 13.14), MIN_STORM_MOVEMENT_SPEED = c(1L,     2L, 3L, 0L, 3L, 1L, 2L, 8L, 13L, 10L, 5L, 4L, 1L, 1L, 1L,     5L, 2L, 3L, 0L, 0L, 2L, 8L, 3L, 2L, 5L, 1L, 3L, 4L, 3L, 2L,     3L, 13L, 6L, 6L, 2L, 5L, 2L, 5L, 0L, 5L, 1L, 4L, 3L), STORM_LENGTH = c(14L,     6L, 8L, 7L, 16L, 12L, 10L, 6L, 5L, 2L, 4L, 4L, 8L, 2L, 11L,     5L, 5L, 3L, 6L, 5L, 6L, 7L, 3L, 13L, 2L, 22L, 13L, 9L, 5L,     10L, 11L, 3L, 13L, 3L, 5L, 14L, 5L, 15L, 10L, 4L, 19L, 5L,     4L)), .Names = c("YEAR", "STORM", "MAX_PRESSURE", "AVERAGE_PRESSURE", "MIN_PRESSURE", "MAX_WIND_SPEED", "AVERAGE_WIND_SPEED", "MIN_WIND_SPEED", "MAX_STORM_MOVEMENT_SPEED", "AVERAGE_STORM_MOVEMENT_SPEED", "MIN_STORM_MOVEMENT_SPEED", "STORM_LENGTH"), row.names = c(NA, 43L), class = "data.frame")     
 shinyServer(function(input, output) {
        output$view_gviz <- renderGvis({
                                chart <- gvisMotionChart(sample_data,
                                        idvar="STORM", 
                                        timevar="YEAR",
                                        xvar="AVERAGE_WIND_SPEED", 
                                        yvar="AVERAGE_PRESSURE",
                                        colorvar="MAX_STORM_MOVEMENT_SPEED", 
                                        sizevar="STORM_LENGTH",
                                        options=list(width=1080, height=500, showChartButtons = FALSE)
                                        )
        })
 })

Now, here are the list of things that I am not able to do:

  1. I do want to put/edit the tooltips. I have seen one example in Gapminder site. I want to add tooltip over indicators on X-axis, Y-axis, colors and size.
  2. Remove the play button along with playback speed button. It does not sound good idea, but I do want to drag through the slider and no animation over time. It would make sense with full data.
  3. Zoom-in doesn't work with mouse click. We must press enter with keyboard to zoom. Do we have any workaround to fix this?
like image 611
Sabin Avatar asked Sep 11 '25 00:09

Sabin


1 Answers

Unfortunately, I don't think item 1 and 2 are supported by the Google API. Regarding 3, I think this depends on the Flash player you use. Chrome's build in Flash player has caused me issues in the past, while Adobe's Flash player seems to allow the zooming function.

The Google Chart API Forum might be the best place to ask such questions, as they are not directly related to R or shiny.

like image 187
Markus Avatar answered Sep 12 '25 14:09

Markus