chartseries: Interactive 'chart_Series'

Description Usage Examples

Description

Convert quantmod::chart_Series to interactive d3fc htmlwidget chart.

Usage

1
chartseries(cs = NULL, width = NULL, height = NULL, elementId = NULL)

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
39
40
41
## Not run: 
# translate quantmod::chart_Series to d3fc
library(quantmod)
library(d3r)
library(rd3fc)

sp500 <- getSymbols("^GSPC", auto.assign=FALSE)
sp500w <- to.weekly(sp500)

cs <- chart_Series(sp500w)

# live interactive version
#  might not show up in RStudio
chartseries(cs)

# examine the chart_Series environment to replicate each
#  of the pieces
#listviewer::jsonedit(
#  jsonlite::toJSON(as.list(cs$Env), force=TRUE, auto_unbox=TRUE)
#)

# data
cs$Env$xdata

# x axis
# bottom ticks
index(cs$Env$xdata[cs$Env$axt,])
# bottom major ticks
index(cs$Env$xdata[cs$Env$atbt,])
# top ticks and ?location?
cs$Env$axis_ticks(cs$Env$xdata)
# limits
index(cs$Env$xdata[cs$Env$xlim,])

# y axis
# ticks
cs$Env$alabels
# limits
cs$Env$ylim[[2]]

## End(Not run)

timelyportfolio/rd3fc documentation built on May 31, 2019, 2:13 p.m.