js画图开发库--mxgraph--[monitor-监控台.html]
<!Doctype html> <html xmlns=http://www.w3.org/1999/xhtml> <head> <meta http-equiv=Content-Type content="text/html;charset=utf-8"> <title>监控台</title> <!-- 如果本文件的包与src不是在同一个目录,就要将basepath设置到src目录下 --> <script type="text/javascript"> mxBasePath = '../src'; </script> <!-- 引入支持库文件 --> <script type="text/javascript" src="../src/js/mxClient.js"></script> <!-- 示例代码 --> <script type="text/javascript"> // 程序在此方法中启动 function main(container) { // 检查浏览器支持 if (!mxClient.isBrowserSupported()) { mxUtils.error('Browser is not supported!', 200, false); } else { // 在容器中创建图形 var graph = createGraph(container); // 创建监控图形需要的xml文件 var xml = '<mxGraphModel><root><mxCell id="0"/><mxCell id="1" parent="0"/>'+ '<mxCell id="2" value="Claim Handling Process" style="swimlane" vertex="1" parent="1"><mxGeometry x="1" width="840" height="400" as="geometry"/></mxCell>'+ '<mxCell id="3" value="Claim Manager" style="swimlane" vertex="1" parent="2"><mxGeometry x="24" width="816" height="200" as="geometry"/></mxCell>'+ '<mxCell id="5" value="" style="start" vertex="1" parent="3"><mxGeometry x="40" y="85" width="30" height="30" as="geometry"/></mxCell>'+ '<mxCell id="AuthorizeClaim" value="Authorize
Claim" vertex="1" parent="3"><mxGeometry x="90" y="80" width="100" height="40" as="geometry"/></mxCell>'+ '<mxCell id="6" value="X" style="step" vertex="1" parent="3"><mxGeometry x="210" y="85" width="30" height="30" as="geometry"/></mxCell>'+ '<mxCell id="ApproveClaim" value="Approve
Claim" vertex="1" parent="3"><mxGeometry x="260" y="80" width="100" height="40" as="geometry"/></mxCell>'+ '<mxCell id="7" value="X" style="step" vertex="1" parent="3"><mxGeometry x="380" y="85" width="30" height="30" as="geometry"/></mxCell>'+ '<mxCell id="8" value="" edge="1" parent="3" source="5" target="AuthorizeClaim"><mxGeometry relative="1" as="geometry"/></mxCell>'+ '<mxCell id="9" value="" edge="1" parent="3" source="AuthorizeClaim" target="6"><mxGeometry relative="1" as="geometry"/></mxCell>'+ '<mxCell id="10" value="" edge="1" parent="3" source="6" target="ApproveClaim"><mxGeometry relative="1" as="geometry"/></mxCell>'+ '<mxCell id="11" value="" edge="1" parent="3" source="ApproveClaim" target="7"><mxGeometry relative="1" as="geometry"/></mxCell>'+ '<mxCell id="12" value="" edge="1" parent="3" source="7" target="AuthorizeClaim"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="140" y="40"/></Array></mxGeometry></mxCell>'+ '<mxCell id="ReviewClaim" value="Review
Claim" vertex="1" parent="3"><mxGeometry x="480" y="80" width="100" height="40" as="geometry"/></mxCell>'+ '<mxCell id="22" value="X" style="step" vertex="1" parent="3"><mxGeometry x="600" y="85" width="30" height="30" as="geometry"/></mxCell>'+ '<mxCell id="23" value="" edge="1" parent="3" source="ReviewClaim" target="22"><mxGeometry relative="1" as="geometry"/></mxCell>'+ '<mxCell id="ApproveReviewedClaim" value="Approve Rev.
Claim" vertex="1" parent="3"><mxGeometry x="650" y="80" width="100" height="40" as="geometry"/></mxCell>'+ '<mxCell id="26" value="" edge="1" parent="3" source="22" target="ApproveReviewedClaim"><mxGeometry relative="1" as="geometry"/></mxCell>'+ '<mxCell id="27" value="X" style="step" vertex="1" parent="3"><mxGeometry x="770" y="85" width="30" height="30" as="geometry"/></mxCell>'+ '<mxCell id="28" value="" edge="1" target="27" parent="3" source="ApproveReviewedClaim"><mxGeometry relative="1" as="geometry"><mxPoint x="740" y="100" as="sourcePoint"/><mxPoint x="760" y="100" as="targetPoint"/></mxGeometry></mxCell>'+ '<mxCell id="32" value="" edge="1" parent="3" source="27" target="ReviewClaim"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="665" y="160"/></Array></mxGeometry></mxCell>'+ '<mxCell id="4" value="Accountant" style="swimlane" vertex="1" parent="2"><mxGeometry x="24" y="200" width="816" height="200" as="geometry"/></mxCell>'+ '<mxCell id="EnterAccountingData" value="Enter
Data" vertex="1" parent="4"><mxGeometry x="430" y="80" width="100" height="40" as="geometry"/></mxCell>'+ '<mxCell id="14" value="X" style="step" vertex="1" parent="4"><mxGeometry x="550" y="85" width="30" height="30" as="geometry"/></mxCell>'+ '<mxCell id="15" value="" edge="1" parent="4" source="EnterAccountingData" target="14"><mxGeometry relative="1" as="geometry"/></mxCell>'+ '<mxCell id="CheckAccountingData" value="Check
Data" vertex="1" parent="4"><mxGeometry x="600" y="80" width="100" height="40" as="geometry"/></mxCell>'+ '<mxCell id="16" value="" edge="1" parent="4" source="14" target="CheckAccountingData"><mxGeometry relative="1" as="geometry"/></mxCell>'+ '<mxCell id="17" value="X" style="step" vertex="1" parent="4"><mxGeometry x="720" y="85" width="30" height="30" as="geometry"/></mxCell>'+ '<mxCell id="18" value="" edge="1" parent="4" source="CheckAccountingData" target="17"><mxGeometry relative="1" as="geometry"/></mxCell>'+ '<mxCell id="19" value="" style="end" vertex="1" parent="4"><mxGeometry x="770" y="85" width="30" height="30" as="geometry"/></mxCell>'+ '<mxCell id="20" value="" edge="1" parent="4" source="17" target="19"><mxGeometry relative="1" as="geometry"/></mxCell>'+ '<mxCell id="31" value="" edge="1" parent="4" source="17" target="EnterAccountingData"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="625" y="160"/></Array></mxGeometry></mxCell>'+ '<mxCell id="13" value="" edge="1" parent="2" source="7" target="EnterAccountingData"><mxGeometry relative="1" as="geometry"/></mxCell>'+ '<mxCell id="24" value="" edge="1" parent="2" source="14" target="ReviewClaim" style="edgeStyle=none"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="589" y="180"/><mxPoint x="480" y="180"/><mxPoint x="480" y="100"/></Array></mxGeometry></mxCell>'+ '<mxCell id="29" value="" edge="1" parent="2" source="22" target="EnterAccountingData"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="469" y="40"/></Array></mxGeometry></mxCell>'+ '<mxCell id="30" value="" edge="1" parent="2" source="27" target="EnterAccountingData"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="469" y="40"/></Array></mxGeometry></mxCell>'+ '<mxCell id="33" value="" edge="1" parent="2" source="6" target="EnterAccountingData"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="249" y="200"/></Array></mxGeometry></mxCell>'+ '</root></mxGraphModel>'; var doc = mxUtils.parseXml(xml); var codec = new mxCodec(doc); codec.decode(doc.documentElement, graph.getModel()); } // 创建更新按钮 document.body.appendChild(mxUtils.button('Update', function(evt) { //XML通常是根据URL在服务器端使用mxUtils.get这个方法获得的结果,这只是一个测试例子 var xml = '<process><update id="ApproveClaim" state="'+getState()+'"/><update id="AuthorizeClaim" state="'+getState()+'"/>'+ '<update id="CheckAccountingData" state="'+getState()+'"/><update id="ReviewClaim" state="'+getState()+'"/>'+ '<update id="ApproveReviewedClaim" state="'+getState()+'"/><update id="EnterAccountingData" state="'+getState()+'"/></process>'; update(graph, xml); })); }; /** * 使用XML数据更新监控图 */ function update(graph, xml) { if (xml != null && xml.length > 0) { var doc = mxUtils.parseXml(xml); if (doc != null && doc.documentElement != null) { var model = graph.getModel(); var nodes = doc.documentElement.getElementsByTagName('update'); if (nodes != null && nodes.length > 0) { model.beginUpdate(); try { for (var i = 0; i < nodes.length; i++) { // 处理活动的节点 var id = nodes[i].getAttribute('id'); var state = nodes[i].getAttribute('state'); // 从图形中获取活动元素的名称 var cell = model.getCell(id); // 更新单元格颜色,并添加了一些提示信息 if (cell != null) { // 重新设置填充色 graph.setCellStyles(mxConstants.STYLE_FILLCOLOR, 'white', [cell]); graph.removeCellOverlays(cell); // 更改元素颜色状态 if (state == 'Running') { graph.setCellStyles(mxConstants.STYLE_FILLCOLOR, '#2DFF2C', [cell]); } else if (state == 'Waiting') { graph.setCellStyles(mxConstants.STYLE_FILLCOLOR, '#FFAF1B', [cell]); } else if (state == 'Completed') { graph.setCellStyles(mxConstants.STYLE_FILLCOLOR, '#FFFF10', [cell]); } // 将使用图标的提示信息 if (state != 'Init') { // 设置图形中的单元格 graph.addCellOverlay(cell, createOverlay(graph.warningImage, 'State: '+state)); } } } // for } finally { model.endUpdate(); } } } } }; /** * 创建一个覆盖对象,使用给定的提示图表和提示文本。 */ function createOverlay(image, tooltip) { var overlay = new mxCellOverlay(image, tooltip); // Installs a handler for clicks on the overlay overlay.addListener(mxEvent.CLICK, function(sender, evt) { mxUtils.alert(tooltip+'\n'+'Last update: '+new Date()); }); return overlay; }; /** * 在给定的容器中创建并返回一个空图。 */ function createGraph(container) { var graph = new mxGraph(container); graph.setTooltips(true); graph.setEnabled(false); // 禁止折叠 graph.isCellFoldable = function(cell, collapse) { return false; }; // 创建处理时的样式 var style = graph.getStylesheet().getDefaultVertexStyle(); style[mxConstants.STYLE_FONTSIZE] = '12'; style[mxConstants.STYLE_FONTCOLOR] = 'black'; style[mxConstants.STYLE_STROKECOLOR] = 'black'; style[mxConstants.STYLE_FILLCOLOR] = 'white'; style[mxConstants.STYLE_GRADIENTCOLOR] = 'white'; style[mxConstants.STYLE_GRADIENT_DIRECTION] = mxConstants.DIRECTION_EAST; style[mxConstants.STYLE_ROUNDED] = true; style[mxConstants.STYLE_SHADOW] = true; style[mxConstants.STYLE_FONTSTYLE] = 1; style = graph.getStylesheet().getDefaultEdgeStyle(); style[mxConstants.STYLE_EDGE] = mxEdgeStyle.ElbowConnector; style[mxConstants.STYLE_STROKECOLOR] = 'black'; style[mxConstants.STYLE_ROUNDED] = true; style = []; style[mxConstants.STYLE_SHAPE] = mxConstants.SHAPE_SWIMLANE; style[mxConstants.STYLE_PERIMETER] = mxPerimeter.RectanglePerimeter; style[mxConstants.STYLE_STROKECOLOR] = 'gray'; style[mxConstants.STYLE_FONTCOLOR] = 'black'; style[mxConstants.STYLE_FILLCOLOR] = '#E0E0DF'; style[mxConstants.STYLE_GRADIENTCOLOR] = 'white'; style[mxConstants.STYLE_ALIGN] = mxConstants.ALIGN_CENTER; style[mxConstants.STYLE_VERTICAL_ALIGN] = mxConstants.ALIGN_TOP; style[mxConstants.STYLE_STARTSIZE] = 24; style[mxConstants.STYLE_FONTSIZE] = '12'; style[mxConstants.STYLE_FONTSTYLE] = 1; style[mxConstants.STYLE_HORIZONTAL] = false; graph.getStylesheet().putCellStyle('swimlane', style); style = []; style[mxConstants.STYLE_SHAPE] = mxConstants.SHAPE_RHOMBUS; style[mxConstants.STYLE_PERIMETER] = mxPerimeter.RhombusPerimeter; style[mxConstants.STYLE_STROKECOLOR] = 'gray'; style[mxConstants.STYLE_FONTCOLOR] = 'gray'; style[mxConstants.STYLE_FILLCOLOR] = '#91BCC0'; style[mxConstants.STYLE_GRADIENTCOLOR] = 'white'; style[mxConstants.STYLE_ALIGN] = mxConstants.ALIGN_CENTER; style[mxConstants.STYLE_VERTICAL_ALIGN] = mxConstants.ALIGN_MIDDLE; style[mxConstants.STYLE_FONTSIZE] = '14'; graph.getStylesheet().putCellStyle('step', style); style = []; style[mxConstants.STYLE_SHAPE] = mxConstants.SHAPE_ELLIPSE; style[mxConstants.STYLE_PERIMETER] = mxPerimeter.EllipsePerimeter; style[mxConstants.STYLE_STROKECOLOR] = 'gray'; style[mxConstants.STYLE_FONTCOLOR] = 'gray'; style[mxConstants.STYLE_FILLCOLOR] = '#A0C88F'; style[mxConstants.STYLE_GRADIENTCOLOR] = 'white'; style[mxConstants.STYLE_ALIGN] = mxConstants.ALIGN_CENTER; style[mxConstants.STYLE_VERTICAL_ALIGN] = mxConstants.ALIGN_MIDDLE; style[mxConstants.STYLE_FONTSIZE] = '14'; graph.getStylesheet().putCellStyle('start', style); style = mxUtils.clone(style); style[mxConstants.STYLE_FILLCOLOR] = '#DACCBC'; style[mxConstants.STYLE_STROKECOLOR] = '#AF7F73'; style[mxConstants.STYLE_STROKEWIDTH] = 3; graph.getStylesheet().putCellStyle('end', style); return graph; }; /** * 返回一个随机的状态。 */ function getState() { var state = 'Init'; var rnd = Math.random() * 4; if (rnd > 3) { state = 'Completed'; } else if (rnd > 2) { state = 'Running'; } else if (rnd > 1) { state = 'Waiting'; } return state; }; </script> </head> <!-- 页面载入时启动程序 --> <body onload="main(document.getElementById('graphContainer'));"> <!-- 创建一个容器 --> <div id="graphContainer" style="overflow:hidden;position:relative;width:861px;height:406px;cursor:default;"> </div> <br> </body> </html>
相关推荐
MXGRAPH..MXGRAPH..MXGRAPH..MXGRAPH..MXGRAPH..MXGRAPH..MXGRAPH..MXGRAPH..MXGRAPH..
资源:mxGraph;包含ie,Firefox两个版本;版本号都是1.4.0.0;只带了一个Hello World的示例,其他的例子请自己去官网找吧
mxgraph开发包
NULL 博文链接:https://chwshuang.iteye.com/blog/1797168
mxGraph里头包含源码,以及常用的一些实例,相关介绍可以查阅博客:http://www.cnblogs.com/shawWey/p/7115124.html
mxgraph.js中文文档是一个官方的api,翻译来源于sunflower(github: https://github.com/SunInfoFE),提供给更多的开发者参考和共享源码资源!
这个插件支持在HTML页面中插入流程图,画得很漂亮 :-)
带Webpack的typed-mxgraph演示 来自Webpack Typescript入门 如何使用 在本地克隆项目 git clone https://github.com/typed-mxgraph/typed-mxgraph-demo.git 切换到项目目录 cd typed-mxgraph-demo 确保使用节点10...
Based on the latest web technologies, mxGraph is the ultimate component for drawing diagrams in a browser. Using open standards, mxGraph does not depend on any third-party plugins and proprietary ...
mxGraph1.8.0.3破解版mxclient,分IE ,FF 和chrome三个部分,不同浏览器加载不同的js文件,手动尝试过,1.8.0.5官方的例子都可以正常运行。
mxGraph 是一个 JS 绘图组件适用于需要在网页中设计/编辑 Workflow/BPM 流 程图、图表、网络图和普通图形的 Web 应用程序。mxgraph 下载包中包括用 javescript 写的前端程序,也包括多个和后端程序(java/C#等等)...
web开发拓扑图插件 mxGraph - An open source JavaScript diagramming component, started in 2005, that works on all major browsers, including touch devices.
十分强大的js绘图工具,适用于设计/编辑 Workflow/BPM 流程图、图表、网络图和普通图形的 Web 应用程序。这是破解过的源js库。
mxGraph 简单易用,只需要在HTML文件中加入JavaScript链接,就可立即使用最简洁最强大的基于浏览器自身的绘图工具。 HTML 5和全系列IE支持。 想像一下,整个应用都是基于Web。在浏览器中设计工作流,操纵有背景图...
mxgraph-svg2shape 一套将SVG文件转换为mxGraph资源的工具。 该存储库基于: SVG to XML mxGraph stencil definition translation tool. ... 添加 :将XML mxGraph模具定义转换为一组相应JavaScript /
在线画图www.draw.io网站的源码,基于mxGraph开发
前段实现mxgraph插件绘制流程图,后台实现保存的xml导出成图片格式,遇到图标没有引用,文字label位置不正确,label换行不识别 标签,linux服务器部署中文字体等问题
mxgraph-1_10_4_0 官方源码+文档+示例
mxgraph-demo-源码.rar
vue配合mxGraph 入门实例项目,