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

100
Views
d3.js - Check parentNode value

I want to check if a parent node equals a certain type as defined in the JSON data. Using d3.js v4 (yes I know...)

For example in the JSON:

{"name":"ABC", "type":"3program_outcome_group","children":[{"name":"XY","type":"program_outcome"},...

In this example, I want to check if parent node's type ('type' being a custom parameter) is equal to 3program_outcome_group. At the same time, I also need to check if the child node is of type program_outcome.

I have tried:

if (d.type == 'program_outcome' && d.parentNode.type == '3program_outcome_group' )
    return d.name.substring(0, 6);

But it's not working...

Whereas the following works without checking the parentNode:

if (d.type == 'program_outcome')
     return d.name.substring(0, 4);

I have also tried:

if (d.type == 'program_outcome' && this.parentNode.type == '3program_outcome_group' )
       return d.name.substring(0, 6);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

OK, I used the following which works to find the parent node's value for the custom 'type' parameter:

if (d.type == 'program_outcome' && d.parent.type == '3program_outcome_group')
                    //do something
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!