cytoscape / cyjShiny

An R/shiny widget for cytoscape.js
Other
92 stars 28 forks source link

htmlwidgets work in shinyApp, not yet in RStudio #22

Open cannin opened 4 years ago

cannin commented 4 years ago

Reference to this issue: https://github.com/ramnathv/htmlwidgets/issues/321

One part in the debugging is clicking the open icon marked with the red box:

Screen Shot 2019-09-06 at 6 12 32 PM

after running this:

library(cyjShiny)

tbl.nodes <- data.frame(id=c("A", "B", "C"),
                        type=c("kinase", "TF", "glycoprotein"),
                        lfc=c(-3, 1, 1),
                        count=c(0, 0, 0),
                        stringsAsFactors=FALSE)

tbl.edges <- data.frame(source=c("A", "B", "C"),
                        target=c("B", "C", "A"),
                        interaction=c("phosphorylates", "synthetic lethal", "unknown"),
                        stringsAsFactors=FALSE)

graph.json <- dataFramesToJSON(tbl.edges, tbl.nodes)
cyjShiny(graph=graph.json, layoutName="cola", style_file=system.file("examples/tinyApp/basicStyle.js", package="cyjShiny"))

In the browser window, you'll have access to the browser Javascript developer tools. The first problem you'll encounter is:

bundle.js:94044 Uncaught ReferenceError: $ is not defined
    at Object.<anonymous> (bundle.js:94044)
    at __webpack_require__ (bundle.js:20)
    at bundle.js:66
    at bundle.js:69

This should be simple to fix by not using $ and instead import as jQuery:

jQuery = require('jquery'); // Instead of $ = require('jquery');

Then things will get complicated. I think I tracked the problem to cytoscape, but with no idea how to fix:

Screen Shot 2019-09-06 at 6 25 24 PM

ctr might be a jQuery object here, I'm not sure what it should be normally. The error is related to ctr.className being undefined and indexOf() not existing.

paul-shannon commented 3 years ago

@cannin Is this still a problem? Dharna and I do not run into at present.