<!DOCTYPE html>
<html>
<head>
<title>Hello Qunee for HTML5</title>
<meta charset="utf-8">
</head>
<body>
<div style="height: 500px;" id="canvas"></div>
<script src="./qunee/qunee-min.js"></script>
<script type="text/javascript" src="./qunee/jquery.min.js"></script>
<!--<script src="http://demo.qunee.com/js/common/Overview.js"></script>-->
<script src="Overview.js"></script>
<script>
/**
* This file is part of Qunee for HTML5.
* Copyright (c) 2016 by qunee.com
**/
if (!window.getI18NString) {
getI18NString = function (s) {
return s;
}
} function FlowingSupport(graph) {
this.flowMap = {};
this.graph = graph;
} FlowingSupport.prototype = {
flowMap: null,
length: 0,
gap: 40,
graph: null,
addFlowing: function (edgeOrLine, count, byPercent) {
var flowList = this.flowMap[edgeOrLine.id];
if (!flowList) {
flowList = this.flowMap[edgeOrLine.id] = [];
this.length++;
}
count = count || 1;
while (--count >= 0) {
// 这里的图片可以自己设置flow.png
var ui = new Q.ImageUI("flow.png");
ui.layoutByPath = true;
ui.position = {x: 0, y: 0};
ui.size = {width: 20};
ui.renderColor = "#F00";
flowList.push(ui);
flowList.byPercent = byPercent;
edgeOrLine.addUI(ui);
}
},
removeFlowing: function (id) {
var flowList = this.flowMap[id];
if (!flowList) {
return;
}
var edgeOrLine = this.graph.getElement(id);
if (edgeOrLine) {
flowList.forEach(function (ui) {
edgeOrLine.removeUI(ui);
})
}
this._doRemove(id);
},
_doRemove: function (id) {
delete this.flowMap[id];
this.length--;
},
timer: null,
perStep: 10,
stop: function () {
clearTimeout(this.timer);
},
start: function () {
if (this.timer) {
clearTimeout(this.timer);
}
var offset = 0;
var scope = this;
scope.timer = setTimeout(function A() {
if (!scope.length) {
scope.timer = setTimeout(A, 2000);
offset = 0;
return;
}
offset += 1;
for (var id in scope.flowMap) {
var ui = scope.graph.getUI(id);
if (!ui) {
scope._doRemove(id);
continue;
}
var lineLength = ui.length;
if (!lineLength) {
continue;
}
var flowList = scope.flowMap[id];
if (flowList.byPercent) {
var x = offset * 2;
var gap = 15;
scope.flowMap[id].forEach(function (ui) {
ui.position = {x: (x % 100) / 100, y: 0};
x += gap;
});
} else {
var x = offset * scope.perStep;
scope.flowMap[id].forEach(function (ui) {
ui.position = {x: x % lineLength, y: 0};
x += scope.gap;
});
}
scope.graph.invalidateUI(ui); //dashed line
var data = ui.data;
if (data instanceof Q.Edge) {
if (data.getStyle(Q.Styles.EDGE_LINE_DASH)) {
data.setStyle(Q.Styles.EDGE_LINE_DASH_OFFSET, -offset);
}
} else if (data instanceof Q.ShapeNode) {
if (data.getStyle(Q.Styles.SHAPE_LINE_DASH)) {
data.setStyle(Q.Styles.SHAPE_LINE_DASH_OFFSET, -offset);
}
}
}
scope.timer = setTimeout(A, 200);
}, 200);
}
};
// 创建画布
var graph = new Q.Graph(canvas);
// 创建图元
var hello = graph.createNode("Hello", -100, -50);
var qunee = graph.createNode("Qunee", 100, 50);
// 创建关系
var edge = graph.createEdge("Hello\nQunee", hello, qunee);
// 指定关系线的颜色
edge.setStyle(Q.Styles.EDGE_COLOR, "#2898E0");
// 指定关系线是虚线,指定虚线的每一个线段的长度,和线段的数量,和虚线的距离等
edge.setStyle(Q.Styles.EDGE_LINE_DASH, [8, 4, 1, 4]);
// 指定虚线是90度的,而不是直线。
// edge.edgeType = Q.Consts.EDGE_TYPE_HORIZONTAL_VERTICAL; var flowingSupport = new FlowingSupport(graph);
// 下面的方式让关系线动起来
flowingSupport.addFlowing(edge, 3);
graph.callLater(function () {
flowingSupport.start();
}) function destroy() {
flowingSupport.stop();
} </script>
</body>
</html>

最新文章

  1. Java 单例模式详解
  2. 【CentOS】又是一篇Shell
  3. Oracle 存储过程 split 代码实现
  4. &lt;转&gt;C Runtime Library(MSVCRT)来历
  5. EOS单向N对1关联
  6. php多版本管理phpenv
  7. REDIS 在电商中的实际应用场景(转)
  8. Redis群集实现Asp.net Mvc分布式Session
  9. BC水题--The Factor(质因分解)
  10. ubuntu修改主机名称
  11. No persister for 编译器每行执行两次的解决方法
  12. hdu1569find the safest road(floyd变形求最大安全值)
  13. 全球主流8位MCU芯片详细解剖No.2:英飞凌 XC866 - 全文
  14. IOS开发之按钮控件Button详解
  15. memcache图形化管理工具MemAdmin
  16. (八)控件介绍,QLable
  17. Java canlendar task
  18. net core中动态给log4net添加日志类型
  19. React 学习之路 (一)
  20. jvm本地实战

热门文章

  1. Centos7.2 搭建emqttd集群,添加自启动服务
  2. Jenkins - Tips
  3. 感知器做二分类的原理及python实现
  4. 【Abode Air程序开发】在设备上进行安装
  5. VS开发】如何给console控制台程序更换应用程序图标
  6. js-object引用示例
  7. rocketMq消息的发送和消息消费
  8. Python之Web前端Ajax
  9. 基于hanlp的es分词插件
  10. VUE-挂载点-实例成员-数据-过滤器-文本指令-事件指令-属性指令-表单指令-01