GoJS实例1
<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>GoJS实例</title>
<style>
#myDiagramDiv {
width: 400px;
height: 500px;
background-color: #DAE4E4;
}
</style>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script src="https://unpkg.com/gojs/release/go-debug.js"></script>
</head> <body>
<div id="myDiagramDiv"></div> <script>
var $ = go.GraphObject.make;
var myDiagram =
$(go.Diagram, "myDiagramDiv", {
"undoManager.isEnabled": true // 启用Ctrl-Z撤消和Ctrl-Y重做
});
var myModel = $(go.Model);
// 在模型数据中,每个节点都由一个JavaScript对象表示:
myModel.nodeDataArray = [{
key: "Alpha"
},
{
key: "Beta"
},
{
key: "Gamma"
}
];
myDiagram.model = myModel;
</script>
</body>
复制如下内容保存到空白的.html文件中,用浏览器打开即可查看效果
<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>GoJS实例</title>
<style>
#myDiagramDiv {
width: 400px;
height: 500px;
background-color: #DAE4E4;
}
</style>
<script src="https://unpkg.com/gojs/release/go-debug.js"></script>
</head> <body>
<div id="myDiagramDiv"></div> <script>
var $ = go.GraphObject.make;
var myDiagram = $(go.Diagram, "myDiagramDiv", {
"undoManager.isEnabled": true // 启用Ctrl-Z撤消和Ctrl-Y重做
});
var myModel = $(go.Model);
// 在模型数据中,每个节点都由一个JavaScript对象表示:
var nodeDataArray = [{
key: "Alpha"
},
{
key: "Beta"
},
{
key: "Gamma"
}
];
var linkDataArray = [{
from: "Alpha",
to: "Beta"
},
{
from: "Alpha",
to: "Gamma"
}
];
myModel = new go.GraphLinksModel(nodeDataArray, nodeLinkDataArray);
myDiagram.model = myModel;
</script>
</body>
复制如下内容保存到空白的.html文件中,用浏览器打开即可查看效果
<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>GoJS实例</title>
<style>
#myDiagramDiv {
width: 400px;
height: 500px;
background-color: #DAE4E4;
}
</style>
<script src="https://unpkg.com/gojs/release/go-debug.js"></script>
</head> <body>
<div id="myDiagramDiv"></div> <script>
var $ = go.GraphObject.make;
var diagram = new go.Diagram("myDiagramDiv");
diagram.nodeTemplate =
$(go.Node, "Auto",
$(go.Shape, "RoundedRectangle", {
fill: "white"
},
new go.Binding("fill", "color")), // shape.fill = data.color
$(go.TextBlock, {
margin: 20
},
new go.Binding("text", "key")) // textblock.text = data.key
); diagram.linkTemplate =
$(go.Link,
$(go.Shape,
new go.Binding("stroke", "color"), // shape.stroke = data.color
new go.Binding("strokeWidth", "thick")), // shape.strokeWidth = data.thick
$(go.Shape, {
toArrow: "OpenTriangle",
fill: null
},
new go.Binding("stroke", "color"), // shape.stroke = data.color
new go.Binding("strokeWidth", "thick")) // shape.strokeWidth = data.thick
); var nodeDataArray = [{
key: "Alpha",
color: "lightblue"
},
{
key: "Beta",
color: "pink"
}
];
var linkDataArray = [{
from: "Alpha",
to: "Beta",
color: "blue",
thick: 2
}];
diagram.model = new go.GraphLinksModel(nodeDataArray, linkDataArray);
</script>
</body>
复制如下内容保存到空白的.html文件中,用浏览器打开即可查看效果
<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>GoJS实例</title>
<style>
#myDiagramDiv {
width: 400px;
height: 500px;
background-color: #DAE4E4;
}
</style>
<script src="https://unpkg.com/gojs/release/go-debug.js"></script>
</head> <body>
<div id="myDiagramDiv"></div> <script>
var $ = go.GraphObject.make;
var diagram = new go.Diagram("myDiagramDiv");
diagram.nodeTemplate =
$(go.Node, "Auto",
new go.Binding("location", "loc"), // 从data.loc值获取Node.location
$(go.Shape, "RoundedRectangle", {
fill: "white"
},
new go.Binding("fill", "color")),
$(go.TextBlock, {
margin: 10
},
new go.Binding("text", "key"))
); var nodeDataArray = [
// 为每个节点使用Point值指定位置
{
key: "Alpha",
color: "lightblue",
loc: new go.Point(0, 0)
},
{
key: "Beta",
color: "pink",
loc: new go.Point(100, 50)
}
];
var linkDataArray = [{
from: "Alpha",
to: "Beta"
}];
diagram.model = new go.GraphLinksModel(nodeDataArray, linkDataArray);
</script>
</body>
复制如下内容保存到空白的.html文件中,用浏览器打开即可查看效果
<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>GoJS实例</title>
<style>
#myDiagramDiv {
width: 400px;
height: 500px;
background-color: #DAE4E4;
}
</style>
<script src="https://unpkg.com/gojs/release/go-debug.js"></script>
</head> <body>
<div id="myDiagramDiv"></div> <script>
var $ = go.GraphObject.make;
var diagram = new go.Diagram("myDiagramDiv");
diagram.nodeTemplate =
$(go.Node, "Auto",
new go.Binding("location", "loc", go.Point.parse), // convert string into a Point value
$(go.Shape, "RoundedRectangle", {
fill: "white"
},
new go.Binding("fill", "color")),
$(go.TextBlock, {
margin: 5
},
new go.Binding("text", "key"))
); var nodeDataArray = [{
key: "Alpha",
color: "lightblue",
loc: "0 0"
}, // note string values for location
{
key: "Beta",
color: "pink",
loc: "100 50"
}
];
var linkDataArray = [{
from: "Alpha",
to: "Beta"
}];
diagram.model = new go.GraphLinksModel(nodeDataArray, linkDataArray);
</script>
</body>
复制如下内容保存到空白的.html文件中,用浏览器打开即可查看效果
<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>GoJS实例</title>
<style>
#myDiagramDiv {
width: 400px;
height: 500px;
background-color: #DAE4E4;
}
</style>
<script src="https://unpkg.com/gojs/release/go-debug.js"></script>
</head> <body>
<div id="myDiagramDiv"></div> <script>
var $ = go.GraphObject.make;
var diagram = new go.Diagram("myDiagramDiv");
diagram.nodeTemplate =
$(go.Node, "Auto",
new go.Binding("location", "loc", go.Point.parse),
$(go.Shape, "RoundedRectangle", { // 如果data.highlight未定义,则为默认值:
fill: "yellow",
stroke: "orange",
strokeWidth: 2
},
new go.Binding("fill", "highlight", function (v) {
return v ? "pink" : "lightblue";
}),
new go.Binding("stroke", "highlight", function (v) {
return v ? "red" : "blue";
}),
new go.Binding("strokeWidth", "highlight", function (v) {
return v ? 3 : 1;
})),
$(go.TextBlock, {
margin: 10
},
new go.Binding("text", "key"))
); var nodeDataArray = [{
key: "Alpha",
loc: "0 0",
highlight: false
},
{
key: "Beta",
loc: "100 50",
highlight: true
},
{
key: "Gamma",
loc: "0 100"
} // 高亮属性未定义:使用默认值
];
var linkDataArray = [{
from: "Alpha",
to: "Beta"
}];
diagram.model = new go.GraphLinksModel(nodeDataArray, linkDataArray);
</script>
</body>
复制如下内容保存到空白的.html文件中,用浏览器打开即可查看效果
<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>GoJS实例</title>
<style>
#myDiagramDiv {
width: 400px;
height: 500px;
background-color: #DAE4E4;
}
</style>
<script src="https://unpkg.com/gojs/release/go-debug.js"></script>
</head> <body>
<div id="myDiagramDiv"></div> <script>
//为了简洁
var $ = go.GraphObject.make;
var diagram = new go.Diagram("myDiagramDiv");
diagram.nodeTemplate =
$(go.Node, "Auto", {
locationSpot: go.Spot.Center
},
$(go.Shape, "RoundedRectangle", { // default values if the data.highlight is undefined:
fill: "yellow",
stroke: "orange",
strokeWidth: 2
},
new go.Binding("fill", "highlight", function (v) {
return v ? "pink" : "lightblue";
}),
new go.Binding("stroke", "highlight", function (v) {
return v ? "red" : "blue";
}),
new go.Binding("strokeWidth", "highlight", function (v) {
return v ? 3 : 1;
})),
$(go.TextBlock, {
margin: 5
},
new go.Binding("text", "key"))
);
diagram.model.nodeDataArray = [{
key: "Alpha",
highlight: false
} // just one node, and no links
]; function flash() {
var model = diagram.model;
// all model changes should happen in a transaction
model.startTransaction("flash");
var data = model.nodeDataArray[0]; // get the first node data
model.setDataProperty(data, "highlight", !data.highlight);
model.commitTransaction("flash");
} function loop() {
//每0.5s相互转换颜色
setTimeout(function () {
flash();
loop();
}, 500);
}
loop();
</script>
</body> </html>
GoJS实例1的更多相关文章
- GoJS实例3
复制如下内容保存到空白的.html文件中,用浏览器打开即可查看效果 <!DOCTYPE html> <html> <head> <meta charset=& ...
- GoJS实例4
此示例更改链接数据的“to”属性,使链接连接到不同的节点.复制如下内容保存到空白的.html文件中,用浏览器打开即可查看效果 <!DOCTYPE html> <html> &l ...
- GoJS实例2
复制如下内容保存到空白的.html文件中,用浏览器打开即可查看效果 <!DOCTYPE html> <html> <head> <meta name=&quo ...
- GoJS最简单的实例
复制如下内容保存到空白的.html文件中,用浏览器打开即可查看效果 <!DOCTYPE html> <html> <head> <meta charset=& ...
- GoJS 友情链接
目前GoJS官网是学习gojs的最佳选择 GOJS简单示例 GoJS API学习 GoJS组织结构图2 mind map思维导图 组织结构图 GoJS实例1 GoJS实例2 GoJS实例3 GoJS实 ...
- GoJS简单示例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 最近学习工作流 推荐一个activiti 的教程文档
全文地址:http://www.mossle.com/docs/activiti/ Activiti 5.15 用户手册 Table of Contents 1. 简介 协议 下载 源码 必要的软件 ...
- JS组件系列——Gojs组件,前端图形化插件之利器
前言:之前分享过两篇关于流程画图的前端组件,使用的jsPlumb.这个组件本身还不错,使用方便.入门简单.轻量级,但是使用一段时间下来,发现一些弊病,比如组件不太稳定,初始进入页面的时候连线的样式有时 ...
- JS图形化插件利器组件系列 —— Gojs组件
阅读目录 一.组件效果预览 二.初次接触 1.Gojs简介 2.使用入门 三.综合效果 1.自定义流程的使用 2.工业流程图 四.总结 正文 前言:之前分享过两篇关于流程画图的前端组件,使用的jsPl ...
随机推荐
- 操作系统OS - 线程中的join()为什么叫join
1. 问题:很好奇为什么叫Join? 参考: https://blog.csdn.net/frankarmstrong/article/details/55504161 https://stackov ...
- DVWA靶机的命令执行漏洞
之前在打攻防世界的时候出现过类似的题目,这里再重温一下 (靶机一共低中高三个安全等级,这里只演示低中等级) (1)Security:low 根据提示让我们输入地址ping一下,之后返回以下内容,可以判 ...
- Activiti工作流学习笔记一
Activiti工作流 一:Activiti第一天 1:工作流的概念 说明: 假设:这两张图就是华谊兄弟的请假流程图 图的组成部分: 人物:范冰冰冯小刚王中军 事件(动作):请假.批准.不批准 工作流 ...
- 关于阿里云ecs服务器无法用FTP进行连接问题
背景 前两天趁机老马又搞优惠,就又撸了一台三年的ecs来折腾,后来整了半天发现ftp怎么都连接不上,以前也是撸过阿里的服务器,不过启动盘是巨硬家的系统, 最后发现虽然服务器的防火墙关了,但是老马为了安 ...
- python学习第一课
第一课: 1.不要使用来路不明的软件 2.下载杀毒软件 3.不懂技术的人在技术人面前会显得愈发无知 4.python无所不能 需要掌握的知识: 1.python基本语法 2.文件处理 3.函数 4.模 ...
- 【PAT甲级】1034 Head of a Gang (30 分)
题意: 输入两个正整数N和K(<=1000),接下来输入N行数据,每行包括两个人由三个大写字母组成的ID,以及两人通话的时间.输出团伙的个数(相互间通过电话的人数>=3),以及按照字典序输 ...
- 【PAT甲级】1029 Median (25 分)
题意: 输入一个正整数N(<=2e5),接着输入N个非递减序的长整数. 输入一个正整数N(<=2e5),接着输入N个非递减序的长整数.(重复一次) 输出两组数合并后的中位数.(200ms, ...
- 使用TortoiseGit处理代码冲突
使用TortoiseGit处理代码冲突 https://www.cnblogs.com/jason-beijing/p/5718190.html 场景一 user0 有新提交 user1 没有pu ...
- 学习不一样的vue4:mock与axios实战1
学习不一样的vue4:mock与axios实战1 发表于 2017-06-14 | 分类于 web前端| | 阅读次数 8180 首先 首发博客: 我的博客 项目源码: 源码(喜欢请star) ...
- android原始sqlite中query的复杂用法
android直接执行sql是execSQL(String sql). 这个方法可以执行任意sql语句.但是改变这个不够灵活. query这个方法可以很好的解决这个问题. 执行query查询指定的数据 ...