score:4
Accepted answer
The v4 changelog tells us that
When used in conjunction with nest.rollup, nest.entries now returns {key, value} objects for the leaf entries, instead of {key, values}.
It is this little renaming from values
to value
within the leaf nodes which eventually breaks the code. Changing the helper function accordingly should get you back on track:
// Recursively sum up children's values
function sumChildren(node) {
if (node.value) {
node.values = node.value; // Ensure, leaf nodes will also have a values array
delete node.value; // ...instead of a single value
}
node.Population = node.values.reduce(function(r, v) {
return r + (v.value? sumChildren(v) : v.Population);
},0);
return node.Population;
}
Source: stackoverflow.com
Related Query
- D3.js nesting and rollup at the same time in v4
- D3.js nesting and rollup at same time
- d3 zoom and brush working at the same time
- D3 v4 moving both circle and text at the same time
- How to automatically move nodes and links at the same time in d3.js
- d3: hovering over words in text at the same time highlighting the corresponding bars and make word in text clickable
- animate grow and radius at the same time
- force directed graph - define the color of a node, if the node is source and target at the same time
- How can I make both HTTP and Websocket requests at the same time on the same server?
- Transitioning xAxis and data at the same time - D3.js
- D3: How do I set "click" event and "dbclick" event at the same time?
- AngularJS, D3 and JQuery in the same page. D3 can't read the correct DOM dimensions
- D3 v4 Brush and Zoom on the same element (without mouse events conflicting)
- How to group by multiple keys at the same time using D3?
- d3.js: run the same code in Angular app and on node.js
- Mouseover event on two charts at the same time d3.js
- How to get the boundaries of currently visible time scale (after panning and zooming)?
- Arrow head and link of the same color in D3 js graph
- Create a padding for the first and last data points using a time scale
- Implementing shift click and click functionality on the same element
- Javascript / Momentjs: Elegant way to find the min and max time from a set of dates?
- cs.js - displaying only one line at the same time (in multi-line chart)?
- How to have the same scale in both x and y
- Combining Enyo 2.4 and D3 JS on the same page
- Why doesn't the same group render a correct line chart and corresponding range chart?
- D3 - not all children nodes are shown at the same time
- Transition all div elements with .tween at the same time with d3
- I am trying to build a d3js graph but on the x-axis i am getting the timestamps instead of date and time even after i used formatting
- How can I control the date format for d3 scaleTime and remove unwanted clock time ticks?
- Time in x-axis and data for the y-axis for line chart in d3.js doesn't match/show with what (data) is on JSON
More Query from same tag
- Collapsible tree diagram v4 and Internet Explorer
- D3 - Legend in seperate div element
- Axis-range-slider alignment
- Creating a simple pie chart using dc.js
- How do you change the default axis labels in D3
- Transition for grouped bar chart in d3 when updating the data values
- Programmatically change initial pan state d3 v4
- d3.event is null inside of debounced function
- d3js Nodes from Links json
- D3.js Pie-chart: how to automatically create and assign gradual scale of colors based on my own categorization
- C3js horizontal bar chart labels cut off and sizing issue
- How to add a d3js graph in slideshow instead of body?
- How to transition from the start position in a loop?
- D3 Not Displaying But No Errors
- Parsing text file to objects in an array in javaScript
- d3 svg differentiate onclick
- Moving an object from one region to another in d3.js
- Draw circles inside pie - d3 chart
- d3.js binary tree with HTML as the nodes
- D3.js path goes in different directions in V3 vs V4
- Reading DOT files in javascript/d3
- Why is nothing being displayed on the webpage?
- In created:, my method doesn't work perfectly
- D3 barchart with ajax data
- Most performant way to add to DOM in ngFor
- Wheel event is not fired on a SVG group element in Safari
- d3 v4 how to limit left/right panning on an x zoom line-graph
- How can I toggle the value of an svg text element with D3.js when user clicks the text?
- How to create responsive svg using d3.js
- How to drag several circles using JS?