networkD3 icon indicating copy to clipboard operation
networkD3 copied to clipboard

location.href in url(...)

Open MikeBadescu opened this issue 7 years ago • 3 comments

Arrows do not work in WebKit (iPad, Safari) due to treatment of url(...) in WebKit. For this issue (and possible fixes), please see https://stackoverflow.com/a/29984481

I made one small change (added location.href) and now it seems to behave as expected.

Here is the sample Shiny app I used for testing. I have deployed it at https://numeract.shinyapps.io/test/ (it includes the suggested change).

require(shiny)
require(networkD3)

shiny::shinyApp(
    ui = bootstrapPage(
        networkD3::forceNetworkOutput(outputId = 'plot3')
    ),
    server = function(input, output) {
        
        data(MisLinks)
        data(MisNodes)
        
        output$plot3 <- networkD3::renderForceNetwork({
            forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source",
                         Target = "target", Value = "value", NodeID = "name",
                             Group = "group", opacity = 1, arrows = TRUE)
            
        })
    }
)

MikeBadescu avatar Dec 04 '17 20:12 MikeBadescu

I'm not opposed to this change, but the arrows work for me locally on macOS/Safari and don't when I publish it to shinyapps.io. Out of curiosity, does this have to do something with being in an iframe or something like that once it's published to shinyapps.io?

cjyetman avatar Dec 04 '17 22:12 cjyetman

I am not JS expert, but based on the stackoverflow answer I expect it has something to do with the <base href=" ... "> declaration (see page source), which might be specific to shinyapps.io. I do not know yet if this is relevant to Shiny Server itself.

MikeBadescu avatar Dec 04 '17 22:12 MikeBadescu

that makes sense, thanks

cjyetman avatar Dec 04 '17 22:12 cjyetman