提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:黄竹雯|2018-12-05 11:37:46.000|阅读 633 次
概述:轻量级流程图控件GoJS 比赛示例
# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>
相关链接:
GoJS是一款功能强大,快速且轻量级的流程图控件,可帮助你在JavaScript 和 HTML5 Canvas程序中创建流程图,且极大地简化你的JavaScript / Canvas 程序。本文主要演示一个比赛流程图。
单击名称旁边的空白分数框可以填写每个玩家的分数。分数必须是非负数,最多3位数。使用TextEditingTool.textValidation函数来验证分数。当“游戏”中的两个玩家获得分数时,分数更高的玩家将自动进入到下一轮的比赛。
比如Bardle得分90,Edwards得分80,那么当你输入两个玩家的分数后,Bardle会自动进入下一轮比赛,对手是Moran。
在页面中查看此示例页面的源代码
function init() { if (window.goSamples) goSamples(); // init for these samples -- you don't need to call this var $ = go.GraphObject.make; // for conciseness in defining templates myDiagram = $(go.Diagram, "myDiagramDiv", // create a Diagram for the DIV HTML element { "textEditingTool.starting": go.TextEditingTool.SingleClick, "textEditingTool.textValidation": isValidScore, layout: $(go.TreeLayout, { angle: 180 }), "undoManager.isEnabled": true }); // validation function for editing text function isValidScore(textblock, oldstr, newstr) { if (newstr === "") return true; var num = parseInt(newstr, 10); return !isNaN(num) && num >= 0 && num < 1000; } // define a simple Node template myDiagram.nodeTemplate = $(go.Node, "Auto", { selectable: false }, $(go.Shape, "Rectangle", { fill: '#8C8C8C', stroke: null }, // Shape.fill is bound to Node.data.color new go.Binding("fill", "color")), $(go.Panel, "Table", $(go.RowColumnDefinition, { column: 0, separatorStroke: "black" }), $(go.RowColumnDefinition, { column: 1, separatorStroke: "black", background: "#BABABA" }), $(go.RowColumnDefinition, { row: 0, separatorStroke: "black" }), $(go.RowColumnDefinition, { row: 1, separatorStroke: "black" }), $(go.TextBlock, "", { row: 0, wrap: go.TextBlock.None, margin: 5, width: 90, isMultiline: false, textAlign: 'left', font: '10pt Segoe UI,sans-serif', stroke: 'white' }, new go.Binding("text", "player1").makeTwoWay()), $(go.TextBlock, "", { row: 1, wrap: go.TextBlock.None, margin: 5, width: 90, isMultiline: false, textAlign: 'left', font: '10pt Segoe UI,sans-serif', stroke: 'white' }, new go.Binding("text", "player2").makeTwoWay()), $(go.TextBlock, "", { column: 1, row: 0, wrap: go.TextBlock.None, margin: 2, width: 25, isMultiline: false, editable: true, textAlign: 'center', font: '10pt Segoe UI,sans-serif', stroke: 'black' }, new go.Binding("text", "score1").makeTwoWay()), $(go.TextBlock, "", { column: 1, row: 1, wrap: go.TextBlock.None, margin: 2, width: 25, isMultiline: false, editable: true, textAlign: 'center', font: '10pt Segoe UI,sans-serif', stroke: 'black' }, new go.Binding("text", "score2").makeTwoWay()) ) ); // define the Link template myDiagram.linkTemplate = $(go.Link, { routing: go.Link.Orthogonal, selectable: false }, $(go.Shape, { strokeWidth: 2, stroke: 'white' })); // Generates the original graph from an array of player names function createPairs(players) { if (players.length % 2 !== 0) players.push('(empty)'); var startingGroups = players.length / 2; var currentLevel = Math.ceil(Math.log(startingGroups) / Math.log(2)); var levelGroups = []; var currentLevel = Math.ceil(Math.log(startingGroups) / Math.log(2)); for (var i = 0; i < startingGroups; i++) { levelGroups.push(currentLevel + '-' + i); } var totalGroups = []; makeLevel(levelGroups, currentLevel, totalGroups, players); return totalGroups; } function makeLevel(levelGroups, currentLevel, totalGroups, players) { currentLevel--; var len = levelGroups.length; var parentKeys = []; var parentNumber = 0; var p = ''; for (var i = 0; i < len; i++) { if (parentNumber === 0) { p = currentLevel + '-' + parentKeys.length; parentKeys.push(p); } if (players !== null) { var p1 = players[i*2]; var p2 = players[(i*2) + 1]; totalGroups.push({ key: levelGroups[i], parent: p, player1: p1, player2: p2, parentNumber: parentNumber }); } else { totalGroups.push({ key: levelGroups[i], parent: p, parentNumber: parentNumber }); } parentNumber++; if (parentNumber > 1) parentNumber = 0; } // after the first created level there are no player names if (currentLevel >= 0) makeLevel(parentKeys, currentLevel, totalGroups, null) } function makeModel(players) { var model = new go.TreeModel(createPairs(players)); model.addChangedListener(function(e) { if (e.propertyName !== 'score1' && e.propertyName !== 'score2') return; var data = e.object; if (isNaN(data.score1) || isNaN(data.score2)) return; // TODO: What happens if score1 and score2 are the same number? // both score1 and score2 are numbers, // set the name of the higher-score'd player in the advancing (parent) node // if the data.parentNumber is 0, then we set player1 on the parent // if the data.parentNumber is 1, then we set player2 var parent = myDiagram.findNodeForKey(data.parent); if (parent === null) return; var playerName = parseInt(data.score1) > parseInt(data.score2) ? data.player1 : data.player2; if (parseInt(data.score1) === parseInt(data.score2)) playerName = ""; myDiagram.model.setDataProperty(parent.data, (data.parentNumber === 0 ? "player1" : "player2"), playerName); }); myDiagram.model = model; // provide initial scores for at most three pairings for (var i = 0; i < Math.min(3, model.nodeDataArray.length); i++) { var d = model.nodeDataArray[i]; if (d.player1 && d.player2) { // TODO: doesn't prevent tie scores model.setDataProperty(d, "score1", Math.floor(Math.random() * 100)); model.setDataProperty(d, "score2", Math.floor(Math.random() * 100)); } } } makeModel(['Adler', 'Pollock', 'Montgomery', 'Lestrade', 'Wilson', 'Moran', 'Bardle', 'Edwards']); } // end init <div id="sample"> <!-- The DIV for the Diagram needs an explicit size or else we won't see anything. Also add a border to help see the edges. --> <div id="myDiagramDiv" style="border: solid 1px black; background: #4D4D4D; width:700px; height:600px"></div> <p> Click on the empty score boxes next to names to fill in scores for each player. The scores must be non-negative numbers with at most 3 digits. Scores are validated using a <a>TextEditingTool.textValidation</a> function. When two players in a "game" have a score, one of them will automatically advance to the next round of the bracket. </p> </div>
想在GitHub上查看此示例页面的源代码,可。
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@cahobeh.cn
本文探讨 SQL Server 中 NULL 和空值之间的区别,并讨论如何有效地处理它们。
Unity 是一款功能极其丰富的游戏引擎,允许开发人员将各种媒体集成到他们的项目中。但是,它缺少最令人兴奋的功能之一 - 将 Web 内容(例如 HTML、CSS 和 JavaScript)直接渲染到 3D 场景中的纹理上的能力。在本文中,我们将介绍如何使用 DotNetBrowser 在 Unity3D 中将 Web 内容渲染为纹理。
DevExpress v24.2帮助文档正式发布上线了,请按版本按需下载~
本教程将向您展示如何用MyEclipse构建一个Web项目,欢迎下载最新版IDE体验!
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@cahobeh.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢