Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting options for family tree usage #12

Open
koka-noodles opened this issue Oct 10, 2022 · 1 comment
Open

Formatting options for family tree usage #12

koka-noodles opened this issue Oct 10, 2022 · 1 comment

Comments

@koka-noodles
Copy link

Hey, love the project but I'm pretty basic with JS. The issue is that I'm trying to use the code to set up a big family tree but I can't specify who is married / divorced to whom. Could you suggest a place to start ? My first thought would be to make a new version of the links with a separate colour but I think integrating it would be a bit messy.

Thanks for the work anyway

@BenPortner
Copy link
Owner

Hi @koka-noodles,

Thanks for your interest in js_family_tree. I am not yet sure if I understand you right but let's try to figure it out together.

I'm trying to use the code to set up a big family tree but I can't specify who is married / divorced to whom

The easiest way would be to define all persons and their relationships in the data.js file. For an example, see this file.

My first thought would be to make a new version of the links with a separate colour

You can change the link color by assigning different classes to the edges (based on some criterion). The relevant line would be this:

.attr("class", this.link_css_class)

For example, you could change the class based on whether the edge starts in a union or ends in a union like this:

        var linkEnter = link.enter().insert('path', "g")
            .attr("class", edge => {
                if(edge.source.is_union()) {
                    return "union_source_edge"
                } else {
                    return "union_target_edge"
                }
            })
            .attr('d', _ => {
                var o = {
                    x: source.x0,
                    y: source.y0
                }
                return this.link_path_func(o, o)
            });

Of course you would then also have to adapt the main.css file to define those classes. For example:

.union_source_edge {
    fill: none;
    stroke: red;
    stroke-width: 2px;
}

.union_target_edge {
    fill: none;
    stroke: blue;
    stroke-width: 2px;
}

Result:
image

I hope this helped a bit. Let me know if anything is unclear.

Cheers.
Ben

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants