Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update NVD3 support #708

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
12 changes: 8 additions & 4 deletions R/Nvd3.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ Nvd3 <- setRefClass('Nvd3', contains = 'rCharts', methods = list(
initialize = function(){
callSuper();
params <<- c(params, list(controls = list(),
chart = list(), xAxis = list(), x2Axis = list(), yAxis = list(),
chart = list(), pie = list(), xAxis = list(), x2Axis = list(), yAxis = list(),
filters = list()
))
},
chart = function(..., replace = F){
params$chart <<- setSpec(params$chart, ..., replace = replace)
},
pie = function(..., replace=F) {
params$pie <<- setSpec(params$pie, ..., replace = replace)
},
addFilters = function(...){
.self$setTemplate(
page = 'rChartControls2.html',
Expand Down Expand Up @@ -46,17 +49,18 @@ Nvd3 <- setRefClass('Nvd3', contains = 'rCharts', methods = list(
getPayload = function(chartId){
data = toJSONArray2(params$data, digits = getOption('rcharts.digits', 13))
chart = toChain(params$chart, 'chart')
pie = toChain(params$pie, 'chart.pie')
xAxis = toChain(params$xAxis, 'chart.xAxis')
x2Axis = toChain(params$x2Axis, 'chart.x2Axis')
yAxis = toChain(params$yAxis, 'chart.yAxis')
controls_json = toJSON(params$controls)
filters_json = toJSON(params$filters)
controls = setNames(params$controls, NULL)
opts = toJSON(params[!(names(params) %in% c('data', 'chart', 'xAxis', 'x2Axis', 'yAxis', 'controls', 'filters'))])
opts = toJSON(params[!(names(params) %in% c('data', 'chart', 'pie', 'xAxis', 'x2Axis', 'yAxis', 'controls', 'filters'))])
list(opts = opts, xAxis = xAxis, x2Axis = x2Axis, yAxis = yAxis, data = data,
chart = chart, chartId = chartId, controls = controls,
chart = chart, pie=pie, chartId = chartId, controls = controls,
controls_json = controls_json, CODE = srccode,
filters_json = filters_json, hasFilter = (length(params$filters) > 0)
)
}
))
))
13 changes: 10 additions & 3 deletions R/showOutput.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
#' @params lib name of js library used
#' @params package name where js library resides
#' @export


chartOutput <- showOutput <- function(outputId, lib = NULL, package = 'rCharts',
add_lib = TRUE){
add_lib = TRUE, width = "100%", height = "400px"){
if (!is.null(lib)){
LIB <- get_lib(lib, package = package)
} else if (exists(".rChart_object")) {
Expand All @@ -17,10 +19,15 @@ chartOutput <- showOutput <- function(outputId, lib = NULL, package = 'rCharts',
if (add_lib){
suppressMessages(singleton(addResourcePath(LIB$name, LIB$url)))
}
style <- {
paste("width:", validateCssUnit(width), ";", "height:",
validateCssUnit(height))
}
div(
id = outputId,
class=paste('shiny-html-output', 'rChart', basename(LIB$name)),
ifelse(add_lib, tagList(get_assets_shiny(LIB)), "")
ifelse(add_lib, tagList(get_assets_shiny(LIB)), ""),
style=style
)
}

Expand All @@ -43,4 +50,4 @@ get_assets_shiny <- function(LIB){
filter_jquery <- function(js){
jquery = c('jquery.js', 'jquery.min.js', 'jquery-1.8.2.min.js', 'jquery-1.9.1.min.js')
!(basename(js) %in% jquery)
}
}
2 changes: 1 addition & 1 deletion inst/libraries/nvd3/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
nvd3:
css: [css/nv.d3.css, css/rNVD3.css]
jshead: [js/jquery-1.8.2.min.js, js/d3.v3.min.js, "js/nv.d3.min-new.js", js/fisheye.js]
jshead: [js/jquery-1.8.2.min.js, js/d3.v3.min.js, "js/nv.d3.min.js", js/fisheye.js]
cdn:
css: "//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.css"
jshead:
Expand Down
12 changes: 7 additions & 5 deletions inst/libraries/nvd3/js/nv.d3.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions inst/libraries/nvd3/layouts/chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@


{{{ chart }}}

{{{ pie }}}

{{{ xAxis }}}

Expand Down