gvisCandlestickChart {googleVis} | R Documentation |
Google Candlestick chart with R
Description
An interactive candlestick chart.
Usage
gvisCandlestickChart(
data,
xvar = "",
low = "",
open = "",
close = "",
high = "",
options = list(),
chartid
)
Arguments
data |
a |
xvar |
name of the character column which contains the category labels for the x-axes. |
low |
name of the numeric column specifying the low/minimum value of this marker. This is the base of the candle's center line. |
open |
name of the numeric column specifying the opening/initial value
of this marker. This is one vertical border of the candle. If less than the
|
close |
name of the numeric column specifying the closing/final value
of this marker. This is the second vertical border of the candle. If less
than the |
high |
name of the numeric column specifying the high/maximum value of this marker. This is the top of the candle's center line. |
options |
list of configuration options, see: https://developers.google.com/chart/interactive/docs/gallery/candlestickchart#Configuration_Options The parameters can be set via a named list. The parameters have to map those of the Google documentation.
For more details see the Google API documentation and the R examples below. |
chartid |
character. If missing (default) a random chart id will be
generated based on chart type and |
Details
The gvisCandlestickChart 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. The actual chart is rendered by the web browser using SVG or VML.
A candlestick chart is used to show an opening and closing value overlaid on top of a total variance. Candlestick charts are often used to show stock value behavior. In this chart, items where the opening value is less than the closing value (a gain) are drawn as filled boxes, and items where the opening value is more than the closing value (a loss) are drawn as hollow boxes.
Value
gvisCandlestickChart 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
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,
Diego de Castillo decastillo@gmail.com
References
Google Chart Tools API: https://developers.google.com/chart/interactive/docs/gallery/candlestickchart
See Also
See also print.gvis
, plot.gvis
for
printing and plotting methods
Examples
## Please note that by default the googleVis plot command
## will open a browser window and requires an internet
## connection to display the visualisation.
## Example data set
OpenClose
C1 <- gvisCandlestickChart(OpenClose, xvar="Weekday", low="Low",
open="Open", close="Close",
high="High",
options=list(legend='none'))
plot(C1)