jsMind是一个纯javascript的思维导图类库,本代码使用jsMind展示了一个基础的思维导图。
jsMind 项目主页: http://hizzgdev.github.io/jsmind/
本代码示例:http://hizzgdev.github.io/jsmind/example/1_basic.html
1.[代码]用jsMind显示一个简单的思维导图
// 代码来源: http://hizzgdev.github.io/jsmind/example/1_basic.html
// 定义思维导图数据
var mind = {
"meta":{
"name":"example",
"author":"hizzgdev@163.com",
"version":"0.2"
},
// 支持三种数据格式,具体参见jsMind的文档
// https://github.com/hizzgdev/jsmind/blob/master/docs/zh/index.md
"format":"node_array",
// 如果你在数据库中存储思维导图的每一个节点,则使用node_array格式非常方便
"data":[
{"id":"root", "isroot":true, "topic":"jsMind"},
{"id":"easy", "parentid":"root", "topic":"Easy"},
{"id":"easy1", "parentid":"easy", "topic":"Easy to show"},
{"id":"easy2", "parentid":"easy", "topic":"Easy to edit"},
{"id":"easy3", "parentid":"easy", "topic":"Easy to store"},
{"id":"easy4", "parentid":"easy", "topic":"Easy to embed"},
{"id":"open", "parentid":"root", "topic":"Open Source"},
{"id":"open1", "parentid":"open", "topic":"on GitHub"},
{"id":"open2", "parentid":"open", "topic":"BSD License"},
{"id":"powerful", "parentid":"root", "topic":"Powerful"},
{"id":"powerful1", "parentid":"powerful", "topic":"Base on Javascript"},
{"id":"powerful2", "parentid":"powerful", "topic":"Base on HTML5"},
{"id":"powerful3", "parentid":"powerful", "topic":"Depends on you"},
]
};
// jsMind的选项,更多参数参见jsMind的文档
// https://github.com/hizzgdev/jsmind/blob/master/docs/zh/index.md
var options = {
container:'jsmind_container',
editable:true,
theme:'primary'
}
var jm = new jsMind(options);
jm.show(mind);
// jm.set_readonly(true);
// var mind_data = jm.get_data();
// alert(mind_data);