<!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 = new mxGraph(container); // 禁止折叠图标 graph.isCellFoldable = function(cell) { return false; } var secondLabelVisible = true; // 返回对于一个给定单元格的编号 graph.getSecondLabel = function(cell) { if (!this.model.isEdge(cell)) { // 可能返回一个字符串 return "ID="+cell.id; } return null; }; var relativeChildVerticesVisible = true; // 隐藏相对于子元素的顶点 graph.isCellVisible = function(cell) { return !this.model.isVertex(cell) || cell.geometry == null || !cell.geometry.relative || cell.geometry.relative == relativeChildVerticesVisible; }; // 在图形中根据模型编号创建模型 var createShape = graph.cellRenderer.createShape; graph.cellRenderer.createShape = function(state) { createShape.apply(this, arguments); if (secondLabelVisible && !state.cell.geometry.relative) { var secondLabel = graph.getSecondLabel(state.cell); if (secondLabel != null && state.shape != null && state.secondLabel == null) { state.secondLabel = new mxText(secondLabel, new mxRectangle(), mxConstants.ALIGN_LEFT, mxConstants.ALIGN_BOTTOM); // 标签的样式 state.secondLabel.color = 'black'; state.secondLabel.family = 'Verdana'; state.secondLabel.size = 8; state.secondLabel.fontStyle = mxConstants.FONT_ITALIC; state.secondLabel.background = 'yellow'; state.secondLabel.border = 'black'; state.secondLabel.dialect = state.shape.dialect; state.secondLabel.init(state.view.getDrawPane()); } } }; // 移动/调整大小已被重新绘制的元素 var redraw = graph.cellRenderer.redraw; graph.cellRenderer.redraw = function(state) { redraw.apply(this, arguments); if (state.shape != null && state.secondLabel != null) { var scale = graph.getView().getScale(); var bounds = new mxRectangle(state.x + state.width - 8 * scale, state.y + 8 * scale, 0, 0); state.secondLabel.value = graph.getSecondLabel(state.cell); state.secondLabel.scale = scale; state.secondLabel.bounds = bounds; state.secondLabel.redraw(); } }; // 销毁图形编号 var destroy = graph.cellRenderer.destroy; graph.cellRenderer.destroy = function(state) { destroy.apply(this, arguments); if (state.secondLabel != null) { state.secondLabel.destroy(); state.secondLabel = null; } }; // 创建默认窗口 var parent = graph.getDefaultParent(); // 开启更新事务 graph.getModel().beginUpdate(); try { var v1 = graph.insertVertex(parent, null, 'Hello,', 30, 20, 80, 30); // 创建子元素 var v11 = graph.insertVertex(v1, null, 'World', 1, 1, 0, 0, 'align=left;verticalAlign=top;labelBackgroundColor=red;labelBorderColor=black', true); v11.geometry.offset = new mxPoint(-8, -8); var v2 = graph.insertVertex(parent, null, 'World!', 200, 150, 80, 30); // 创建子元素 var v21 = graph.insertVertex(v2, null, 'World', 1, 1, 0, 0, 'align=left;verticalAlign=top;fillColor=red;rounded=1;spacingLeft=4;spacingRight=4', true); v21.geometry.offset = new mxPoint(-8, -8); graph.updateCellSize(v21); var e1 = graph.insertEdge(parent, null, '', v1, v2); } finally { // 结束更新事务 graph.getModel().endUpdate(); } // 添加切换子元素按钮 document.body.insertBefore(mxUtils.button('切换到子元素Toggle Child Vertices', function(evt) { relativeChildVerticesVisible = !relativeChildVerticesVisible; graph.refresh(); } ), document.body.firstChild); // 添加切换编号按钮 document.body.insertBefore(mxUtils.button('切换到编号Toggle IDs', function(evt) { secondLabelVisible = !secondLabelVisible; graph.refresh(); } ), document.body.firstChild); } }; </script> </head> <!-- 页面载入时启动程序 --> <body onload="main(document.getElementById('graphContainer'))"> <!-- 创建一个带网格壁纸的容器 --> <div id="graphContainer" style="overflow:hidden;width:321px;height:241px;background:url('editors/images/grid.gif')"> </div> </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
这个插件支持在HTML页面中插入流程图,画得很漂亮 :-)
带Webpack的typed-mxgraph演示 来自Webpack Typescript入门 如何使用 在本地克隆项目 git clone https://github.com/typed-mxgraph/typed-mxgraph-demo.git 切换到项目目录 cd typed-mxgraph-demo 确保使用节点10...
mxGraph1.8.0.3破解版mxclient,分IE ,FF 和chrome三个部分,不同浏览器加载不同的js文件,手动尝试过,1.8.0.5官方的例子都可以正常运行。
mxGraph 简单易用,只需要在HTML文件中加入JavaScript链接,就可立即使用最简洁最强大的基于浏览器自身的绘图工具。 HTML 5和全系列IE支持。 想像一下,整个应用都是基于Web。在浏览器中设计工作流,操纵有背景图...
web开发拓扑图插件 mxGraph - An open source JavaScript diagramming component, started in 2005, that works on all major browsers, including touch devices.
mxgraph-svg2shape 一套将SVG文件转换为mxGraph资源的工具。 该存储库基于: SVG to XML mxGraph stencil definition translation tool. ... 添加 :将XML mxGraph模具定义转换为一组相应JavaScript /
前段实现mxgraph插件绘制流程图,后台实现保存的xml导出成图片格式,遇到图标没有引用,文字label位置不正确,label换行不识别 标签,linux服务器部署中文字体等问题
mxgraph-1_10_4_0 官方源码+文档+示例
mxgraph-demo-源码.rar
vue配合mxGraph 入门实例项目,
在线画图www.draw.io网站的源码,基于mxGraph开发
mxGraph1.9.1.1 mxclient.js破解文件下载 1.找到mxclient.js文件中的这句代码 注释 if ((eval('/156/145/167/40/104/141/164/145/50/51/56/147/145/164/124/151/155/145/50/51') / 1000) - 1270532723 >...
mxgraph-typescript-定义mxgraph库的打字稿定义。 有人需要吗? 对此加注星标或给我发电子邮件进行协作。 为模块定义的定义等于官方api文档的软件包: : - Each class has its "declare class mxEvent {}"- ...
十分强大的js绘图工具,适用于设计/编辑 Workflow/BPM 流程图、图表、网络图和普通图形的 Web 应用程序。这是破解过的源js库。
本demo是运用mxgraph.js 和node api 读取xml文件,并解析出来显示,业务上常用这个画流程图和topo状态图;主要适用于,现在的图形可视化操作