Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Addded new mindmap visualization in the perspectiveGraph

uggrock6ef885082c6f
diff --git a/data/ext/perspectiveGraph/extension.js b/data/ext/perspectiveGraph/extension.js
index 9203e918d..024348482 100644
--- a/data/ext/perspectiveGraph/extension.js
+++ b/data/ext/perspectiveGraph/extension.js
@@ -7,10 +7,10 @@ define(function(require, exports, module) {
console.log("Loading perspectiveGraph");
- var extensionTitle = "InfoViz"
+ var extensionTitle = "DirectoryViz"
var extensionID = "perspectiveGraph"; // ID should be equal to the directory name where the ext. is located
var extensionType = "perspective";
- var extensionIcon = "icon-bar-chart";
+ var extensionIcon = "icon-sitemap";
var extensionVersion = "1.0";
var extensionManifestVersion = 1;
var extensionLicense = "AGPL";
@@ -23,7 +23,7 @@ define(function(require, exports, module) {
var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+extensionID;
- var graphMode = "treeMap" // tree
+ var graphMode = "mindmap"
var treeData = undefined;
@@ -86,6 +86,21 @@ define(function(require, exports, module) {
TSCORE.hideLoadingAnimation();
});
break;
+ case "mindmap":
+ require([
+ extensionDirectory+'/mindmap.js',
+ 'css!'+extensionDirectory+'/mindmap.css',
+ ], function(viz) {
+ d3.select("svg").remove();
+ var svg = d3.select("#"+extensionID+"Container")
+ .append("svg")
+ .attr("id", "tagspacesMindmap")
+ .attr("width", viewContainer.width())
+ .attr("height", viewContainer.height())
+ viz.drawMindMap(svg, treeData);
+ TSCORE.hideLoadingAnimation();
+ });
+ break;
case "bilevelPartition":
require([
extensionDirectory+'/bilevelPartition.js',
@@ -129,12 +144,25 @@ define(function(require, exports, module) {
class: "btn-group",
"data-toggle": "buttons-radio",
})
+ .append($("<button>", {
+ class: "btn",
+ title: "Activate Mindmap Visualization",
+ text: " Mindmap"
+ })
+ .button('toggle')
+ .click(function() {
+ graphMode = "mindmap";
+ TSCORE.showLoadingAnimation();
+ TSCORE.IO.createDirectoryTree(TSCORE.currentPath);
+ })
+ .prepend( "<i class='icon-sitemap' />")
+ )
+
.append($("<button>", {
class: "btn",
title: "Activate Treemap Mode",
text: " TreeMap"
})
- .button('toggle')
.click(function() {
graphMode = "treeMap";
TSCORE.showLoadingAnimation();
@@ -153,7 +181,7 @@ define(function(require, exports, module) {
TSCORE.showLoadingAnimation();
TSCORE.IO.createDirectoryTree(TSCORE.currentPath);
})
- .prepend( "<i class='icon-sitemap' />")
+ .prepend( "<i class='icon-th-large' />")
)
.append($("<button>", {
@@ -179,7 +207,7 @@ define(function(require, exports, module) {
TSCORE.showLoadingAnimation();
TSCORE.IO.createDirectoryTree(TSCORE.currentPath);
})
- .prepend( "<i class='icon-sitemap' />")
+ .prepend( "<i class='icon-adjust' />")
)
) // end button group
diff --git a/data/ext/perspectiveGraph/mindmap.css b/data/ext/perspectiveGraph/mindmap.css
new file mode 100644
index 000000000..f624392b2
--- /dev/null
+++ b/data/ext/perspectiveGraph/mindmap.css
@@ -0,0 +1,21 @@
+/* Styles for the mindmap application of TagSpaces */
+#tagspacesMindmap {
+
+}
+
+#tagspacesMindmap .node circle {
+ cursor: pointer;
+ fill: #fff;
+ stroke: steelblue;
+ stroke-width: 1.5px;
+}
+
+#tagspacesMindmap .node text {
+ font-size: 11px;
+}
+
+#tagspacesMindmap path.link {
+ fill: none;
+ stroke: #ccc;
+ stroke-width: 1.5px;
+}
\ No newline at end of file
diff --git a/data/ext/perspectiveGraph/mindmap.js b/data/ext/perspectiveGraph/mindmap.js
new file mode 100644
index 000000000..81eb22d5e
--- /dev/null
+++ b/data/ext/perspectiveGraph/mindmap.js
@@ -0,0 +1,155 @@
+/* Copyright (c) 2012-2013 The TagSpaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
+ * can be found in the LICENSE file. */
+
+define(function(require, exports, module) {
+"use strict";
+ console.log("Loading Mindmap");
+
+ var TSCORE = require("tscore");
+
+ require("d3");
+
+ // Based on http://mbostock.github.io/d3/talk/20111018/tree.html
+ var drawMindMap = function(svg, treeData) {
+ var vis = svg;
+
+ var m = [20, 120, 20, 120],
+ w = svg.attr("width") - m[1] - m[3],
+ h = svg.attr("height") - m[0] - m[2],
+ i = 0,
+ root;
+
+ var tree = d3.layout.tree()
+ .size([h, w]);
+
+ var diagonal = d3.svg.diagonal()
+ .projection(function(d) { return [d.y, d.x]; });
+
+ vis.append("svg:g")
+ .attr("transform", "translate(" + m[3] + "," + m[0] + ")");
+
+ root = treeData;
+ root.x0 = h / 2;
+ root.y0 = 0;
+
+ function toggleAll(d) {
+ if (d.children) {
+ d.children.forEach(toggleAll);
+ toggle(d);
+ }
+ }
+
+ // Initialize the display to show a few nodes.
+ root.children.forEach(toggleAll);
+
+ update(root);
+
+ function update(source) {
+ var duration = d3.event && d3.event.altKey ? 5000 : 500;
+
+ // Compute the new tree layout.
+ var nodes = tree.nodes(root).reverse();
+
+ // Normalize for fixed-depth.
+ nodes.forEach(function(d) { d.y = d.depth * 180; });
+
+ // Update the nodes…
+ var node = vis.selectAll("g.node")
+ .data(nodes, function(d) { return d.id || (d.id = ++i); });
+
+ // Enter any new nodes at the parent's previous position.
+ var nodeEnter = node.enter().append("svg:g")
+ .attr("class", "node")
+ .attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; })
+ .on("click", function(d) { toggle(d); update(d); });
+
+ nodeEnter.append("svg:circle")
+ .attr("r", 1e-6)
+ .style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });
+
+ nodeEnter.append("svg:text")
+ .attr("x", function(d) { return d.children || d._children ? -10 : 10; })
+ .attr("dy", ".35em")
+ .attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
+ .text(function(d) { return d.name; })
+ .style("fill-opacity", 1e-6);
+
+ // Transition nodes to their new position.
+ var nodeUpdate = node.transition()
+ .duration(duration)
+ .attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; });
+
+ nodeUpdate.select("circle")
+ .attr("r", 4.5)
+ .style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });
+
+ nodeUpdate.select("text")
+ .style("fill-opacity", 1);
+
+ // Transition exiting nodes to the parent's new position.
+ var nodeExit = node.exit().transition()
+ .duration(duration)
+ .attr("transform", function(d) { return "translate(" + source.y + "," + source.x + ")"; })
+ .remove();
+
+ nodeExit.select("circle")
+ .attr("r", 1e-6);
+
+ nodeExit.select("text")
+ .style("fill-opacity", 1e-6);
+
+ // Update the links…
+ var link = vis.selectAll("path.link")
+ .data(tree.links(nodes), function(d) { return d.target.id; });
+
+ // Enter any new links at the parent's previous position.
+ link.enter().insert("svg:path", "g")
+ .attr("class", "link")
+ .attr("d", function(d) {
+ var o = {x: source.x0, y: source.y0};
+ return diagonal({source: o, target: o});
+ })
+ .transition()
+ .duration(duration)
+ .attr("d", diagonal);
+
+ // Transition links to their new position.
+ link.transition()
+ .duration(duration)
+ .attr("d", diagonal);
+
+ // Transition exiting nodes to the parent's new position.
+ link.exit().transition()
+ .duration(duration)
+ .attr("d", function(d) {
+ var o = {x: source.x, y: source.y};
+ return diagonal({source: o, target: o});
+ })
+ .remove();
+
+ // Stash the old positions for transition.
+ nodes.forEach(function(d) {
+ d.x0 = d.x;
+ d.y0 = d.y;
+ });
+ }
+
+ // Toggle children.
+ function toggle(d) {
+ if (d.children) {
+ d._children = d.children;
+ d.children = null;
+ } else {
+ TSCORE.FileOpener.openFile(d.path);
+ d.children = d._children;
+ d._children = null;
+ }
+ }
+
+ }
+
+ // Methods
+ exports.drawMindMap = drawMindMap;
+
+});
\ No newline at end of file
diff --git a/data/ext/perspectiveGraph/treeMap.js b/data/ext/perspectiveGraph/treeMap.js
index cef772610..b0409ce9a 100644
--- a/data/ext/perspectiveGraph/treeMap.js
+++ b/data/ext/perspectiveGraph/treeMap.js
@@ -4,7 +4,7 @@
define(function(require, exports, module) {
"use strict";
- console.log("Loading Quantified Self");
+ console.log("Loading Tree Map");
var TSCORE = require("tscore");
diff --git a/data/ext/perspectiveHealth/extension.js b/data/ext/perspectiveHealth/extension.js
index 131d8f7e2..cad694218 100644
--- a/data/ext/perspectiveHealth/extension.js
+++ b/data/ext/perspectiveHealth/extension.js
@@ -10,7 +10,7 @@ define(function(require, exports, module) {
var extensionTitle = "Quantified Self"
var extensionID = "perspectiveHealth"; // ID should be equal to the directory name where the ext. is located
var extensionType = "perspective";
- var extensionIcon = "icon-medkit";
+ var extensionIcon = "icon-bar-chart";
var extensionVersion = "1.0";
var extensionManifestVersion = 1;
var extensionLicense = "AGPL";