Giter VIP home page Giter VIP logo

Comments (8)

fperucic avatar fperucic commented on August 15, 2024

Hi, your question is valid, but why whould you want for JSONconfig.getID to reset?

from treant-js.

scrobbleme avatar scrobbleme commented on August 15, 2024

I'm able to use multiple trees on a page without any problem.

Just call new Treant ... multiple times on different configurations.

from treant-js.

leolr02 avatar leolr02 commented on August 15, 2024

scrobbleme, can you post your javascript code? I can't be able to initialize two diagrams in the same page

from treant-js.

scrobbleme avatar scrobbleme commented on August 15, 2024

@leolr02 Yes, see this page: http://stammbaum.dev.moewe.io/family-tree/persons/johann-caspar-goethe/
oder http://stammbaum.dev.moewe.io

There are 3 treant trees (even the single person card is one)

  • For configuring the trees, the JSON structure is used (just look into the pages source)

Initialization is done with a simpe JavaScript:

jQuery(function (jQuery) {
    var charts = jQuery('.stammbaum-chart');
    charts.each(create_treant);

    function create_treant(index, element) {
        element = jQuery(element);
        var person = element.attr('data-person');
        element.data('treant', new Treant(window.stammbaum['person-hierarchy-' + person], align_graph));
    }

    function align_graph(tree) {
        var tree_container = jQuery(tree.drawArea);
        var wrapper = tree_container.parent();
        var element = tree_container.find('.node').last();
        tree.drawArea.scrollLeft = parseInt(element.css('left')) - ((wrapper.width() - element.width()) / 2);
    }
});

align_graph is just use to center the graph on the root node.

The main part is just muliple calls to new Treant(configuration)

So really nothing special.

from treant-js.

leolr02 avatar leolr02 commented on August 15, 2024

thanks is more clearly for me!!! , have a nice day 👍

from treant-js.

Mixone-FinallyHere avatar Mixone-FinallyHere commented on August 15, 2024

This is not working for me :/

from treant-js.

scrobbleme avatar scrobbleme commented on August 15, 2024

@Mixone-FinallyHere What exactly is not working? Or better: What is happening, are there any (JavaScript) error? Do you have an example online.

from treant-js.

andrea-filoso avatar andrea-filoso commented on August 15, 2024

I have this same problem.

<script>
	/* first tree  */
	config = { container: "#basic-example"};

	parent_node = {	text: { name: "First parent node" } };

	first_child = { parent: parent_node, text: { name: "First child" }};
	second_child = { parent: parent_node, text: { name: "Second child" }};
	
	simple_chart_config = [	config, parent_node, first_child, second_child ];

	var chart = new Treant( simple_chart_config );
	/* Here tree shows all 3 nodes */
	
	/* Second tree same container */
	config2 = { container: "#basic-example"};

	parent_node2 = { text: { name: "Second parent node" } };

	first_child2 = { parent: parent_node2, text: { name: "First child 2" }};
	second_child2 = { parent: parent_node2, text: { name: "Second child 2" }};

	simple_chart_config2 = [ config2, parent_node2, first_child2, second_child2 ];	

	chart = new Treant( simple_chart_config2 );
	/* Here tree shows only root node*/	
</script>

I think that bug could be in JSONconfig.getId() or in JSONconfig.findChildren().

findChildren: function(nodes) {
		var parents = [0]; // start with a a root node
		...

New Treant doesn't reset the i variable so when next Treant is created, the id of root node isn't 0 and findChildren() fails.
I hope this comment can help you.

from treant-js.

Related Issues (20)

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.