Git Product home page Git Product logo

Comments (3)

timelyportfolio avatar timelyportfolio commented on July 24, 2024

If I understand correctly, I think you will just need to add the cola.js dependency to the ui/fluidPage. Will you let me know if something like the below works?

ui <- tagList(
  shinyUI(fluidPage(
    useShinyjs(),
    titlePanel(
      "Network Browser"
    ),
    mainPanel(
      d3Output("d3")
    ),
    htmlDependency(
      name = "cola",
      version = "3.1.3",
      src = c(file = system.file("htmlwidgets/lib/WebCola", package="colaR"),
      script = "cola.min.js"
    )
))

Also, colaR has not been updated to d3v4 even though cola (js) has been, so you will need d3_version=3 in r2d3. I am happy to update if you have interest.

from r2d3.

 avatar commented on July 24, 2024

Hi

Slight typo? in your suggestion:

from r2d3.

 avatar commented on July 24, 2024

Hi

Slight change to your suggestion but the same error persists: Error: cola is not defined in forcegraph.js#11:14
ReferenceError: cola is not defined

library("r2d3")
library("jsonlite")
library("colaR")
library("htmltools")
library("shiny")
library(shinyjs)

ui <- tagList(
shinyUI(fluidPage(
useShinyjs(),
titlePanel(
"Network Browser"
),
mainPanel(
d3Output("d3")
),
htmlDependency(
name = "cola",
version = "3.1.3",
src = c(file = system.file("/home/shiny/webapps/d3_test/colaR/inst/htmlwidgets/lib/WebCola")),
package="colaR",
script = "cola.min.js"
)
)))

Define server logic required to process and plot data

server <- shinyServer(function(input, output,session) {

output$d3 <- renderD3({
r2d3(data = jsonlite::read_json("miserables.json"), d3_version = 3, script = "forcegraph.js")
})

})

Run the application

shinyApp(ui = ui, server = server)

The forcegraph.js i am using is as attached which is based on https://bl.ocks.org/mbostock/4063570

forcegraph.txt

Thank you!

from r2d3.

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.