Created
August 28, 2014 19:01
-
-
Save rbdixon/67a252fcfd74b28e4f51 to your computer and use it in GitHub Desktop.
Attempt to get rCharts Highcharts to fill container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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