Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. data(citytemp, package = "highcharter")
  2. function(input, output) {
  3. hcbase <- reactive({
  4. # hcbase <- function() highchart()
  5. hc <- highchart()
  6.  
  7.  
  8. if (input$credits)
  9. hc <- hc %>% hc_credits(enabled = TRUE, text = "Highcharter", href = "http://jkunst.com/highcharter/")
  10.  
  11. if (input$exporting)
  12. hc <- hc %>% hc_exporting(enabled = TRUE)
  13.  
  14. if (input$theme != FALSE) {
  15. theme <- switch(input$theme,
  16. null = hc_theme_null(),
  17. economist = hc_theme_economist(),
  18. dotabuff = hc_theme_db(),
  19. darkunica = hc_theme_darkunica(),
  20. gridlight = hc_theme_gridlight(),
  21. sandsignika = hc_theme_sandsignika(),
  22. fivethirtyeight = hc_theme_538(),
  23. chalk = hc_theme_chalk(),
  24. handdrwran = hc_theme_handdrawn()
  25. )
  26.  
  27. hc <- hc %>% hc_add_theme(theme)
  28. }
  29.  
  30. hc
  31.  
  32. })
  33.  
  34.  
  35. output$table <-renderDataTable({
  36. #Output from graph
  37. data.table(month=citytemp$month,berlin=citytemp$berlin
  38. ,berlin_dragged=citytemp$berlin)#Here I want to use the dragged data. something linke input$highchart$... should do the trick I guess...
  39. })
  40.  
  41. output$highchart <- renderHighchart({
  42.  
  43. data(citytemp)
  44. highchart() %>%
  45. hc_chart(animation = FALSE) %>%
  46. hc_title(text = "draggable points demo") %>%
  47. hc_xAxis(categories = month.abb) %>%
  48. hc_plotOptions(
  49. series = list(
  50.  
  51. stickyTracking = FALSE
  52. ),
  53. column = list(
  54. stacking = "normal"
  55. ),
  56. line = list(
  57. cursor = "ns-resize"
  58. )
  59. ) %>%
  60.  
  61. hc_add_series(
  62. data = citytemp$berlin,
  63. draggableY = TRUE
  64. )
  65.  
  66. })
  67.  
  68.  
  69.  
  70. }
  71. ui.r
  72.  
  73. library("shiny")
  74. library("shinydashboard")
  75. library("highcharter")
  76. library("dplyr")
  77. library("viridisLite")
  78. library("markdown")
  79. library("quantmod")
  80. library("tidyr")
  81. library("ggplot2")
  82. library("treemap")
  83. library("forecast")
  84. library("DT")
  85. rm(list = ls())
  86.  
  87. dashboardPage(
  88. skin = "black",
  89. dashboardHeader(title = "highcharter", disable = FALSE),
  90. dashboardSidebar(
  91. sidebarMenu(
  92. menuItem("Examples", tabName = "examples", icon = icon("bar-chart"))
  93. )
  94. #,
  95. #div(includeMarkdown("hcterinfo.md"), style = "padding:10px")
  96. ),
  97. dashboardBody(
  98. # tags$head(tags$script(src = "js/ga.js")),
  99. # tags$head(tags$link(rel = "stylesheet", type = "text/css", href = "css/custom_fixs.css")),
  100. tabItems(
  101. tabItem(tabName = "examples",
  102. fluidRow(
  103.  
  104. box(width = 6, highchartOutput("highchart")),
  105. box(width = 6, dataTableOutput("table"))
  106.  
  107. )
  108. )
  109. )
  110. ))
  111.  
  112. hc_plotOptions(
  113. series = list(
  114. point = list(
  115. events = list(
  116. drop = JS("function(){
  117. console.log(this.series)
  118. window.data = _.map(this.series.data, function(e) { return e.y })
  119. Shiny.onInputChange('inputname', data);
  120. }"))
  121. )))
  122.  
  123. renderDataTable({
  124. ...
  125. var <- input$inputname # listening the drop event
  126. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement