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 ...
随机推荐
- 爬虫(十四):Scrapy框架(一) 初识Scrapy、第一个案例
1. Scrapy框架 Scrapy功能非常强大,爬取效率高,相关扩展组件多,可配置和可扩展程度非常高,它几乎可以应对所有反爬网站,是目前Python中使用最广泛的爬虫框架. 1.1 Scrapy介绍 ...
- Navicat Premium 12安装及激活
一.安装 百度云下载地址:https://pan.baidu.com/s/1T5BjpBqLtwCy26szcKSdKw 提取码:ujzx 二.激活步骤 ①将navicat-keygen-for-x6 ...
- VB.NET中Sub和Function的区别
function是函数,sub是子程序,都可以传递参数,但函数有返回值,子程序没有 function 可以用自身名字返回一个值,sub 需定义别的变量,用传址方式传回值. Sub 过程与Functio ...
- nginx 的请求处理阶段
nginx处理的11个阶段 nginx处理用户请求的流程 接收用户请求头部之后 1 .匹配对应得location 2.是否进行限速 3.验证用户是否有权限访问该资源:和判断是否是盗链的请求 4.生成用 ...
- day4-2数组及方法
数组: Js数组 可以存放任意数据类型的数据 如果索引大于数组的长度,数组自动增加到该索引值加1的长度 var arr = ["terry","larry",& ...
- A - Bi-shoe and Phi-shoe 素数打表
A - Bi-shoe and Phi-shoe Bamboo Pole-vault is a massively popular sport in Xzhiland. And Master Phi- ...
- docker-compose 快速部署持续集成测试环境 Gitlab+Harbor+Jenkins pipeline 实现 tag run docker Images
环境 测试部署主机IP:192.168.1.1 Jenkins主机IP:192.168.1.2 Harbor主机IP:192.168.1.3 Gitlab主机IP:192.168.0.10 系统信息: ...
- android原始sqlite中query的复杂用法
android直接执行sql是execSQL(String sql). 这个方法可以执行任意sql语句.但是改变这个不够灵活. query这个方法可以很好的解决这个问题. 执行query查询指定的数据 ...
- 什么是Device ID?
Android ID用于唯一识别一部设备的一次刷机行为,虽然不能完全确定该设备的唯一性(真的唯一性是用IMEI号的),但是可以很大程度上过滤重复设备.这是移动互联网广告行业的基础,尤其是CPI广告,设 ...
- 任意promise串行执行算法 - 童彪
// 任意promise串行执行算法 - 童彪 function runAllPromise() { var p1 = new Promise((resove, reject) => { s ...