如何让Balkan Family Tree JS完整展示所有图表元素
To show your entire family tree without automatic folding or navigation requirements, here are actionable configuration tweaks and methods:
Disable Collapsibility Completely
Add thecollapsible: falseparameter to your FamilyTree options. This removes all collapse buttons and ensures every node stays expanded permanently:var chart = new FamilyTree(document.getElementById("tree"), { // ... existing options collapsible: false, // ... other bindings });Force All Nodes to Expand (If Collapsibility Is Needed)
If you still want to keep collapsibility enabled but need all nodes open initially, callexpandAll()right after loading your tree data:chart.load([/* your data */]); chart.expandAll();Optimize Layout for Full Tree Display
Adjust spacing parameters to prevent excessive gaps and fit more nodes:levelSeparation: Reduce vertical space between generations (e.g.,80instead of default)nodeSeparation: Minimize horizontal space between sibling nodes (e.g.,60)- Keep
scaleInitial: FamilyTree.match.boundary(viafit=yesURL param) to auto-scale the tree to fit its container.
Modified Full Code Example
var options = getOptions(); var chart = new FamilyTree(document.getElementById("tree"), { mouseScrool: FamilyTree.none, scaleInitial: options.scaleInitial, siblingSeparation: 120, levelSeparation: 80, nodeSeparation: 60, template: 'john', collapsible: false, nodeBinding: { field_0: "name", field_1: "title", field_2 : "bday", img_0: "img", } }); chart.load([ // Insert your tree data here ]); function getOptions(){ const searchParams = new URLSearchParams(window.location.search); var fit = searchParams.get('fit'); var enableSearch = true; var scaleInitial = 1; if (fit == 'yes'){ enableSearch = false; scaleInitial = FamilyTree.match.boundary; } return {enableSearch, scaleInitial}; }
These options are available in recent versions of Balkan Family Tree JS (added post the older Stack Overflow question you referenced), so they should resolve your early folding issue. For very large trees, monitor performance, but most standard family trees will render without problems.
内容的提问来源于stack exchange,提问作者Cove

