Skip to content

Instantly share code, notes, and snippets.

@rbdixon
Created August 28, 2014 19:01
Show Gist options
  • Save rbdixon/67a252fcfd74b28e4f51 to your computer and use it in GitHub Desktop.
Save rbdixon/67a252fcfd74b28e4f51 to your computer and use it in GitHub Desktop.
Attempt to get rCharts Highcharts to fill container
require(rCharts)
sample=data.frame(
k = c("a", "b", "c"),
v = c(1,2,3)
)
renderChartFit <- function(expr, env = parent.frame(), quoted = FALSE) {
func <- shiny::exprToFunction(expr, env, quoted)
function() {
rChart_ <- func()
cht_style <- sprintf("<style>.rChart {width: %spx; height: %spx} </style>",
rChart_$params$width, rChart_$params$height)
cht <- paste(capture.output(rChart_$print()), collapse = '\n')
# HTML(paste(c(cht_style, cht), collapse = '\n'))
HTML(cht)
}
}
shinyServer(function(input, output) {
output$chart1 = renderChartFit(hPlot(v ~ k, data=sample, type="column"))
output$chart2 = renderChartFit(hPlot(v ~ k, data=sample, type="line"))
})
require(rCharts)
shinyUI(
fluidPage(
# includeScript("ui.js"),
fluidRow(
column(2, "Sidebar"),
column(10,
fluidRow(id="mainContent",
column(6, showOutput("chart1", lib="Highcharts")),
column(6, showOutput("chart2", lib="Highcharts"))
)
)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment