Code Monkey home page Code Monkey logo

Comments (3)

cegbuna avatar cegbuna commented on June 6, 2024

Hi, have you had a chance to take a look at this issue? Thanks!

from manipulatewidget.

bthieurmel avatar bthieurmel commented on June 6, 2024

Hi,

You can have the result you want using an observe :

server <- function(input, output, session) {
  
  data <- reactive({
    if(runif(1) > 0.5){
      data.frame(
        year = 2000+1:input$obs,
        series1 = rnorm(input$obs),
        series2 = rnorm(input$obs),
        series3 = rnorm(input$obs)
      )
    } else {
      data.frame(
        year = 2000+1:input$obs,
        series1 = rnorm(input$obs),
        series2 = rnorm(input$obs)
      )
    }
    
  })
  
  observe({
    ncharts = input$ncharts
    nrow = input$nrow
    ncol = input$ncol
    
    c <- manipulateWidget(
      {  
        dygraph(data[range[1]:range[2] - 2000, c("year", series)], main = title)
      },
      range = mwSlider(min = 2001, max = 2001 + (nrow(data)-1), c(2001, 2001 + (nrow(data)-1))),
      series = mwSelect(choices = colnames(data)[-1], value = colnames(data)[3]),
      title = mwSharedValue(),
      data = mwSharedValue(), .runApp = FALSE,
      .compare = "range",
      .compareOpts = compareOptions(ncharts = ncharts, nrow = nrow, ncol = ncol)
    )
    mwModule("ui", c, title = reactive(input$title), data = data)
  })
  
}

from manipulatewidget.

cegbuna avatar cegbuna commented on June 6, 2024

Thanks for the response @bthieurmel. Your solution worked. I have another question though. I have multiple graphs, some from different packages and would like the option to chose which goes to which panel. I tried adding them below the dygraph(data[range[1]:range[2] - 2000, c("year", series)], main = title) line but it didn't work. Could you please advice on an alternative solution. Thanks again for taking the time to respond.

from manipulatewidget.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.