Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

node_adjacency

Node Adjacency


Description

Focus or unfocus on node adjacency.

Usage

e_focus_adjacency_p(proxy, index, ...)

e_unfocus_adjacency_p(proxy, ...)

Arguments

proxy

An echarts4r proxy as returned by echarts4rProxy.

index

One or more node index to focus on.

...

Any other options, see official documentation and details.

Details

Must pass seriesId, seriesIndex, or seriesName, generally seriesIndex = 0 will work.

Examples

value <- rnorm(10, 10, 2)

nodes <- data.frame(
  name = sample(LETTERS, 10),
  value = value,
  size = value,
  grp = rep(c("grp1", "grp2"), 5),
  stringsAsFactors = FALSE
)

edges <- data.frame(
  source = sample(nodes$name, 20, replace = TRUE),
  target = sample(nodes$name, 20, replace = TRUE),
  stringsAsFactors = FALSE
)
## Not run: 

library(shiny)

ui <- fluidPage(
  fluidRow(
    column(
      2,
      numericInput("index", "Node", value = 3, min = 1, max = 9)
    ),
    column(
      2,
      br(),
      actionButton("focus", "Focus")
    ),
    column(
      2,
      br(),
      actionButton("unfocus", "Unfocus")
    )
  ),
  fluidRow(
    column(12, echarts4rOutput("graph"))
  )
)

server <- function(input, output, session) {
  output$graph <- renderEcharts4r({
    e_charts() %>%
      e_graph() %>%
      e_graph_nodes(nodes, name, value, size, grp) %>%
      e_graph_edges(edges, source, target)
  })

  observeEvent(input$focus, {
    echarts4rProxy("graph") %>%
      e_focus_adjacency_p(
        seriesIndex = 0,
        index = input$index
      )
  })

  observeEvent(input$unfocus, {
    echarts4rProxy("graph") %>%
      e_unfocus_adjacency_p(seriesIndex = 0)
  })
}

if (interactive()) {
  shinyApp(ui, server)
}

## End(Not run)

echarts4r

Create Interactive Graphs with 'Echarts JavaScript' Version 5

v0.4.0
Apache License (>= 2.0)
Authors
John Coene [aut, cre, cph], Wei Su [ctb], Helgasoft [ctb], Xianying Tan [ctb] (<https://orcid.org/0000-0002-6072-3521>)
Initial release
2021-03-05

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.