Code Monkey home page Code Monkey logo

family-chart's Introduction

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

Family Chart

Interactive family tree chart built on top of d3.js
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

Product Name Screen Shot

family-chart is tool for creating and displaying family trees. Although it has many default features, family trees created with this tool are very customizable. This is an ongoing project and any suggestion or request will be appreciated :)

Examples

  1. Interactive family tree of all people in wikidata database. Product Name Screen Shot

  2. Basic tree Product Name Screen Shot

Getting Started

  1. Visit examples/create-tree
  2. Create your family tree
  3. Copy/paste generated code for Vanila, Vue or React.
  4. Copy/paste family-chart.css
  5. Give me some github stars (:

Usage

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Project Link: https://github.com/donatso/family-chart

(back to top)

family-chart's People

Contributors

donatso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

family-chart's Issues

Change the direction of the chart

Hello! First, I want to thank you for such a cool decision. I also have a question, how can you expand the direction of the tree to the other side? so that parents are under children and not above them (as now)

How to add/update family tree dynamically on the site

Hi Donatso,

Your library is great🥇for family tree implementation.

Can we add/update family tree dynamically instead of copying from the examples/create-tree? actually I am trying to accomplish family tree on react project(typescript).

It will be good scenario for updating family tree without touching the backend code.

Thanks for your support.

change the path line color to black

I want to set the main view's background color to be white and the path line color to be black.
However, I can set the backgroup color, but cannot find the setting of the path line.
Any suggestion will be great.

Expand tree animation

Hello Donatso!

Q1. I want to know is there any ways to stop the expand tree's animation, or expand faster?
Q2. Is there any ways to stop translate when I click those cards?

This family-chart is very amazing, thank you so much!!!

Customize onClick event on Card

I searched for this but I don't see anywhere. I want to add event onClick on the card so I can do other things such as show full info. Could you help? Also anywhere I can see the full options/parameter or all the methods? Thanks

Cannot find the list of all props of the constants store, view and Card respectively that can be changed

Please publish the list of all props of the constants store, view and Card respectively that can be changed. I have elaborated the issue below:

const store = f3.createStore({
    data: data(),
    node_separation: 300,
    level_separation: 170,
  }),
  view = f3.d3AnimationView({
    store,
    cont: document.querySelector("#FamilyChart"),
  }),
  Card = f3.elements.Card({
    store,
    svg: view.svg,
    card_dim: {
      w: 250,
      h: 70,
      text_x: 75,
      text_y: 15,
      img_w: 60,
      img_h: 60,
      img_x: 5,
      img_y: 5,
    },
    card_display: [
      (d) => `${d.data["first name"] || ""} ${d.data["middle name"].charAt(0)+"." || ""} ${d.data["last name"] || ""}`,
      (d) => `${d.data["birthday"] || ""}`,
    ],
    mini_tree: true,
    link_break: true,
  });

For example, in the above code we have passed the props to render customized data but in the same format as you have created in the package, in the same way.

If you can publish the list of all such properties and data types they accept, (props) which do not cause bugs on changing them.
I hope you got my point. I think that this feature will add more flexibliity in building application using this package.

Thanks, kindly and hopefully waiting for a response back

Is there a way to distinguish relationships?

First of all, thanks for the incredible effort.
Let's say that I would like to show divorced couples with a dashed relationship line, is that possible?
Thanks again for your time

Images reload when I click the same node

The images displayed on the graph is reloaded when I even click the same node (I can see they are requested in network monitor) and they flicker. An optimization for this would be good.

Multi Line Support

I tried adding another tspan in the js file but it doesn't seem to render the third line. Is there something I am missing / can it be added as a feature?

How to perform clean up in useEffect

so when I use state to toggle between views, it crashes when I try mounting back a tree component, works the first time but going back I get this.
image
Need a way to clean up when unmounting.

[NextJS] d3.select(...).transition is not a function

Hi, I find this module interesting and tried to implement to NextJS based on code generated on https://donatso.github.io/family-chart/examples/create-tree/

I wrap all componentDidMount to a useEffect hook, createRef with useRef hook.

I did a conditional if everything was mounted based on .current presence from the ref.

However it did not run as expected and returning the exact d3.select(...).transition is not a function error which I assume this was came from the family-chart that d3 module was not yet loaded, I've attached my code I working on this page.

'use client'

import { Suspense, useEffect, useRef } from 'react'
import f3 from 'family-chart'

import '@/styles/family-tree.css'

export default function RelationshipAnalisis() {

	const treeRef = useRef<HTMLDivElement>(null)

	const treeData = [
		{
			"id": "0",
			"rels": {
				"father": "83285456-43d8-44bd-bbf1-9204bd69111e",
				"mother": "fe5debe3-2ff0-4bf5-be51-317f595575d5",
				"spouses": [
					"588da99f-31df-4887-b4c1-163e4d2a6cee"
				]
			},
			"data": {
				"first name": "Name",
				"last name": "Surname",
				"birthday": 1970,
				"avatar": "https://static8.depositphotos.com/1009634/988/v/950/depositphotos_9883921-stock-illustration-no-user-profile-picture.jpg",
				"gender": "M"
			}
		},
		{
			"id": "83285456-43d8-44bd-bbf1-9204bd69111e",
			"data": {
				"gender": "M",
				"first name": "",
				"last name": "",
				"birthday": "",
				"avatar": ""
			},
			"rels": {
				"children": [
					"0"
				],
				"spouses": [
					"fe5debe3-2ff0-4bf5-be51-317f595575d5"
				]
			}
		},
		{
			"id": "fe5debe3-2ff0-4bf5-be51-317f595575d5",
			"data": {
				"gender": "F",
				"first name": "",
				"last name": "",
				"birthday": "",
				"avatar": ""
			},
			"rels": {
				"spouses": [
					"83285456-43d8-44bd-bbf1-9204bd69111e"
				],
				"children": [
					"0"
				]
			}
		},
		{
			"id": "588da99f-31df-4887-b4c1-163e4d2a6cee",
			"data": {
				"gender": "F",
				"first name": "",
				"last name": "",
				"birthday": "",
				"avatar": ""
			},
			"rels": {
				"spouses": [
					"0"
				]
			}
		}
	]

	useEffect(() => {
		if (treeRef?.current) {
			const store = f3.createStore({
				data: treeData,
				node_separation: 250,
				level_separation: 150
			})

			const view = f3.d3AnimationView({
				store,
				cont: document.querySelector("#FamilyChart")
			})

			const Card = f3.elements.Card({
				store,
				svg: view.svg,
				card_dim: { w: 220, h: 70, text_x: 75, text_y: 15, img_w: 60, img_h: 60, img_x: 5, img_y: 5 },
				card_display: [(d: { data: { [x: string]: any } }) => `${d.data['first name'] || ''} ${d.data['last name'] || ''}`, (d: { data: { [x: string]: any } }) => `${d.data['birthday'] || ''}`],
				mini_tree: true,
				link_break: false
			})

			view.setCard(Card)
			store.setOnUpdate((props: any) => view.update(props || {}))
			store.update.tree({ initial: true })
		}
	}, [treeRef.current])

	return (
		<div className="px-12 sm:px-32">
			<h2 className="text-xl font-medium">Hubungan</h2>
			<Suspense>
				<div id="treeWrapper" className="w-full h-96">
					<div className="f3" id="FamilyChart" ref={treeRef}></div>
				</div>
			</Suspense>
		</div>
	)
}

Search and Image

Hello Donatso,

I really loved your project and i have started to build one with my lineage. While working on it, i came across few scenarios, looking for your help around this...

  1. Can you help implement Search option on the chart!!
  2. I am also trying to implement onclick event on Image so that the Image would blow up for better visibility.
  3. Click on card to show more details..
  4. Can we count the number of nodes excluding the hidden ones!!
  5. Minimize larger nodes by default.

Custom elements

Hello Donatso, I would like to use my last wish :).
I tried to use the custom element but failed miserably.

Could you post a working example?

From already thank you very much

React Hooks and DT

It is hard to make use of functionalities in react, having a react hook will go a long way.
I want to be able to create forms in react, currently had to make use of your js example form.
A types declarations would also be helpful for typescript.

How to add third line to node?

i want to show third line in the node below birthday how to add it? also want to give class to card along with male female how to do it?

Search Issues

The example seems to work perfectly fine but when I try to port it to react it doesn't seem to work with a rewrite as well. The app without the search works but the search wouldn't. Plus in the example file the data is from Wiki, can that be injected with a JSON, cant seem to figure it out.
Simple js search example with local data would be great

Templating

Is there a way we could write our own html templates for the nodes ?
Can we make some nodes special like round?

Center the clicked item

Hello, I have a large tree and when I click on a sub node, I lose the family in the big canvas.
so the item i clicked must be navigated to center.

Manual Zoom

How to implement manualZoom in family-chart?
I'm using React JS

Search User

Hi @donatso !

I want you to support search user.
Or maybe a select box all user, when clicking on a user, the chart automatically focus on that user.

sibling node

is that possible to add sibling node of main node?

search feature

I think the js should come with search (like wiki-search example) or it should be activated with a parameter.

[Vue]addRelative is not a function

Hello,I tried to import this proj on examples/create-tree/,but I found it didn't work in some cases in my Vue proj.

First,pencil and add icon didn't appear,so i found it miss some params: 'cardEditForm' and 'addRelative'.But I don't know what the parameters consists of.How should I write two arguments?

Thank you ! :)

const store = await f3.createStore({
        data: await data(),
        node_separation: 250,
        level_separation: 150,
      }),
      view = f3.d3AnimationView({
        store,
        cont: document.querySelector("#FamilyChart"),
      }),
      Card = f3.elements.Card({
        store,
        svg: view.svg,
        card_dim: {
          w: 220,
          h: 70,
          text_x: 75,
          text_y: 15,
          img_w: 60,
          img_h: 60,
          img_x: 5,
          img_y: 5,
        },
        card_display: [
          (d) => `${d.data["first_name"] || ""} ${d.data["last_name"] || ""}`,
          (d) => `${d.data["birthday"] || ""}`,
        ],
        mini_tree: true,
        link_break: false,
        // cardEditForm: () => {}, ??
        // addRelative: () => {}, ??
      });

    view.setCard(Card);
    store.setOnUpdate((props) => view.update(props || {}));
    store.update.tree({ initial: true });

Expand tree

Hello @donatso!

How we can fully expand the tree? I've tried to edit toggleAllRels. But no results. I have no idea what I should do.

Could you help me?

Using family-chart with Laravel 10 Vite + React

Hi, I'm working on family tree in my spare time and I come across your package which would work perfect for me but I having issue using it with above combination.
I wonder if you'll be able to help me resolve the problem?

When importing f3 as in your React example
import f3 from "family-chart"; // npm i family-chart
I get error:
[plugin:vite:import-analysis] Failed to resolve entry for package "family-chart". The package may have incorrect main/module/exports specified in its package.json.

I've asked for help laravel community but none of the suggestions worked so I thought I'll reach out to you.
Here is a link to post in laracasts forum.
https://laracasts.com/discuss/channels/vite/laravel-10-vite-react-problem-importing-npm-packages

Regards.

Google Sheet family tree template

I have a Google Sheet for creating family tree data to import into yed. After finding the "family-chart" project, I added a sheet to transform the sheet data to the "family-chart" json format.

To use the Google Sheet...

  1. make a copy of the Sheet https://docs.google.com/spreadsheets/d/1FSPUe2Emdm97p7TwcLmxBvJwUBFTIm6QRH6wZrZJvY0/copy
  2. Enter Family tree information in the "People" tab
  3. In the "treeChart" tab, copy column O
  4. Create a page using the vanila html code from https://donatso.github.io/family-chart/examples/create-tree/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.