Git Product home page Git Product logo

googlevis's Introduction

googleVis

R-CMD-check

CRAN_Status_Badge downloads

The googleVis package provides an interface between R and the Google's charts tools. It allows users to create web pages with interactive charts based on R data frames. Charts are displayed locally via the R HTTP help server. A modern browser with Internet connection is required. The data remains local and is not uploaded to Google.

Check out the examples from the googleVis demo.

Please read Google's Terms of Use before you start using the package.

Installation

You can install the stable version from CRAN:

install.packages('googleVis')

Usage

library(googleVis)
?googleVis
demo(googleVis)

See the googleVis package vignette for more details. For a brief introduction read the five page R Journal article.

License

This package is free and open source software, licensed under GPL 2 or later.

Creative Commons Licence
googleVis documentation by Markus Gesmann & Diego de Castillo is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

googlevis's People

Contributors

bbrewington avatar dureyingenieria avatar hack-r avatar jcheng5 avatar mages avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

googlevis's Issues

Running ;texi2dvi; on 'googleVis.tex' failed

I have used 'mages/googleVis' earlier on my MAC with RStudio. Recently I have update to new R release and it removed all my old packages. When I try to re-install, I am getting the following error.

Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'googleVis.tex' failed.
Calls: -> texi2pdf -> texi2dvi
Execution halted
Error: Command failed (1)

sizevar does not work in gvisMotionChart()

Trying to set sizevar does not work with gvisMotionChart(). Looking at the code, it is not included in 'my.options', which is probably the reason for it not working. Now I need to manually adjust the variables to that I get the desired variable assigned to size by default, but it's not very convenient, so could you please fix this!

gvisPieChart legend

Dear Markus,
In the current release, legend = 'none' is ignored by the function and the plot would include legend even with legend = 'none'.
data("CityPopularity")

pie <- gvisPieChart(CityPopularity,
options=list(
width=200,
height=200,
title='test',
legend='none',
colors="['orange', 'transparent']",
pieSliceText='percentage',
pieHole=0.5))
plot(pie)

`could not find function "is"` in batch mode

The package works fine for me interactively, but in batch mode this happens:

Rscript minimal_ggvis_example.R 

Welcome to googleVis version 0.5.9

Please read the Google API Terms of Use
before you start using the package:
https://developers.google.com/terms/

Note, the plot method of googleVis will by default use
the standard browser to display its output.

See the googleVis package vignettes for more details,
or visit http://github.com/mages/googleVis.

To suppress this message use:
suppressPackageStartupMessages(library(googleVis))

Error in FUN(X[[1L]], ...) : could not find function "is"
Calls: gvisLineChart ... gvisChart -> gvis -> gvisFormat -> toJSONarray -> lapply -> FUN
Execution halted

The example script that this came from is:

library(googleVis)
df=data.frame(country=c("US", "GB", "BR"), 
              val1=c(10,13,14), 
              val2=c(23,12,32))
Line <- gvisLineChart(df)
plot(Line)

It's googleVis version 0.5.9 (installed via install_github("mages/googleVis")), but the same thing happened with version 0.5.9 installed via CRAN.

Here's my other system info:

> R.Version()
$platform
[1] "x86_64-apple-darwin13.1.0"

$arch
[1] "x86_64"

$os
[1] "darwin13.1.0"

$system
[1] "x86_64, darwin13.1.0"

...

$`svn rev`
[1] "66115"

$language
[1] "R"

$version.string
[1] "R version 3.1.1 (2014-07-10)"

$nickname
[1] "Sock it to Me"

Also reproduced in this environment:

$platform
[1] "x86_64-pc-linux-gnu"

$arch
[1] "x86_64"

$os
[1] "linux-gnu"

$system
[1] "x86_64, linux-gnu"

...

$`svn rev`
[1] "68180"

$language
[1] "R"

$version.string
[1] "R version 3.2.0 (2015-04-16)"

$nickname
[1] "Full of Ingredients"

width and height with gvisAnnotatedTimeLine

Hi Markus,

maybe I am wrong (because of something specific with my env: R 3.1.1, googleVis 0.5.5) but gvisAnnotatedTimeLine example from https://code.google.com/p/google-motion-charts-with-r/wiki/GadgetExamples is not working properly when: width and height is used .

plot(gvisAnnotatedTimeLine(Stock, datevar="Date",
numvar="Value", idvar="Device",
titlevar="Title", annotationvar="Annotation",
options=list(displayAnnotations=TRUE,
legendPosition='newRow',
width=400, height=250)
))

gvisMotionChart example is working properly...

Best Regards
Robert

Custom tooltip in gvisTimeline

Can you help troubleshoot....

My goal is to add a custom tooltip to the gvisTimeline function.

I've modified your script to add tooltip as a parameter. However, when I run the modified function, I get the following error message "could not find function "gvisChart". I reloaded googleVis, but I get the same error message.

This is also an unsolved post on StackOverflow, so I'm reaching out to the expert!

Thanks in advance for any guidance.

gvisTimeline <- function(data, rowlabel="", barlabel="", tooltip="", start="",
end="", options=list(), chartid){

    my.type <- "Timeline"
    dataName <- deparse(substitute(data))

    my.options <- list(gvis=modifyList(list(width=600, height=200),options), dataName=dataName,
                       data=list(rowlabel=rowlabel, barlabel=barlabel,** tooltip=tooltip**, start=start, end=end,
                                 allowed=c("number", "string", "date", "datetime"))
    )


    checked.data <- gvisCheckTimelineData(data, rl=rowlabel, bl=barlabel, **tt=tooltip**,
                                          start=start, end=end)

    output <- gvisChart(type=my.type, checked.data=checked.data, options=my.options,
                        chartid=chartid, package="timeline") 

    return(output)

}

gvisCheckTimelineData <- function(data, rl, bl, tt, start, end){

    if(any(c(rl, bl, **tt**, start, end) %in% ""))
            return(data)
    else  
            return(data[, c(rl, bl, **tt,** start, end)])

}

require(timeline)
require(googleVis)
data(ww2)
ww2$Person <- gsub("\n" ," ", ww2$Person)
ww2$tooltip <- rep("Hello World",nrow(ww2))
plot(gvisTimeline(ww2, barlabel="Person", rowlabel="Group", tooltip = "tooltip",
start="StartDate", end="EndDate",
options=list(tooltip="{isHtml:'True'}"), chartid="ww2")
)

Shiny example doesn't generate graph

Using the example straight from your cran documentation, the following code generates a shiny dropdown but no graph.

I am able to plot the gvisScatterChart when i pass it variables not through shiny.

Seems to be something wrong with the renderGvis function?

server.R

library(googleVis)
shinyServer(function(input, output) {
datasetInput <- reactive({
switch(input$dataset,
"rock" = rock,
"pressure" = pressure,
"cars" = cars)
})
output$view <- renderGvis({
gvisScatterChart(datasetInput(),
options=list(title=paste(Data:,input$dataset)))
})
})

ui.R

shinyUI(pageWithSidebar(
headerPanel("googleVis on Shiny"),
sidebarPanel(
selectInput("dataset", "Choose a dataset:",
choices = c("rock", "pressure", "cars"))
),
mainPanel(
htmlOutput("view")
)
))

How to map categorical variables in gvisGeoMap/gvisGeoChart

I am attempting to create a map in which each US state is colored according to a character type categorical variable. I am able to get the map to render, but all of the tooltips show a numeric value instead of the character string in my variable. Here's a reproducible example:

library(googleVis)
library(datasets)


category <- c("A","B","C","D","E",
           "A","B","C","D","E",
           "A","B","C","D","E",
           "A","B","C","D","E",
           "A","B","C","D","E",
           "A","B","C","D","E",
           "A","B","C","D","E",
           "A","B","C","D","E",
           "A","B","C","D","E",
           "A","B","C","D","E")

hover <- c(1:50)

data <- data.frame(state.name,category,hover)

Map <- gvisGeoMap(data, "state.name", "category", "hover",
                    options=list(region="US", 
                                 displayMode="regions", 
                                 resolution="provinces",
                                 width=600, height=400))
plot(Map)

The map assigns colors correctly for "category," but the tooltip shows category as a number, rather than a letter A - E. Ultimately, I would like to be able to assign discrete colors to each category, rather than using a gradient, but I'll take one step at a time with my questions. Any help is much appreciated.

Region Maps : India

The India border (Jammu & Kashmir) is not coming correctly. Is there any way to fix it?

geoChartIndia <- gvisGeoChart(countryData, locationvar="Country", colorvar="Count", options=list(region = "IN", projection="kavrayskiy-vii", dataMode='markers', colorAxis="{colors:['#AEC7E8', '#1F77B4']}", backgroundColor="#fff", width="100%", displayMode="regions", resolution="provinces"))

The above is the code I'm using to display it.

gvisAnnotationChart strips characters from legend

I have a dataframe called 'df' that looks like this when dumped using write.table():
"x" "key" "y"
"1" 2014-06-02 02:14:00 "aby01" 217.95
"2" 2014-06-02 00:43:00 "aby01" 222.783333333333
"3" 2014-06-02 00:48:00 "aby01" 226.716666666667
"4" 2014-06-02 02:13:00 "aby01" 216.266666666667
"5" 2014-06-02 02:04:00 "aby01" 235.9
"6" 2014-06-02 01:22:00 "aby01" 227.1

When I try to plot it with the following code:

plot <- gvisAnnotationChart(df, numvar="y", idvar = "key", datevar = "x", titlevar = "key",
options=list(legendPosition='newRow', height=440, width=900))

it plots correctly, however the legend appears incorrectly as "ab1" instead of "aby01" i.e. the letter y and the following character are stripped from the legend (although the annotation title appears correctly). Please see the attached screenshot.

plot

After some investigation I worked out that if I change the third column name from "y" to "z" then the problem with the name aby01 disappears, but names including a z are then affected in a similar way!

I also wrote some html to plot the same data directly using google charts and I didn't see the problem there so I am concluding that this is an issue with the R package when transforming the data frame. I didn't see any restriction in the documentation regarding what column names can be used...

I think this issue also affects gvisAnnotatedTimeLine()

renderGvis not working with renderUI and plotOutput ( while creating multiple google charts )

I am creating an app in which multiple charts will dynamically build using R Shiny on base of CSV folder, selected using shinyFiles. I am facing problem with combination of renderGvis, renderUI and plotOutput.

CASE 1:

renderUI creates 5 divs using plotOutput. When trying to create charts with renderGvis, it DIDN'T CREATE charts and gives error in browser's console "TypeError: invalid 'in' operand a"

CASE 2:

renderUI creates 5 divs using htmlOutput. When trying to create charts with renderGvis, it CREATE charts but as soon as I click to choose a new folder it gives following error in browser's console "uncaught exception: Duplicate binding for ID plot1". Here problem is, it re-try to create 5 div which are already exists with same ids.

Here is code.

UR.r

 library(shiny)
 library(shinyFiles)
 shinyUI(fluidPage(

 tags$head(
 tags$style(HTML("
            .shiny-output-error-validation {
            color: red;
            }
            .shiny-output-error-missing-folder {
            color: red;
            }
            "))
    ),
   titlePanel("Example"),
  sidebarPanel(
  shinyDirButton('directory', 'Folder select', 'Please select a folder'),
  tags$p(),
  tags$p('Select a folder.'),
  tags$hr()
 ),
mainPanel(
    tags$h3('Overall Insights'),
    textOutput('allStats'),
    tags$h3('Columns Charts'),
    uiOutput('columnCharts')
 )
 ))

Server.r

 library(shiny)
 library(shinyFiles)
 library(googleVis)

 shinyServer(function(input, output, session) {
 volumes <- getVolumes()
 shinyDirChoose(input, 
         'directory', 
         roots=volumes, 
         session=session, 
         restrictions=system.file(package='base'))

  dataFrame <- reactive({

validate (
   need(input$directory != "", "<< Please select any folder"),
   errorClass = "missing-folder"
) 
  text <- "dummy output"
 })

output$allStats <- renderText({

 dummyVar <- dataFrame()

 output$columnCharts <- renderUI({

  plot_output_list <- lapply(1:5, function(i) {
    plotname <- paste0("plot", i)
    htmlOutput(plotname)
 })

 do.call(tagList, plot_output_list)
 })

 for (i in 1:5) {
 local({

  my_i <- i
  plotname <- paste0("plot", my_i)

  output[[plotname]] <- renderGvis({

  data <- cars
  # plot(data)
  if(nrow(data)!= 0){

    chart <- gvisBarChart(
      data,
      options = list(
        gvis.editor = "Edit",
        legend = "none",
        backgroundColor = "transparent"
      )
    )
    return(chart)
  }
  })
})
 }
 txt <- "Google Charts"
    })

  })

Tooltip's HTML code showing on hover over a marker in gvisMap

When you hover over a marker in gvisMap, the tool-tip's HTML code (including the tags) is displayed, which can be confusing to users. The user has to click on the marker to see the formatted tool-tip.
Is there a way to at least suppress the hover-over event? Or, ideally, display formatted tool-tip on hover?

Change between 0.5.2 and 0.5.3 makes gvisColumnChart render differently

In version 0.5.2 the following:

mz <- c(204.090426224,204.42,205.093450946652,205.333333333333,205,206.09617548735,206)
Intensity <- c(100,0,12.8287163823763,0,0,1.06475087409598,0)

plot_data = data.frame(mz,Intensity)

xlim=c(min(plot_data[,1])-0.2,max(plot_data[,1])+0.2)

  p=gvisColumnChart(plot_data,options=list(titleTextStyle="{color:'black'}",
                                     bar="{groupWidth:'1'}",legend= "{ position: 'none' }",hAxis=paste0("{minValue:",xlim[1],",maxValue:",xlim[2],"}"),chartArea="{'width': '100%', 'height': '80%'}")
  )

plot(p)

Gave a plot similar to:

   plot(plot_data,xlab="m/z",ylab="Relative abundance",type="h",xlim=xlim,lwd=2  ,cex.lab=1.5     )
   abline(h=0)

With version 0.5.3 and 0.5.4 it now instead gives a nonsense plot with all bars of equal height. Did something change in the syntax or is this a bug?

Group colors in gvisTimeline

Hello,

I am using gvisTimeline in Shiny, and I need to color code the timeline bars according to groups. This is different from the colorByRowLabel option because I am trying to use the same colors for groups of rows, not by each row label.
I know we can just use the options for colors, but I am not able to utilize this because the data set I am using to generate the plot is a reactive object. Is there any way we could add a functionality where you can just use a 'colors' column so that each timeline bar uses the corresponding color for the row, or use 'group' colors in the option?

For example, if I wanted to color code by 'Level', in the dataset below,
it would be great if I could do something like:

gvisTimeline(data=dat, rowlabel="Class", barlabel="Day", start="Start", end="End", colors = "Level" ) or
gvisTimeline(data=dat, rowlabel="Class", barlabel="Day", start="Start", end="End", colors = "Color" )

screen shot 2016-11-09 at 6 44 14 pm

Thanks for your help!

DL

Date Labels stripped off when use width = automatic (and browser windows is wide)

This may be an issue more with underlying google chart object, but I wanted to bring this to your attention.

I noticed my dates fall off the axis when I use a large browser window. I am trying to get my shiny app to work for tablets and desktop so I dont set the width in pixels but use automatic.

When browser window is small:
20150714-googlevisdates-ok

When browser is wide - dates go missing:
20150714-googlevisdates-notok

Any clues on what to do to fix this?
Thanks we really appreciate your work.

Calendar chart: Cannot call method 'getFullYear' of null

Markus Thanks very much for including these new charts

I am looking to use the calendar chart in one or more of my shinyApps.
The scraped data has a daily count for this year to date and I get the above error
However, it does not appear consistent - or related to need for a full year of data, which would be major drawback - as when the scraped data only returned this month's info the calendar was drawn correctly

Sankey Out of Frame

Hi, I'm relatively new to R and GoogleVis. I've recently discovered the gvissankey function however whenever I pull a chart the bottom half is always cut off/out of frame (See attached). Do you know how I can resolve this issue? also as the totals of each side of my sankey diagram are the same is it possible to make the start and finish level in height? finally how do you amend the node colours? Thanks, this is a fantastic package by the way!!!

SankeyID23e46ff57f27.pdf

How to set the 'generateTooltip' option for TreeMap charts?

Hi,

The 'generateTooltip' option expects a Javascript function. Doing the following doesn't work because the argument is considered as a string, not a function object when the chart is loaded (I include a javascript file with the definition of the function).

options <- list(showScale = T, generateTooltip = "showStaticTooltip")

Any idea how to solve this problem?

Thanks,

Guillaume

Uncaught Error: Container is not defined

Hi,
Sometimes when using googleVis library in shiny I have this error.

I think reason is that

for chart is in code after chart initialization.

Can we change order ?

Weekly and monthly data trails plotting incorrectly

When attempting to produce weekly and monthly charts, the trails feature plots daily. This causes browser crashes and slow downs when working over years of data. This doesn't seem to be the case with yearly data, only for anything less than a year.

Mersin (aka Icel) Province of Turkey

Hi there,

I want to thank all the contributors of this package. I love it, used it and will be using it. However I had a small issue for Turkey's map. When I did try the following R code, Mersin province was not colored. I did try "Icel" instead of "Mersin" but again the region is not colored. Could you please help me to figure out how I could get all provinces of Turkey are successfully colored (marked)?

Thanks!

city<-data.frame(City=c("Istanbul","Ankara","Antalya","Izmir","adana","bursa","sivas","Mersin","eskisehir","kocaeli","trabzon","ordu","sinop","Izmit"), Quantity= c(1000,500,600,400,300,200,200,170,130,120,120,100,100,80))

Plot(gvisGeoChart(city,locationvar="City",colorvar="Quantity",options=list(region="TR", resolution="provinces",height=400,width=650)))

gvisAnnotationChart height & width options now need units

The help for gvisAnnotationChart says:

parameters with names that don't include a "." and are set with a single value, e.g. width and height. Those are set like one would do in R, that is options=list(width=200, height=300). Boolean arguments are set to either TRUE or FALSE, using the R syntax.

This worked for me last month (2014-09-16) using googleVis 0.5.2 with R 3.1.1, but it doesn't work today (2014-10-21) using googleVis 0.5.6 with R 3.1.1

In order to control the width and height, I need to provide the units (px). For example:

data(Stock)

# Plot fills page width (100%)
A1 <- gvisAnnotationChart(Stock, datevar="Date",
                           numvar="Value", idvar="Device",
                           titlevar="Title", annotationvar="Annotation",
                           options=list(displayAnnotations=TRUE,
                            legendPosition='newRow',
                            width=600, height=350)
                           )
plot(A1)

# Plot height and width are fixed
A1px <- gvisAnnotationChart(Stock, datevar="Date",
                           numvar="Value", idvar="Device",
                           titlevar="Title", annotationvar="Annotation",
                           options=list(displayAnnotations=TRUE,
                            legendPosition='newRow',
                            width="600px", height="350px")
                           )
plot(A1px)

I've tried a few of the other functions (gvisBarChart, gvisAreaChart), but I've only seen this behavior with gvisAnnotationChart. On the other hand, gvisBarChart and gvisAreaChart work just fine with options = list(width = "750px", height = "500px"), so perhaps it makes sense to update isnt/mansections/gvisOptions.txt

googleVis RMarkdown

When I use the following code, I am getting the error

library(googleVis)
op = options(gvis.plot.tag='chart')
M = gvisMotionChart(Fruits, "Fruit", "Year",
                     options=list(width=600, height=400))
M

pandoc: Could not fetch https://www.google.com/jsapi?callback=displayChartMotionChartIDacc71caca3e7
TlsException (HandshakeFailed (Error_Protocol ("certificate has unknown CA",True,UnknownCa)))
Error: pandoc document conversion failed with error 67
Execution halted

Minor Error in Example

Great package and documentation. I was just working with gvisTable and noticed that the demo/Vignette

http://cran.r-project.org/web/packages/googleVis/vignettes/googleVis_examples.html

has lots of impossible values for “% of World Population”. Just wanted to let you know; I think this fixes it:

Population$"% of World Population" <- Population$"% of World Population" * .01

Though a more useful fix that I'm not sure how to do would probably be to adjust the value of the formatting parameter rather than the source data.

I emailed a heads up about this to Markus Gesmann. Cheers.

offline access to motion chart

Markus, is there any workaround to get a motion chart to show up in the absence of an Internet connection? Can the files for display be saved locally, which could then be used to show the chart?

Multiple input columns for "hovervar" in gvisGeoChart?

Hi,

I noticed that in the documentation for GeoCharts, they show an example where they use 2 columns of data for the hovervar. On the other hand, the documentation for gvisGeoChart seems to imply that only one column of data can be passed to the hovervar argument. Is this the case? If so, will you be implementing multiple columns? It seems like a reasonably easy thing to do, looking at the var data = block in the documentation link above...

thanks!

Plots not appearing in Rstudio viewer

Hi,

I am using Linux Mint, R-Studio Version 0.98.1103 , R-Version 3.1.3 and googleVis 0.5.8. Plotting nonflash visualisations like tables never uses my Viewerpanel in R-Studio but instead the default browser.

Example Code:

data(mtcars)
gvt = gvisTable(mtcars)
plot(gvt)

Any idea why this is not working? I did not change any default options.

using googleVis with FlexDashboard?

Hi Markus, how can we use GoogleVis with the new package FlexDashboard? FlexDashboard is like the intersection between a basic .Rd and shinyDashboards.

To visualize the plot (let's say I have called the output of a googlevis chart as d), I have tried:
d
plot(d)
renderGvis(d)

also have tried setting op <- options(gvis.plot.tag='chart')

I can get the html to show up in the output, but nothing I try renders the block. Somebody asked in the github of flexdashboard... but I'm not sure it's a problem on their end... http://www.github.com/rstudio/flexdashboard/issues/26

There must be a simple solution,, no? hopefully I'm just messing something up?

Add support for treemap objects

d3tree has awesome support for treemap objects, so you can have the data quickly in the right format for visualization. Maybe it's interesting to add it here. I can try to do so

Applying ColorFormat to Gvistable

Hi,
I am trying to apply the colorformat to my gvistable and I am so far unsuccessful at it. Any suggestion on how to do it?
I am trying to choose a back ground colour and font colour depending on some input condition. Like it is shown in the google example below.

var data = new google.visualization.DataTable();
data.addColumn('string', 'Department');
data.addColumn('number', 'Revenues');
data.addRows([
  ['Shoes', 10700],
  ['Sports', -15400],
  ['Toys', 12500],
  ['Electronics', -2100],
  ['Food', 22600],
  ['Art', 1100]
]);

var table = new google.visualization.Table(document.getElementById('colorformat_div'));

var formatter = new google.visualization.ColorFormat();
formatter.addRange(-20000, 0, 'white', 'orange');
formatter.addRange(20000, null, 'red', '#33ff33');
formatter.format(data, 1); // Apply formatter to second column

table.draw(data, {allowHtml: true, showRowNumber: true, width: '100%', height: '100%'});

I am not able to figure out how to adapt the same logic in R

any help?!

Bundle Annotations like Google Finance

Hello,

Thank you for maintaining this invaluable project! I have a request -- Google Finance seems to use the same AnnotatedTimeLine function as googleVis, but their charts bundle multiple annotations for the same data point such that they are unintrusive:
screen shot 2016-10-19 at 5 23 54 pm

and expand when clicked on:
screen shot 2016-10-19 at 5 25 24 pm

Can this functionality be added to googleVis?

Thank you!
Steven

Org Chart under shiny 0.11.1 and shinydashboard

Hi,

I use googleVis_0.4.7 (in other Org Chart) to publish the taxonomy of risk solvency2 (about it thank you for the latest version of ChainLadder). One of the feature is to display the correlation matrix if you click on a block of risk diversification (Diversification Market Risk, No Risk Life, ...)

Using shiny 0.11.1 under shinybootstrap2 this is not a problem, but
I migrated my application to shinydashboard_0.2.3 and I can not see the matrix despite the capture of diversification selected block (see the alert function).

Below is the functions used (recovering the block name in shiny input with $ selected)

Do you have a solution to this problem ?

A big thank you for your help.

Alain

output$S2Taxo <- renderGvis({

jscode <- "var sel = chart.getSelection();
var c = sel[0].row;
var text = data.getValue(c, 0);               
alert(text);
$('input#selected').val(text);
$('input#selected').trigger('change');"   

if (input$Taxo==FALSE){

SII_Taxo_S<-dplyr::filter(dbTaxoDyn(), Origin=='SCR')
gvisOrgChart(SII_Taxo_S, idvar = "KeyRisk", parentvar = "KeyParentLevel2", tipvar="Value",  options=list(gvis.listener.jscode=jscode,width=300, height=600,allowHtml=TRUE, size='large', allowCollapse=TRUE))
}
else if (input$Taxo==TRUE){
gvisOrgChart(dbTaxoDyn(), idvar = "KeyRisk", parentvar = "KeyParent", tipvar="Value",  options=list(gvis.listener.jscode=jscode,width=300, height=600,allowHtml=TRUE, size='large', allowCollapse=TRUE))
}

})


dataTaxo<-reactive({
# Search Risk Nr 1
vvv<-readTaxoMulti(input$selected)
#cat(vvv$FieldName)
return(vvv)

})

observe({
if (is.null(input$selected))
return()
isolate({

  v<-readTaxoMulti(input$selected)  

  pub<-paste(v$FieldName," :  ",v$FieldValue)

})  

})

#Correlation Matrix  #
######################

CorrelMatrix<-reactive ({
# Error message 
validate(
  need(dataTaxo()$FieldName != "", "Please click on a Diversification block to see the correlation matrix")
)

SII_COR_SEL<-SII_COR[SII_COR[,"Matrix"]=="NoCorr",]
if(dataTaxo()$FieldName=="DiversificationBSCR")
{SII_COR_SEL<-SII_COR[SII_COR[,"Matrix"]=="Agg_matrix_BSCR",]}
else if (dataTaxo()$FieldName=="DiversificationNONLIFE")
{SII_COR_SEL<-SII_COR[SII_COR[,"Matrix"]=="Agg_matrix_nonlife",]}
else if (dataTaxo()$FieldName=="Diversification LIFE")
{SII_COR_SEL<-SII_COR[SII_COR[,"Matrix"]=="Agg_matrix_Life",]}
else if (dataTaxo()$FieldName=="DiversificationMARKET")
{SII_COR_SEL<-SII_COR[SII_COR[,"Matrix"]=="Agg_matrix_market_down",]}
else if (dataTaxo()$FieldName=="Diversification HEALTH")
{SII_COR_SEL<-SII_COR[SII_COR[,"Matrix"]=="Agg_matrix_health",]}
else if (is.na(dataTaxo()$FieldName)) 
{SII_COR_SEL<-SII_COR[SII_COR[,"Matrix"]=="NoCorr",]}


dimMat <- dim(SII_COR_SEL)[1]^0.5
aaa <- melt(SII_COR_SEL)
bbb <- as.data.frame(cast(aaa, Item1 ~ Item2))
cat(bbb)
return(bbb)
})

output$correlaM <- renderTable({

CorrelMatrix()
})

sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Dutch_Belgium.1252 LC_CTYPE=Dutch_Belgium.1252
[3] LC_MONETARY=Dutch_Belgium.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Belgium.1252

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

other attached packages:
[1] shinydashboard_0.2.3 geoR_1.7-4
[3] sp_1.0-9 fOptions_3010.83
[5] fBasics_3010.86 MASS_7.3-35
[7] timeSeries_3010.97 timeDate_3010.98
[9] quantmod_0.4-0 TTR_0.22-0
[11] Defaults_1.1-1 tseries_0.10-32
[13] xts_0.9-7 ggplot2_0.9.3.1
[15] PerformanceAnalytics_1.1.0 dygraphs_0.3.3
[17] shinyBS_0.25 shinysky_0.1.2
[19] lattice_0.20-29 scales_0.2.4
[21] RColorBrewer_1.0-5 leaflet_1.0
[23] hwriter_1.3 data.table_1.8.8
[25] rHighcharts_1.0 RJSONIO_1.0-3
[27] actuar_1.1-6 shiny_0.11.1
[29] ChainLadder_0.2.0 statmod_1.4.17
[31] systemfit_1.1-14 lmtest_0.9-31
[33] zoo_1.7-11 car_2.0-21
[35] Matrix_1.1-4 stringr_0.6.2
[37] googleVis_0.4.7 dplyr_0.4.0
[39] reshape_0.8.4 plyr_1.8.1
[41] RODBC_1.3-6 JavaGD_0.6-1
[43] codetools_0.2-9

loaded via a namespace (and not attached):
[1] assertthat_0.1 cluster_1.15.3 colorspace_1.2-4
[4] DBI_0.3.1 digest_0.6.4 grid_3.1.2
[7] gtable_0.1.2 Hmisc_3.12-2 htmltools_0.2.6
[10] htmlwidgets_0.3.2 httpuv_1.3.2 lme4_0.999999-2
[13] magrittr_1.5 mime_0.2 munsell_0.4.2
[16] nlme_3.1-118 nnet_7.3-8 parallel_3.1.2
[19] proto_0.3-10 quadprog_1.5-5 R6_2.0
[22] RandomFields_2.0.66 Rcpp_0.11.3 reshape2_1.4
[25] rpart_4.1-8 sandwich_2.2-10 SparseM_1.05
[28] splancs_2.01-32 stabledist_0.6-6 stats4_3.1.2
[31] tools_3.1.2 tweedie_2.1.7 xtable_1.7-4
[34] yaml_2.1.13

Background not changing for gvisTimeline

Hi,

I was trying to use the gvisTimeline function but was not able to get the background colour to change despite specifying the parameter as described in the example code in the documentation. It seems like backgroundColor is reaching the javascript end as an array (eg ['#000']) while it expects a string (eg '#000'). My reason for saying this is removing the square brackets in the corresponding html portion in tl$html$chart renders it perfectly. I'm not sure if I'm doing something wrong or if this is a known issue, just thought I would bring it up just in case it's helpful.

dat <- data.frame(Position=c(rep("President", 3), rep("Vice", 3)),
                  Name=c("Washington", "Adams", "Jefferson",
                         "Adams", "Jefferson", "Burr"),
                  start=as.Date(x=rep(c("1789-03-29", "1797-02-03", "1801-02-03"),2)),
                  end=as.Date(x=rep(c("1797-02-03", "1801-02-03", "1809-02-03"),2)))

tl <- gvisTimeline(data=dat, rowlabel="Name",barlabel="Position", 
                   start="start", end="end",
                   options=list(timeline="{groupByRowLabel:false}",
                                backgroundColor='#ffd', height=350,
                                colors="['#cbb69d', '#603913', '#c69c6e']"))

plot(tl)

google.visualization.ColorFormat

I'm attempting to use gvisTable to create heatmapped tables. However, I don't see support for any of the generic formatters. Am I missing this feature?

Thank you,
Eric

gvisMotionChart why not allow xvar and yvar to be categorical?

Dear all,
gvisMotionChart is a great tool to visualise the data in R. However, why don't you make it work with categorical xvar and yvar as well? Of course, a hack is to convert them to 0, 1, 2, etc. But changing the x & y ticks is maddening hard (at least for a Java noob like me). It would be great if you can add in the feature. Thanks

chart using ordered factors not shown, as the javascript is produced incorrectly

When using ordered factor, a chart is not displayed, as the underlying javascript is not correct.

Using "factor" is ok and produces in the HTML/javascript two entries "data.addColumn" as expected.

HTML excerpt ok:
data.addColumn('string','foo');
data.addColumn('number','bar');
data.addRows(datajson);

require(googleVis)
df.ok <- data.frame(foo = factor(c("a", "c", "b")), bar = c(1, 6, 4))
plot(gvisColumnChart(df.ok))

But using "ordered" is not ok. The "data.addColumn" for the ordered factor is missing from the generated HTML/javascript. As result, the chart does not display.

HTML excerpt not ok:
data.addColumn('number','bar');
data.addRows(datajson);

df.nok <- data.frame(foo = ordered(c("a", "c", "b")), bar = c(1, 6, 4))
plot(gvisColumnChart(df.nok))

Expectation is that a chart on data using ordered works the same as with factor.

No graph output when using googleVIS in Jupyter

Using this works in R console:

plot(G)

but when typed into a cell in jupyter I get:

starting httpd help server ... done
and no graph. So here is what I did. Into Anaconda 2.7.11, I installed R essentials

conda install -c r r-essentials
started up jupyter

notebook jupyter
installed needed reqs, XML and googleVIS, by typing this into a cell

options(repos=structure(c(CRAN="https://cloud.r-project.org/")))
install.packages('googleVis')
install.packages('XML')

typed this code into a cell

suppressPackageStartupMessages(library(googleVis))
library(googleVis)
library(XML)
url <- "http://en.wikipedia.org/wiki/List_of_countries_by_credit_rating"
x <- readHTMLTable(readLines(url), which=3)
levels(x$Rating) <- substring(levels(x$Rating), 4, 
                            nchar(levels(x$Rating)))
x$Ranking <- x$Rating
levels(x$Ranking) <- nlevels(x$Rating):1
x$Ranking <- as.character(x$Ranking)
x$Rating <- paste(x$Country, x$Rating, sep=": ")
G <- gvisGeoChart(x, "Country", "Ranking", hovervar="Rating",
                options=list(gvis.editor="S&P",
                             projection="kavrayskiy-vii",
                             colorAxis="{colors:['#91BFDB', '#FC8D59']}"))

then

plot(G)

This code works fine when typed directly into an R console and makes a nice map. But something is causing jupyter to choke on starting a server. I guess since jupyter itself is web page running in a server there is some sort of problem with a web page starting a server?

Is the API still working?

I was trying to answer this StackOverflow question for someone who couldn't get a plot and I realized that if I run the examples in the documentation none of them work for me either anymore.


## Please note that by default the googleVis plot command
## will open a browser window and requires Internet
## connection to display the visualisation.

## Regions Example
## The regions style fills entire regions (typically countries) with colors
## corresponding to the values that you assign. Specify the regions style
## by assigning options['dataMode'] = 'regions' in your code.

G1 <- gvisGeoMap(Exports, locationvar='Country', numvar='Profit',
                 options=list(dataMode="regions")) 

plot(G1)

## Markers Example
## The "markers" style displays a circle, sized and colored to indicate
## a value, over the regions that you specify. 
G2 <- gvisGeoMap(CityPopularity, locationvar='City', numvar='Popularity',
                 options=list(region='US', height=350, 
                              dataMode='markers',
                              colors='[0xFF8747, 0xFFB581, 0xc06000]'))  

plot(G2) 

## Example showing US data by state 

require(datasets)
states <- data.frame(state.name, state.x77)

G3 <- gvisGeoMap(states, "state.name", "Illiteracy",
                 options=list(region="US", dataMode="regions",
                              width=600, height=400))
plot(G3) 

## Example with latitude and longitude information
## Show Hurricane Andrew (1992) storm track
G4 <- gvisGeoMap(Andrew, locationvar="LatLong", numvar="Speed_kt", 
                 hovervar="Category", 
                 options=list(height=350, region="US", dataMode="markers"))

plot(G4) 

## World population
WorldPopulation=data.frame(Country=Population$Country, 
                           Population.in.millions=round(Population$Population/1e6,0),
                           Rank=paste(Population$Country, "Rank:", Population$Rank))

G5 <- gvisGeoMap(WorldPopulation, "Country", "Population.in.millions", "Rank", 
                 options=list(dataMode="regions", width=600, height=300))
plot(G5)

gvisMap failing to load map in shinyapp on AWS

Hi, I have a shiny app which is using googleVis package in R. I am using gvisMap to plot some latlong. The app runs fine on my local machine without any issues but he same app loads the MAP for some seconds and than dis-appears citing a java script error: Google Maps API error: MissingKeyMapError.

I have gone through the googleVis documentation and there is no way to provide an API key. Can someone help me. Here is the code in R that is generating the the map output.

output$chart1 <- renderGvis({
if(input$state=="All"){
gvisMap(cplex_user_state, "latlong" , "num_users",
options=list(showTip=TRUE,
showLine=TRUE,
enableScrollWheel=TRUE,
mapType='terrain',
useMapTypeControl=TRUE,width=600,height=400))
} else {
gvisMap(filter(cplex_user_state,state==input$state), "latlong" , "num_users",
options=list(showTip=TRUE,
showLine=TRUE,
enableScrollWheel=TRUE,
mapType='terrain',
useMapTypeControl=TRUE,width=600,height=400))
}
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.