My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
SettingOptions  

Featured
Updated Feb 3, 2012 by markus.g...@googlemail.com

Setting Options

Setting the various options of a googleVis objects can be a bit cumbersome at first. The options follow those of the Google Visualisation API and can be set via a named list using the argument options. In the following example we create a line chart and set various options.

library(googleVis)
df <- data.frame(country=c("US", "GB", "BR"), val1=c(10,13,14), val2=c(23,12,32))
Line <-  gvisLineChart(df, xvar="country", yvar=c("val1","val2"),
                        options=list(
                          title="Hello World",
                          titleTextStyle="{color:'red', 
                                           fontName:'Courier', 
                                           fontSize:16}",                         
                          backgroundColor="#D3D3D3",                          
                          vAxis="{gridlines:{color:'red', count:3}}",
                          hAxis="{title:'Country', titleTextStyle:{color:'blue'}}",
		          series="[{color:'green', targetAxisIndex: 0},	
                                   {color: 'orange',targetAxisIndex:1}]",
                          vAxes="[{title:'val1'}, {title:'val2'}]",
                          legend="bottom",
                          curveType="function",
                          width=500,
                          height=300                         
                          ))
plot(Line)

As you can see some from the example above, the simpler options can be set by name=value, e.g. width=500, while the more complex options with sub-components are listed in curly brackets { }, and arrays, e.g. to define the two axes, use square brackets [ ].

Chart Editor (googleVis >= 0.2.9)

A special option for all charts is gvis.editor, which puts a button onto the page allowing the user to edit, change and customise the chart in a browser window, see the following example. The content of the list item gvis.editor describes the label of the browser button.

Editor <- gvisLineChart(df, options=list(gvis.editor="Editor"))
plot(Editor)

Comment by kashanip...@gmail.com, Sep 4, 2012

it blows minds!

Comment by drra...@gmail.com, Apr 29, 2013

Is it possible to specify column width for tables? (gvisTable)

Comment by project member markus.g...@googlemail.com, Apr 29, 2013

No, unfortunately you can't specify the column with in tables.

Comment by drra...@gmail.com, Apr 30, 2013

Thanks for the response and thanks for the amazing/powerful package.

Is there a workaround available for specifying column width?

Comment by amber.m....@gmail.com, May 14, 2015

Is the gvis.editor deprecated for Shiny ? I am attempting to use it for my application but it is conflicting with other drop down features and the graph is extremely large for the page. Is there any way to fix or customize this feature?

Powered by Google Project Hosting