Giter VIP home page Giter VIP logo

Comments (7)

earowang avatar earowang commented on September 15, 2024

Can you write a small demo of {detourr} with Shiny?

from detourr.

casperhart avatar casperhart commented on September 15, 2024

I'll look in to it

from detourr.

casperhart avatar casperhart commented on September 15, 2024

Using detourr with Shiny will require a few changes:

  • the renderValue method will need to be modified to prevent duplicate elements from being drawn each time it's called
  • shiny bindings will need to be added. I'll need to find a way of doing this that's generic across widgets.
  • Using shiny gives some alignment issues between axes and axis labels

from detourr.

casperhart avatar casperhart commented on September 15, 2024

I've run in to a slight problem with Shiny, and I'm not sure the best way to work around it.

In order to get the widgets to work with both shiny and crosstalk, I need to write some shiny bindings. For example, for d3scatter, the following bindings are used, both of which get called from a shiny app:

d3scatterOutput <- function(outputId, width = '100%', height = '400px'){
  htmltools::attachDependencies(
    tagList(
      shinyWidgetOutput(outputId, 'd3scatter', width, height, package = 'd3scatter')
    ),
    crosstalk::crosstalkLibs()
  )
}

renderD3scatter <- function(expr, env = parent.frame(), quoted = FALSE) {
  if (!quoted) { expr <- substitute(expr) } # force quoted
  shinyRenderWidget(expr, d3scatterOutput, env, quoted = TRUE)
}

The problem I'm having is that the first function requires the widget name, but we don't know the widget name until we know the display method and dimension of the tour.

This can be inferred in the second function because we have expr, which is the call to animate_tour, and we can extract these values. But the first function only has the output_id which isn't enough to infer the widget name we are using.

@earowang Do you have any experience with writing shiny bindings, and can you suggest how to work around this issue? Ideally the widget name would remain hidden from the user.

The shiny example I'm going by is here: https://rstudio.github.io/crosstalk/shiny.html#:~:text=Adding%20reactive%20outputs

from detourr.

earowang avatar earowang commented on September 15, 2024

Looks like shinyWidgetOutput() requires one function corresponding to one widget. I don't have any examples in my mind that can help with this. Maybe decompose animate_tour() to two functions?

from detourr.

earowang avatar earowang commented on September 15, 2024

Any updates on this?

from detourr.

casperhart avatar casperhart commented on September 15, 2024

For shiny, I'll create wrapper functions that require passing in the widget name, e.g. display_scatter_3d. I intend to work on that this weekend

from detourr.

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.