Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
networkD3 en R - Freeze forceNetwork()

¿Hay alguna forma de congelar el diseño con forceNetwork() en la biblioteca {networkD3}?

Esto me está tomando mucho tiempo, debido a la cantidad de nodos que tiene mi red. Solo necesito detener la animación. Encontré algo aquí , pero no resolví mi problema.

Aquí está parte de mi código:

 p <- forceNetwork(Links = links, Nodes = nodes, Source = 'source', Target = 'target', NodeID = 'name', Group = 'group', Value = "value", Nodesize = "size", radiusCalculation = JS("d.nodesize"), zoom = TRUE, arrows = FALSE, linkWidth = JS("function(d){return d.value;}"), linkDistance = JS("function(d){return d.value*10}"), charge = gravity, opacity = 0.95, fontSize = 24, linkColour = "#424242" ) customJS <- "function() { d3.selectAll('.node text').style('fill', 'white').attr('stroke-width', '.1px').attr('stroke', '#3f3f3f'); d3.select('body').style('background-color', '#15171a'); d3.layout.force().tick(); d3.layout.force().stop(); }" g <- htmlwidgets::onRender(p, customJS) g
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede detener la simulación, avanzar a través de las marcas sin actualizar las posiciones (efectivamente, la "animación") y luego reiniciar la simulación para que las posiciones de los nodos se actualicen...

 library(networkD3) p <- forceNetwork( Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.4, zoom = TRUE ) customJS <- ' function() { simulation = this; simulation.stop(); for (var i = 0; i < 300; ++i) simulation.tick(); simulation.nodes().forEach( function(d,i) { d.cx = dx; d.cy = dy; }); simulation.restart(); } ' htmlwidgets::onRender(p, customJS)

También he estado trabajando en un sucesor de {networkD3} que puede hacer esto fácilmente (aunque por defecto usa lienzo en lugar de SVG, y por lo tanto puede manejar muchos más datos, incluso con la animación)...

 library(network.r2d3) url <- "https://gist.githubusercontent.com/mbostock/ad70335eeef6d167bc36fd3c04378048/raw/df541a01e850c6073ece4516fcd74ea1bae080ab/miserables.json" force_network(url, plot_static = TRUE)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!