diff --git a/example/bundle/bundle.html b/example/bundle/bundle.html
index 7bc7ab7..7593ae1 100644
--- a/example/bundle/bundle.html
+++ b/example/bundle/bundle.html
@@ -1,53 +1,52 @@
-
-
-
-
-
- Hierarchical Edge Bundling
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Hierarchical Edge Bundling
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/bundle/bundle_without_seajs.html b/example/bundle/bundle_without_seajs.html
new file mode 100644
index 0000000..7975fe7
--- /dev/null
+++ b/example/bundle/bundle_without_seajs.html
@@ -0,0 +1,36 @@
+
+
+
+
+ Hierarchical Edge Bundling
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/charts/bundle.js b/lib/charts/bundle.js
index b3a0a2c..0f65816 100644
--- a/lib/charts/bundle.js
+++ b/lib/charts/bundle.js
@@ -1,8 +1,14 @@
/*global EventProxy, d3, Raphael, self, packages, $ */
-//function:弦+文字+高亮某弦
-define(function (require, exports, module) {
- var DataV = require('datav');
+// 弦+文字+高亮某弦
+;(function (name, definition) {
+ if (typeof define === 'function') { // Module
+ define(definition);
+ } else { // Assign to common namespaces or simply the global object (window)
+ this[name] = definition(function (id) { return this[id];});
+ }
+})('Bundle', function (require) {
+ var DataV = require('DataV');
//构造函数,container参数表示在html的哪个容器中绘制该组件
//options对象为用户自定义的组件的属性,比如画布大小
@@ -33,19 +39,6 @@ define(function (require, exports, module) {
}
});
- //返回
- Bundle.prototype.checkContainer = function (container) {
- if (!container) {
- throw new Error("Please specify which container to render.");
- }
- if (typeof (container) === "string") {
- return document.getElementById(container); //如果container为string,但是html中不存在该container,那么return返回空object
- } else if (container.nodeName) { //DOM-element
- return container;
- }
- throw new Error("Please specify which container to render.");
- };
-
//设置用户自定义属性
Bundle.prototype.setOptions = function (options) {
if (options) {
@@ -76,7 +69,7 @@ define(function (require, exports, module) {
Bundle.prototype.setSource = function (source) {
if (source[0] && source[0] instanceof Array) {
// csv or 2d array source
- if (source[0][0] === "name") {
+ if (source[0][0] === "name") {
source = source.slice(1); // 从第一行开始,第0行舍去
}
var nData = [];
@@ -211,7 +204,7 @@ define(function (require, exports, module) {
var rotateStr = "";
//element data cache
- var nodeRelatedElements = {};// {key: {targetLink: [], sourceLink: [], targetNode: [], sourceNode: []}}
+ var nodeRelatedElements = {};// {key: {targetLink: [], sourceLink: [], targetNode: [], sourceNode: []}}
var nodeElements = {}; //{key: Els}
var bBoxElements = {}; //{key: Els}
@@ -229,7 +222,7 @@ define(function (require, exports, module) {
var mouseoverLink = function () {
var current = this;
//var color = that.data("color");
- if (rLinks.preLink) {
+ if (rLinks.preLink) {
rLinks.preLink.attr("stroke", that.defaults.color.defaultLineColor)
.attr("stroke-width", 1)
.attr("stroke-opacity", 0.6);
@@ -240,7 +233,7 @@ define(function (require, exports, module) {
current.attr("stroke", that.defaults.color.lineHoverColor)
.attr("stroke-width", 2)
.attr("stroke-opacity", 1.0)
- .toFront(); //把当前弦移到画布最上层
+ .toFront(); //把当前弦移到画布最上层
};
/*
@@ -250,13 +243,13 @@ define(function (require, exports, module) {
current.attr("stroke", that.defaults.color.defaultLineColor)
.attr("stroke-width", 1)
.attr("stroke-opacity", 0.6);
- };
+ };
*/
var mouseoverNode = function () {
var relatedEl = this.data("relatedElements");
//高亮所选节点的文字颜色
- this.data("relatedNode").attr({"fill": that.defaults.color.nodeHoverColor,
+ this.data("relatedNode").attr({"fill": that.defaults.color.nodeHoverColor,
"fill-opacity": 1.0, "font-weight": "600"});
//将包围盒颜色设为透明
this.attr({"fill": that.defaults.color.nodeHoverColor, "fill-opacity": 0.0/*, "font-weight": "600"*/});
@@ -265,7 +258,7 @@ define(function (require, exports, module) {
d.attr({"stroke": that.defaults.color.importNodesColor, "stroke-width": 1, "stroke-opacity": 0.9})
.toFront();
});
- relatedEl.sourceNode.forEach(function (d) {
+ relatedEl.sourceNode.forEach(function (d) {
d.attr({"fill": that.defaults.color.importNodesColor, "font-weight": "600"});
});
relatedEl.targetLink.forEach(function (d) { //set red
@@ -275,11 +268,11 @@ define(function (require, exports, module) {
relatedEl.targetNode.forEach(function (d) {
d.attr({"fill": that.defaults.color.exportNodesColor, "font-weight": "600"});
});
- };
+ };
var mouseoutNode = function () {
var relatedEl = this.data("relatedElements");
- this.data("relatedNode").attr({"fill": that.defaults.color.defaultWordColor,
+ this.data("relatedNode").attr({"fill": that.defaults.color.defaultWordColor,
"font-weight": "400", "fill-opacity": 1.0});
relatedEl.targetLink.forEach(function (d) {
d.attr({"stroke": that.defaults.color.defaultLineColor, "stroke-width": 1, "stroke-opacity": 0.6});
@@ -297,7 +290,7 @@ define(function (require, exports, module) {
for (j = 0; j < nodes.length; j++) {
//若为叶子节点
- if (!nodes[j].children) {
+ if (!nodes[j].children) {
locateStr = "T" + that.defaults.radius + "," + that.defaults.radius + "R"; //使用大写T、R、S--绝对,not相对
//半径: add a padding between lines and words
@@ -332,7 +325,7 @@ define(function (require, exports, module) {
.attr("text", nodes[j].key)
//.attr("title", nodes[j].size)
.transform(locateStr)
- .attr("text-anchor", anchor)
+ .attr("text-anchor", anchor)
.attr("fill", that.defaults.color.defaultWordColor);
//获取旋转平移之前文字的bounding box
@@ -379,13 +372,13 @@ define(function (require, exports, module) {
var spline = line(l);
var sourceKey = links[i].source.key;
var targetKey = links[i].target.key;
- var tips = "link source: " + sourceKey + "\n"
+ var tips = "link source: " + sourceKey + "\n"
+ "link target: " + targetKey;
linkEl = canvas.path(spline)
//.attr("stroke", that.defaults.defaultLineColor)
.attr("stroke-opacity", 0.6)
- .attr("title", tips)
+ .attr("title", tips)
.attr("d", spline)
.attr("stroke", that.defaults.color.defaultLineColor)
.translate(that.defaults.radius, that.defaults.radius)
@@ -410,16 +403,16 @@ define(function (require, exports, module) {
}
});
- //bind text words hover event
+ //bind text words hover event
for (key in bBoxElements) {
if (bBoxElements.hasOwnProperty(key)) {
bBoxElements[key].data("relatedElements", nodeRelatedElements[key])
.mouseover(mouseoverNode)
- .mouseout(mouseoutNode);
+ .mouseout(mouseoutNode);
}
}
- };
+ };
- module.exports = Bundle;
+ return Bundle;
});