Code Monkey home page Code Monkey logo

Comments (3)

FrancoisGuillem avatar FrancoisGuillem commented on June 12, 2024

Hello,

Can you explain why do you want to do this? Using a manipulateWidget inside a shiny app is not documented for now, but you can find some examples here: https://github.com/rte-antares-rpackage/manipulateWidget/tree/master/inst/examples .

With manipulateWidget, you can add modules to a shiny application. The modules can use reactive values from the application but they are not intended to modify other elements of the application.

from manipulatewidget.

StevenMMortimer avatar StevenMMortimer commented on June 12, 2024

Thanks for the quick reply @FrancoisGuillem! Maybe I don't understand the aim of manipulateWidget well enough, but I thought it returned already rendered objects and let you modify them. The reason why I asked the question was that in a Shiny app you can create a leaflet map using leaflet() and you can further add to that using leafletProxy() which pushes changes to the rendered map. Unfortunately, you cannot get the map object back in order to save it. I've posed this as a question on StackOverflow after finding that many other R users are trying to figure out a solution to this problem because the typical ways of saving a leaflet map don't work with a proxy object. It needs to be an object of class leaflet, htmlwidget. I thought this package might return the actual object in some way.

Right now there are two workaround solutions to this problem:

  1. Build and render the map object, then keep a second object in a parallel with the same updates to the rendered map, then download the second object when needed.
  2. On click, grab all the rendered HTML from the map element and throw into an HTML file.

Neither solution seems to be ideal, so thought it would be worth posing the question more broadly, but this probably isn't the right place. I'll close this issue now.

from manipulatewidget.

FrancoisGuillem avatar FrancoisGuillem commented on June 12, 2024

I don't know if it can helps, but with manipulateWidget you can generate a leaflet map, update it and save it into an html file:

image

Here is the code to generate it:

myMapFun <- function(radius, color, initial, session, output) {
    if (initial) {
      # Widget has not been rendered
      map <- leaflet() %>% addTiles()
    } else {
      # widget has already been rendered
      map <- leafletProxy(output, session) %>% clearMarkers()
    }

    map %>% addCircleMarkers(lon, lat, radius = radius, color = color)
  }

  manipulateWidget(myMapFun(radius, color, .initial, .session, .output),
                   radius = mwSlider(5, 30, 10),
                   color = mwSelect(c("red", "blue", "green")))

This looks more or less like your first solution: when the user clicks the save button, a new htmlWidget object is created using the current values of the inputs.

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.