I moved the inclusion of the theme url outside of renderChart2
, directly into ui.R
. The reason for this is that afterScript
is only included in the static template for charts. The shiny version only outputs the chart related HTML and currently does not include the contents of afterScript
. You could consider this a bug in the implementation of rCharts and I hope to fix it in future versions.
Last active
August 29, 2015 14:02
-
-
Save ramnathv/6f83ea255eccc5a03349 to your computer and use it in GitHub Desktop.
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(shiny) | |
require(rCharts) | |
shinyServer(function(input, output) { | |
output$plot <- renderChart2({ | |
data(mtcars) | |
p <- hPlot(mpg ~ hp, data = mtcars, type = 'scatter', group = input$g_variable) | |
p$set(width = "100%", height= "100%") | |
return(p) | |
}) | |
}) |
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(shiny) | |
require(rCharts) | |
theme <- 'gray.js' | |
theme_url <- sprintf('http://rawgithub.com/highslide-software/highcharts.com/master/js/themes/%s', theme) | |
shinyUI(fluidPage( | |
tags$head( | |
tags$link(rel = "stylesheet", type = "text/css", href = "http://bootswatch.com/superhero/bootstrap.min.css") | |
), | |
titlePanel("Migrations Analysis"), | |
sidebarLayout( | |
sidebarPanel( | |
radioButtons( | |
inputId = "g_variable", | |
label = "Group by", | |
choices = list( "Cyl" = "cyl", | |
"VS" = "vs", | |
"AM" = "am", | |
"Gear" = "gear"), | |
selected = "area" | |
) | |
), | |
mainPanel( | |
chartOutput("plot", "highcharts"), | |
tags$script(src=theme_url, type='text/javascript') | |
) | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment