Git Product home page Git Product logo

dndtree's Introduction

#dndTree ##Introduction dndTree is a drag & drop tree built using D3.js. It was tested in the latest version of Chrome and Firefox.

It's not exactly brilliant code, but I looked for a D&D tree and couldn't find one, so I made this one publicly available. Feel free to use and tweak, and please report any issue you find.

##Contents

  • dndTree.js is the actual lib. The code isn't properly done (yet?), so you'll need to edit this file to customize the tree.
  • dndTree.css are sample styles for the tree. Really ugly right now, but useful for testing.
  • <name>.json are data files to test the tree. Ignore issuestable.json for now, it doesn't work. It will in the future! :)
  • index.html a simple example

##Usage To use, just create a div with a specific id, and call the constructor. Next, just send your data to the tree. This example assumes you have a issues.json file with your tree.

...
<div id="chart"></div>
...
<script type="text/javascript">
    $(function(){
    	var tree = new dndTree("#chart");
    	d3.json("issues.json", function(json) {
			tree.update(json);
		});	
    });
</script>
</body>
</html>

###JSON format The .json file needs to have a hierarchical structure. Something like:

{"id": 1, "name": "Parent", "children": [
  {"id": 2, "name": "Child 1", "children": [
    {"id": 3, "name": "Child 1.1", "children": [
        {"id": 4,"name": "Child 1.1.1"},
        {"id": 5, "name": "Child 1.1.2"}
      ]
    }]
  },
  {"id": 6, "name": "Child 2", "children": [
  	{"id": 7,"name": "Child 2.2"},
  	{"id": 8, "name": "Child 2.3"}
  ]}
]}

This uses the D3 tree layout, so you can check more details here.

##Customization Customization right now isn't a pretty thing… I need to improve that bit!

You'll need to dive into D3 and play with the innerUpdate function. Just beware that some of the elements are required for drag and drop to work.

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.