You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让Balkan Family Tree JS完整展示所有图表元素

Display Full Uncollapsed Balkan Family Tree

To show your entire family tree without automatic folding or navigation requirements, here are actionable configuration tweaks and methods:

  1. Disable Collapsibility Completely
    Add the collapsible: false parameter 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
    });
    
  2. Force All Nodes to Expand (If Collapsibility Is Needed)
    If you still want to keep collapsibility enabled but need all nodes open initially, call expandAll() right after loading your tree data:

    chart.load([/* your data */]);
    chart.expandAll();
    
  3. 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., 80 instead of default)
    • nodeSeparation: Minimize horizontal space between sibling nodes (e.g., 60)
    • Keep scaleInitial: FamilyTree.match.boundary (via fit=yes URL 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 02:47:15