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

290
Views
D3 - how to fire an on-click function for only a specific group of nodes

In this d3 force layout viz project I'm trying to remove the user's ability to click on the bigger yellow nodes. I have an on-click, fire the clicknodeControl function,

 nodes.append('circle')
  .attr("r", 28)  
  .attr("id", "hoverdots")
  .style("opacity", 0) 
  .style("fill", "#00bedd") 
  .on("click", function(d) { return clicknodeControl(d.group); }) 
  .style("z-index", "10")
  .on("mouseover", mouseover)
  .on("mouseout", mouseout)

and then ideally this variable would pass through the clicknode function to one group of nodes but not the other:

 var clicknodeControl = d3.scaleOrdinal([`clicknode`, ``]);

This does not seem to be working in practice, the clicknode function is not being passed through.

Thanks if anyone has any ideas on this!!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In D3 V7 mouse event handlers have event as the first argument and datum as the second.

Replace

.on("click", function(d) { return clicknodeControl(d.group); }) 

with:

.on("click", (_, d) => clicknodeControl(d.group)) 
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!