Learn R Programming

googleVis (version 0.7.1)

gvisBubbleChart: Google Bubble Chart with R googleChartName <- "bubblechart" gvisChartName <- "gvisBubbleChart"

Description

The gvisBubbleChart function reads a data.frame and creates text output referring to the Google Visualisation API, which can be included into a web page, or as a stand-alone page.

Usage

gvisBubbleChart(
  data,
  idvar = "",
  xvar = "",
  yvar = "",
  colorvar = "",
  sizevar = "",
  options = list(),
  chartid
)

Value

paste(gvisChartName) returns list of class

paste(readLines(file.path(".", "inst", "mansections", "gvisOutputStructure.txt")))

Arguments

data

a data.frame to be displayed as a bubble chart. The data has to have at least three columns for idvar, xvar, and yvar.

idvar

column name of data with the bubble

xvar

column name of a numerical vector in data to be plotted on the x-axis.

yvar

column name of a numerical vector in data to be plotted on the y-axis.

colorvar

column name of data that identifies bubbles in the same series. Use the same value to identify all bubbles that belong to the same series; bubbles in the same series will be assigned the same color. Series can be configured using the series option.

sizevar

values in this column are mapped to actual pixel values using the sizeAxis option.

options

list of configuration options, see:

gsub("CHARTNAME", googleChartName, readLines(file.path(".", "inst", "mansections", "GoogleChartToolsURLConfigOptions.txt")))

paste(readLines(file.path(".", "inst", "mansections", "gvisOptions.txt")))

chartid

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

Author

Markus Gesmann markus.gesmann@gmail.com,

Diego de Castillo decastillo@gmail.com

Details

A bubble chart is used to visualize a data set with 2 to 4 dimensions. The first two dimensions are visualized as coordinates, the 3rd as color and the 4th as size.

The bubble chart is rendered within the browser using SVG or VML and displays tips when hovering over points.

References

Google Chart Tools API: gsub("CHARTNAME", googleChartName, readLines(file.path(".", "inst", "mansections", "GoogleChartToolsURL.txt")))

See Also

See also gvisMotionChart for a moving bubble chart over time, and print.gvis, plot.gvis for printing and plotting methods.

Examples

Run this code


bubble1 <- gvisBubbleChart(Fruits, idvar="Fruit", xvar="Sales", yvar="Expenses")
plot(bubble1)

## Set color and size
bubble2 <- gvisBubbleChart(Fruits, idvar="Fruit", xvar="Sales", yvar="Expenses",
                          colorvar="Location", sizevar="Profit",
                          options=list(hAxis='{minValue:75, maxValue:125}'))

plot(bubble2)

## Use year to color the bubbles
bubble3 <- gvisBubbleChart(Fruits, idvar="Fruit", xvar="Sales", yvar="Expenses",
                           colorvar="Year", sizevar="Profit",
                           options=list(hAxis='{minValue:75, maxValue:125}'))
plot(bubble3)

## Gradient colour example
bubble4 <- gvisBubbleChart(Fruits, idvar="Fruit", xvar="Sales", yvar="Expenses",
                          sizevar="Profit",
                          options=list(hAxis='{minValue:75,  maxValue:125}', 
                                  colorAxis="{colors: ['lightblue', 'blue']}"))
plot(bubble4)

if (FALSE) {
## Moving bubble chart over time, aka motion chart

M <- gvisMotionChart(Fruits, Fruit, Year)
plot(M)
}




Run the code above in your browser using DataLab