gvisMerge: Merge two googleVis charts into one gvis-object

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/gvisMethods.R

Description

gvisMerge merges two gvis-objects, either next or below each other into one gvis-object. The objects are arranged in a HTML table.

Usage

1
2
gvisMerge(x, y, horizontal = FALSE,
                tableOptions = "border=\"0\"", chartid)

Arguments

x

a gvis-object.

y

a gvis-object.

horizontal

boolean. Default FALSE. If FALSE the two gvis-objects are arranged below each other, otherwise next to each other.

tableOptions

a valid HTML table option string. Default "border=\"0\"".

chartid

character. If missing (default) a random chart id will be generated based on chart type and tempfile

Value

gvisMerge returns list of class "gvis" and "list".

An object of class "gvis" is a list containing at least the following components:

type

Google visualisation type, here 'gvisMerge'

chartid

character id of the chart object. Unique chart ids are required to place several charts on the same page.

html

a list with the building blocks for a page

header

a character string of a html page header: <html>...<body>,

chart

a named character vector of the chart's building blocks:

jsHeader

Opening <script> tag and reference to Google's JavaScript library.

jsData

JavaScript function defining the input data as a JSON object.

jsDrawChart

JavaScript function combing the data with the visualisation API and user options.

jsDisplayChart

JavaScript function calling the handler to display the chart.

jsFooter

End tag </script>.

jsChart

Call of the jsDisplayChart function.

divChart

<div> container to embed the chart into the page.

caption

character string of a standard caption, including data name and chart id.

footer

character string of a html page footer: </body>...</html>, including the used R and googleVis version and link to Google's Terms of Use.

Author(s)

Markus Gesmann markus.gesmann@gmail.com,

References

Google Chart Tools API: http://code.google.com/apis/chart/index.html

Follow the link for Google's data policy.

See Also

See also print.gvis, plot.gvis for printing and plotting methods

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## Please note that by default the googleVis plot command
## will open a browser window and requires Internet
## connection to display the visualisation.


G <- gvisGeoChart(Exports, "Country", "Profit", 
                  options=list(width=250, height=100))
T <- gvisTable(Exports, 
                  options=list(width=250, height=300))

GT <- gvisMerge(G,T, horizontal=FALSE) 
plot(GT)

M <- gvisMotionChart(Fruits, "Fruit", "Year",
                     options=list(width=400, height=410))

GTM <- gvisMerge(GT, M, horizontal=TRUE,
                     tableOptions="cellspacing=10")
plot(GTM)


line <- gvisLineChart(OpenClose, "Weekday", c("Open", "Close"), 
	      options=list(legend='none', width=300, height=150))
column <- gvisColumnChart(OpenClose, "Weekday", c("Open", "Close"),
              options=list(legend='none', width=300, height=150))
area <- gvisAreaChart(OpenClose, "Weekday", c("Open", "Close"),
              options=list(legend='none', width=300, height=150))
bar <- gvisBarChart(OpenClose, "Weekday", c("Open", "Close"),
              options=list(legend='none', width=300, height=150))
LBCA <- gvisMerge(gvisMerge(line, bar), gvisMerge(column, area),
                  horizontal=TRUE, tableOptions="bgcolor=\"#AABBCC\"") 

plot(LBCA)

## Applying gvisMerge successively

p <- Reduce(gvisMerge, list(line, column, area, bar))
plot(p)

kleanthisk10/google-motion-charts-with-r documentation built on May 20, 2019, 12:32 p.m.