JohnCoene / echarts4r

🐳 ECharts 5 for R
http://echarts4r.john-coene.com/
Other
587 stars 82 forks source link

Need help in: How to label only some nodes in a network #519

Open CucinaGiorgia opened 1 year ago

CucinaGiorgia commented 1 year ago

I am trying to select the nodes that display their labels, as demonstrated in this example: https://echarts.apache.org/examples/en/editor.html?c=graph. Despite creating a column specifically for the labels, I am not able to only show the ones I am interested in. echarts4r::e_labels(nodes$label) keeps giving me all the labels, even if the column is empty.

echarts4r::e_charts() %>%
   echarts4r::e_graph(
     roam = TRUE,
     force = list(
       initLayout = "circular",
       repulsion = 500,
       edgeLength = 30,
       layoutAnimation = FALSE),
     autoCurveness = TRUE %>%
   echarts4r::e_graph_nodes(
     nodes = nodes,
     names = name,
     value = value,
     size = size,
     category = grp,
     symbol=symbol
   ) %>%
   echarts4r::e_graph_edges(
     edges = edges,
     source = source,
     target = target,
     value = value,
     size = size
   ) %>%
  echarts4r::e_labels(nodes$label)%>%
   echarts4r::e_tooltip()

Is there a way to solve this?

Thanks

rdatasculptor commented 1 year ago

I think there is a way. Can you add some dummy data? I mean a complete reproducible example? Thanks!

JohnCoene commented 1 year ago

Thanks @rdatasculptor! Yes there is, I think using the formatter in e_labels, some JS to skip if empty string or something.

CucinaGiorgia commented 1 year ago

@rdatasculptor thank you for your help! 😄 Try to use this files: edges.csv nodes.csv

JohnCoene commented 1 year ago

Are you sure these are CSVs? I cannot open them

CucinaGiorgia commented 1 year ago

@JohnCoene Please, try again now nodes.csv edges.csv