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 ...
随机推荐
- CSS - 精灵Sprite
1. CSS精灵是一种处理网页背景图像的方式. 2. 它将一个页面涉及到的所有零星背景图像都集中到一张大图中去,然后将大图应用于网页,这样,当用户访问该页面时,只需向服务发送一次请求,网页中的背景图像 ...
- 【协作式原创】查漏补缺之Golang中mutex源码实现(预备知识)
预备知识 CAS机制 1. 是什么 参考附录3 CAS 是项乐观锁技术,当多个线程尝试使用 CAS 同时更新同一个变量时,只有其中一个线程能更新变量的值,而其它线程都失败,失败的线程并不会被挂起,而是 ...
- iOS开发架构学习记录
闲着没事看了一些iOS开发架构的视频,简单的介绍了几个常用的架构设计,现将它记录如下,以后有时间再专门写这方面的内容,大家可以看看,感兴趣的就进一步学习. 一.架构基础 1.架构设计的目的 进一步解耦 ...
- SpringBoot与Mybatis-plus整合,代码生成mvc层
一.添加pom依赖 <!-- mysql驱动 --> <dependency> <groupId>mysql</groupId> <artifac ...
- c# 分页 PaginatedList<TResult>
using System; using System.Collections.Generic; using System.Linq; namespace Microestc.PaginatedList ...
- mongodb插入性能
转自 https://blog.csdn.net/asdfsadfasdfsa/article/details/60872180 MongoDB与MySQL的插入.查询性能测试 7.1 平均 ...
- 【转】 android之如何在两个activity之间传递handler_利用broadcast广播机制
原文:http://blog.csdn.net/jason0539/article/details/18075293 这算是如何在两个activity之间传递handler的解决方案二了,解决方案一见 ...
- JS如何阻止事件冒泡
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx. ...
- jsoup教学系列
http://my.oschina.net/flashsword/blog?catalog=390084
- 「NOIP2009」Hankson的趣味题
题目描述 (由于本题是数论题,所以我只把题目大意说一下...) 输入时给定\(a_0,a_1,b_0,b_1\),题目要求你求出满足如下条件的\(x\)的个数: \[\begin{cases}\gcd ...