Code Monkey home page Code Monkey logo

js-mindmap's Introduction

js-mindmap

Kenneth Kufluk 2008/09/10/11

This code is provided at:
https://github.com/kennethkufluk/js-mindmap

A demo is provided at:
http://kenneth.kufluk.com/google/js-mindmap/

Requires jQuery for basic shortcuts ($) and stuff.
Requires Raphael for drawing.
jQuery UI may be used to allow draggable nodes.

This code is released under license.  Please leave acknowledgements and copyright messages in the code.


WHAT IS THIS?
-------------

This is a small demo script, intended for fun applications.
My favourite is this:
http://www.pcworld.com/misc/edit/195163/index.htm

If you feel like building it out into a massively overfeatured application, please go ahead.  While I've stuck some liberal licensing on it, the basic principles of a force directed layout controlling nodes are as free as the birds in the trees.
My favourite massively overfeatured application is this:
http://www.mindjet.com/ (great for meeting notes)


HOW THIS WORKS
--------------

It's relatively easy to build a mindmap.  Take a collection of HTML nodes, and position them absolutely.  Use a Force Directed Layout to link them together and yet keep them apart.

http://en.wikipedia.org/wiki/Force-based_algorithms_(graph_drawing)

Once you've got that, you need to add some filters, to define which nodes are properly connected. All nodes should repel, to prevent overlap, but connected nodes should have a string between them.  This is where you use a springy force (hooke's law) to pull them together.

Drawing lines in HTML is not an easy feat.  IE has/had VML, all browsers (except Android) support SVG (albeit slowly), and all except IE support Canvas.  I tried using a diagonal line in a JPG, stretching it to fit.  It looks daft.  I then switched to Canvas, and now I'm on SVG (using Raphael to support IE VML too).  So it works everywhere except Android.


ALTERNATIVES
------------

Before I wrote this, I used an open-source mindmap written in Flex.  It was beautiful.
It's here:
http://www.rubenswieringa.com/blog/interactive-mindmap
It uses Mark Shepard's SpringGraph component, which has lots of interesting demos:
http://mark-shepherd.com/blog/springgraph-flex-component/

I considered migrating this component to JS, but found it massively over-complicated for the simple uses I had in mind.


APPLICATIONS IN THE WILD
------------------------

I use this code for my own mindmap website here:
http://sunshinemisiu.com/

Also, there's a PCWorld page about Google here:
http://www.pcworld.com/misc/edit/195163/index.htm

Let me know of any others to add here.

js-mindmap's People

Contributors

drewish avatar kennethkufluk avatar kevinkells 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  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

js-mindmap's Issues

Window width sometimes not set correctly

When using the default options (which passes height of -1 for automatic detection) the window's width is not always read correctly. It's very noticeable in Chrome if I open up two tabs then close the browser, when it's re-opened one tab will almost always have all the elements stacked at the very left side of the screen. This also hints at another issue which is the resize event doesn't seem to fire correctly.

Load on-demand <ul>

I'm working on a MindMap with over two million items, performance was affected due to the quantity of items to be loaded at once.

There is a possibility, and load demand (on-demand) the ul in order to speed at the time of mounting the MindMap?

performance on ios (iPad)

Is it possible to improve performance of js-mindmap for iOS& I opened demo version of js-mindmap on ipad and it was performing bad. Movement of nodes was lagging.

It is amazing script! Thanks!

Integration with shadowbox.js (addition)

More an addition than an "issue" but not quite a fork. If you want to add shadowbox.js to the links, this is what worked for me:

    this.el.click(function(){
        if (obj.activeNode) {
            obj.activeNode.el.removeClass('active');
        }
        if (typeof(opts.onclick)=='function') {
            opts.onclick(thisnode);
        }
        obj.activeNode = thisnode;
        obj.activeNode.el.addClass('active');
    this.el = $('<a href="'+this.href+'" rel="shadowbox">'+this.name+'</a>');

    Shadowbox.open({ 
    player:     'qt', 
    title:      'Welcome', 
    content:    this.href, 
    height:     480, 
    width:      720 
}); 

In the HTML, place the JavaScript that calls the shadowbox at the bottom of your document:

<script type="text/javascript"> 

Shadowbox.init({
    // a darker overlay looks better on this particular site
overlayOpacity: 0.8

});

</script> 

change color

A way to change the color of certain nodes would be very useful.

console.log breaks IE

Hi,
you have in line 448 in the js-minmap.js a :
console.log(obj.root);

which breaks the IE.
You could consider a log wrapper like:
paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog

non-hirarchal relation between nodes

it would be great if by adding class="relation:nodename" it will draw another line to related nodes (even though the related node is really "far away" from current center node) in a different color.

change shapes

Is there a way to change the default rectangular shape of a node? (e.g. to a circle)

customizing styles for last child nodes

Hi,
I am trying to use the mind map to show user details like activity, access, top 10 documents accessed, hr info , etc. Each of the child nodes will have large information and I need to be able to have that in a larger box also arranging the child most nodes in a horizontal array of boxes.
Also right now its getting really difficult to keep the mindmap bounded to a limited frame like a div, changing the canvas initialization call (Raphael( , , , ) in js-mindMap.js binds the links to the defined x and y parameters but nodes still remain unbounded and roam in a browser window extendable infinitely..
Thanks
Priyank

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.