d3.js v4 Partition where parent's value is greater than sum of its children (node.sum)

Gawain Chin

I know, in d3.js v4, it is possible that parent's value is greater than sum of its children by using the d3.v4 hierarchy().sum()

I also know that the hierarchy().sum() function will return a value that is a sum of the node and its children.

However, I only want to draw the respective rectangular that contains its value only (not the sum of its value plus the sum of its children)

Is it possible?

For example, this is the JSON file:

{"name":"Top Level", "size": "50000" ,"children":[{"name":"Level 2: A","size":"10000","children":[{"name":"Son of A","size":"2000"},{"name":"Daughter of A","size":"3000"}]},{"name":"Level 2: B","size":"1000"}]}

So for Top Level, I only a box with size 50000. (not 50000+10000+2000+3000+1000 = 66000)

bumbeishvili

You can manually override values of hierarchy object and skip sum function

var rawData = {
  "name": "Top Level",
  "size": "50000",
  "children": [
    {
      "name": "Level 2: A",
      "size": "10000",
      "children": [
        {
          "name": "Son of A",
          "size": "2000"
        },
        {
          "name": "Daughter of A",
          "size": "3000"
        }
      ]
    },
    {
      "name": "Level 2: B",
      "size": "1000"
    }
  ]
}

var root = d3.hierarchy(rawData);  //apply hierarchy 


root.each(d=> d.value = +d.data.size); //override values

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to select where sum of fields is greater than a value in MongoDB

From Dev

Smallest sum of subarray with sum greater than a given value

From Dev

Get all records where sum of children (quantity) is less than parent (also quantity)

From Dev

sum if greater than in r

From Dev

Calculating sum of children's balance for each parent

From Dev

parent nodes value to be the sum of all its childrens

From Dev

Query where sum of a group of records greater than ZERO

From Dev

sql select where (sum of 2 columns) is greater than X

From Dev

xslt sum node values where node value

From Dev

Number of Subarray whose sum greater than given value

From Dev

d3.js: How to size D3 partition table based on both children and parents value

From Dev

Parent value as sum of all children values within nested javascript object

From Dev

Width auto results in larger width than the sum of children's width

From Dev

Can we use IntStream#sum, If sum of elements is greater than the Integer.MAX_VALUE?

From Dev

Use recursion to get parent value and children value and all its children's children value

From Dev

MySql: Getting sum of a table by the id of its parent from other table and return all children with sum values that are relevant to parent_id

From Dev

PROLOG Print numbers that end in 7 and the sum of its digits is greater than 100

From Dev

PROLOG Print numbers that end in 7 and the sum of its digits is greater than 100

From Dev

MySQL select rows where its columns sum equal value

From Dev

MySQL select rows where its columns sum equal value

From Dev

Select array elements that are greater than 5% of a sum

From Dev

MySQL select records with sum greater than threshold

From Dev

MySQL to select a daterange where sum is less than a value

From Dev

Check if there exists a cycle containing a certain edge in a graph where the sum of edge values is greater than 0

From Dev

Check if there exists a cycle containing a certain edge in a graph where the sum of edge values is greater than 0

From Dev

MySQL Select 3 random rows where sum of three rows is less than value

From Java

How to create a cumulative sum column in python if column value is greater than other value

From Dev

SUM operation on attributes of children of multiple parent records

From Dev

SUM operation on attributes of children of multiple parent records

Related Related

  1. 1

    How to select where sum of fields is greater than a value in MongoDB

  2. 2

    Smallest sum of subarray with sum greater than a given value

  3. 3

    Get all records where sum of children (quantity) is less than parent (also quantity)

  4. 4

    sum if greater than in r

  5. 5

    Calculating sum of children's balance for each parent

  6. 6

    parent nodes value to be the sum of all its childrens

  7. 7

    Query where sum of a group of records greater than ZERO

  8. 8

    sql select where (sum of 2 columns) is greater than X

  9. 9

    xslt sum node values where node value

  10. 10

    Number of Subarray whose sum greater than given value

  11. 11

    d3.js: How to size D3 partition table based on both children and parents value

  12. 12

    Parent value as sum of all children values within nested javascript object

  13. 13

    Width auto results in larger width than the sum of children's width

  14. 14

    Can we use IntStream#sum, If sum of elements is greater than the Integer.MAX_VALUE?

  15. 15

    Use recursion to get parent value and children value and all its children's children value

  16. 16

    MySql: Getting sum of a table by the id of its parent from other table and return all children with sum values that are relevant to parent_id

  17. 17

    PROLOG Print numbers that end in 7 and the sum of its digits is greater than 100

  18. 18

    PROLOG Print numbers that end in 7 and the sum of its digits is greater than 100

  19. 19

    MySQL select rows where its columns sum equal value

  20. 20

    MySQL select rows where its columns sum equal value

  21. 21

    Select array elements that are greater than 5% of a sum

  22. 22

    MySQL select records with sum greater than threshold

  23. 23

    MySQL to select a daterange where sum is less than a value

  24. 24

    Check if there exists a cycle containing a certain edge in a graph where the sum of edge values is greater than 0

  25. 25

    Check if there exists a cycle containing a certain edge in a graph where the sum of edge values is greater than 0

  26. 26

    MySQL Select 3 random rows where sum of three rows is less than value

  27. 27

    How to create a cumulative sum column in python if column value is greater than other value

  28. 28

    SUM operation on attributes of children of multiple parent records

  29. 29

    SUM operation on attributes of children of multiple parent records

HotTag

Archive