score:0
Accepted answer
very simple solution to this. assuming you're using mike's example, the collapse
method is designed to be recursive. by default, the tree is expanded when loaded. the program calls the line root.children.foreach(collapse);
to collapse it. but note that this only calls collapse on the children, and does not collapse the root itself.
thus, to get the behavior you want, simply change that line to:
collapse(root);
and it will load up with the root also being collapsed.
Source: stackoverflow.com
Related Query
- What code should I change to get the flare.json uncollapsible on first load?
- What is the standard way to get the active (running) D3 v3 Transition for a given element?
- How to get the total depth of an unknown JSON hierarchy?
- What do the nodes, groups, and values mean in the JSON for a d3 force-directed graph?
- What is the difference between these two code blocks in d3.js
- How to get the specific JSON array from a value in that array
- What is the fastest way to get SVG element given a position (x,y)?
- d3 graph: What code to write in dblclick handler to change a node text
- What is "size" in flare json -- used in D3 examples?
- Passing JSON from Grails Controller to d3 - how to get the .gsp side working?
- How to get a value from a stylesheet into the code so that it can be used programmatically?
- NetworkD3 sankey chart in R creating really messy links, even though my code should be good. What is wrong?
- Should this code override the default d3 version in use by Juypyter notebooks?
- What is the best design for a react website that will need to load large data files
- what is the equivalent group code for nest and group functions in D3 V6
- 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
- D3 how to properly get the key value INSIDE of a json object
- Unable to get the correct index of node that was clicked in d3 and update the JSON at that location
- Update page JSON data get on drop down change
- Trying to load JSON into d3 treemap without using a GET
- What is the code to use your own data instead of the random data that is generated here?
- What is the most efficient way to aggregate a value from a JSON tree in d3.js?
- How to get the JSON path from element
- How should I use map to get back some values of an object when the key are user input
- How can I get the source code from a page using javascript
- What is the recommended way to refactor code written with d3.js like this?
- How do I structure data in php to get the correct json result?
- how to load json file using the latest d3?
- How does the following code get away with not defining initial x and y coordinates for nodes?
- How to get the total number of rows with particular value in json file in d3.js
More Query from same tag
- Second y axis on D3 column chart
- Legend placement D3
- D3 Not Displaying SVG Text Element
- Fit svg inside of div and automatically scale svg if size of div changes
- Identifying the function used in this d3 stacked bar chart example
- d3.js - evenly spaced bars on a time scale
- Nested datasets in d3, updating the right element
- How to plot bullet chart using python-nvd3?
- d3.js: How to rotate an SVG around its center while translating?
- SVG manipulation with d3 joins and text positioning
- D3 Nest - Sorting Values
- How to update the fill color on existing svg elements with d3.js?
- create bar chart with D3
- d3.js (v3) enter() not working in bar chart update
- D3.js - Uncaught TypeError: .enter(...).append(...).merge is not a function
- How to render a d3.js map on canvas free of blurriness
- Trying to Position SVG OVER Map, not UNDER it
- Passing callback function to d3.xml?
- How to stack rects respective of previous rect's height?
- How to set the browser window size according to D3JS graph?
- D3.js - Zoom network graph with canvas and then drag node
- dc.js - Hide the div container till the svg is created
- How to reach a URL based on a node click?
- Pie layout using multiple values within a single object
- SVG manipulate gradiant fill color
- nvd3 multibarchart height and label issue
- d3 donut chart unwanted outline during interpolation
- Python/Bottle: sending JSON object via post
- D3 append different elements, keep common index
- Responsive Donut Chart d3