graph使泳道图的label横向显示
1、如果需要将label靠左边对齐,则必须重写底层源码
新增mxText的一个构造器,主要是增加了一个参数:x(代表当前的cell)
function mxText(a, b, c, d, e, f, g, h, k, i, l, m, n, o, p, q, t, u, v, w, x) {
this.value = a;
this.bounds = b;
this.color = e != null ? e : "black";
this.align = c != null ? c : "";
this.valign = d != null ? d : "";
this.family = f != null ? f : mxConstants.DEFAULT_FONTFAMILY;
this.size = g != null ? g : mxConstants.DEFAULT_FONTSIZE;
this.fontStyle = h != null ? h : 0;
this.spacing = 0;
this.spacingTop = 0;
//this.spacingRight = x.cell.geometry.height/2 - (this.size * 1.25 * a.length);
this.spacingRight = 0;
this.spacingBottom = 0;
this.spacingLeft = 0;
this.horizontal = true;
this.background = p;
this.border = q;
this.wrap = t != null ? t : false;
this.clipped = u != null ? u : false;
this.overflow = v != null ? v : "visible";
this.labelPadding = w != null ? w : 0
}
重写createTabel方法
mxCellRenderer.prototype.createLabel = function(a, b) {
var c = a.view.graph;
c.getModel().isEdge(a.cell);
if (a.style[mxConstants.STYLE_FONTSIZE] > 0 || a.style[mxConstants.STYLE_FONTSIZE] == null) {
var d = (c.isHtmlLabel(a.cell) || b != null && mxUtils.isNode(b)) && c.dialect == mxConstants.DIALECT_SVG;
//alert(a.cell.value + '-' + b);
//dongyj add :其中b=a.cell.value
if (!a.cell.id && a.cell.id.indexOf("_swimlane") >= 0 && b) {
a.text = new mxText(b, new mxRectangle, a.style[mxConstants.STYLE_ALIGN] || mxConstants.ALIGN_CENTER, c.getVerticalAlign(a), a.style[mxConstants.STYLE_FONTCOLOR], a.style[mxConstants.STYLE_FONTFAMILY], a.style[mxConstants.STYLE_FONTSIZE],
a.style[mxConstants.STYLE_FONTSTYLE], a.style[mxConstants.STYLE_SPACING], a.style[mxConstants.STYLE_SPACING_TOP], a.style[mxConstants.STYLE_SPACING_RIGHT], a.style[mxConstants.STYLE_SPACING_BOTTOM], a.style[mxConstants.STYLE_SPACING_LEFT], a.style[mxConstants.STYLE_HORIZONTAL], a.style[mxConstants.STYLE_LABEL_BACKGROUNDCOLOR], a.style[mxConstants.STYLE_LABEL_BORDERCOLOR], c.isWrapping(a.cell) && c.isHtmlLabel(a.cell), c.isLabelClipped(a.cell), a.style[mxConstants.STYLE_OVERFLOW], a.style[mxConstants.STYLE_LABEL_PADDING], a);
} else {
//alert(a.cell.geometry.width);
//a.cell.geometry.height; a.text = new mxText(b, new mxRectangle, a.style[mxConstants.STYLE_ALIGN] || mxConstants.ALIGN_CENTER, c.getVerticalAlign(a), a.style[mxConstants.STYLE_FONTCOLOR], a.style[mxConstants.STYLE_FONTFAMILY], a.style[mxConstants.STYLE_FONTSIZE],
a.style[mxConstants.STYLE_FONTSTYLE], a.style[mxConstants.STYLE_SPACING], a.style[mxConstants.STYLE_SPACING_TOP], a.style[mxConstants.STYLE_SPACING_RIGHT], a.style[mxConstants.STYLE_SPACING_BOTTOM], a.style[mxConstants.STYLE_SPACING_LEFT], a.style[mxConstants.STYLE_HORIZONTAL], a.style[mxConstants.STYLE_LABEL_BACKGROUNDCOLOR], a.style[mxConstants.STYLE_LABEL_BORDERCOLOR], c.isWrapping(a.cell) && c.isHtmlLabel(a.cell), c.isLabelClipped(a.cell), a.style[mxConstants.STYLE_OVERFLOW], a.style[mxConstants.STYLE_LABEL_PADDING], a);
}
a.text.opacity = a.style[mxConstants.STYLE_TEXT_OPACITY];
a.text.dialect = d ? mxConstants.DIALECT_STRICTHTML : a.view.graph.dialect;
this.initializeLabel(a);
var e = false,
f = function(b) {
var d = a;
if (mxClient.IS_TOUCH || e) {
d = mxEvent.getClientX(b);
b = mxEvent.getClientY(b);
b = mxUtils.convertPoint(c.container, d, b);
d = c.view.getState(c.getCellAt(b.x, b.y))
}
return d
},
d = mxClient.IS_TOUCH ? "touchmove" : "mousemove",
g = mxClient.IS_TOUCH ? "touchend" : "mouseup";
mxEvent.addListener(a.text.node, mxClient.IS_TOUCH ? "touchstart" : "mousedown", mxUtils.bind(this, function(b) {
if (this.isLabelEvent(a, b)) {
c.fireMouseEvent(mxEvent.MOUSE_DOWN, new mxMouseEvent(b, a));
e = c.dialect != mxConstants.DIALECT_SVG && mxEvent.getSource(b).nodeName == "IMG"
}
}));
mxEvent.addListener(a.text.node, d, mxUtils.bind(this, function(b) {
this.isLabelEvent(a, b) && c.fireMouseEvent(mxEvent.MOUSE_MOVE, new mxMouseEvent(b, f(b)))
}));
mxEvent.addListener(a.text.node, g, mxUtils.bind(this, function(b) {
if (this.isLabelEvent(a, b)) {
c.fireMouseEvent(mxEvent.MOUSE_UP, new mxMouseEvent(b, f(b)));
e = false
}
}));
mxEvent.addListener(a.text.node, "dblclick", mxUtils.bind(this, function(b) {
if (this.isLabelEvent(a, b)) {
c.dblClick(b, a.cell);
mxEvent.consume(b)
}
}))
}
};
如果要求泳道的label居中,则不需要重写底层方法,只需要重写createLabel方法即可
mxCellRenderer.prototype.createLabel = function(a, b) {
var c = a.view.graph;
c.getModel().isEdge(a.cell);
if (a.style[mxConstants.STYLE_FONTSIZE] > 0 || a.style[mxConstants.STYLE_FONTSIZE] == null) {
var d = (c.isHtmlLabel(a.cell) || b != null && mxUtils.isNode(b)) && c.dialect == mxConstants.DIALECT_SVG; /*****************泳道图样式修改start*******************/ var tempSwinlaneHorizontal = a.style[mxConstants.STYLE_HORIZONTAL];
if(c.isSwimlane(a.cell)){
tempsHorizontal = true;
} var tempSwinlaneVertical = c.getVerticalAlign(a);
if(c.isSwimlane(a.cell)){
tempSwinlaneVertical = 'middle';
}
/*****************泳道图样式修改end*******************/ a.text = new mxText(b, new mxRectangle, a.style[mxConstants.STYLE_ALIGN] || mxConstants.ALIGN_CENTER, tempSwinlaneVertical, a.style[mxConstants.STYLE_FONTCOLOR], a.style[mxConstants.STYLE_FONTFAMILY], a.style[mxConstants.STYLE_FONTSIZE],
a.style[mxConstants.STYLE_FONTSTYLE], a.style[mxConstants.STYLE_SPACING], a.style[mxConstants.STYLE_SPACING_TOP], a.style[mxConstants.STYLE_SPACING_RIGHT], a.style[mxConstants.STYLE_SPACING_BOTTOM], a.style[mxConstants.STYLE_SPACING_LEFT], tempsHorizontal, a.style[mxConstants.STYLE_LABEL_BACKGROUNDCOLOR], a.style[mxConstants.STYLE_LABEL_BORDERCOLOR], c.isWrapping(a.cell) && c.isHtmlLabel(a.cell), c.isLabelClipped(a.cell), a.style[mxConstants.STYLE_OVERFLOW], a.style[mxConstants.STYLE_LABEL_PADDING]);
a.text.opacity = a.style[mxConstants.STYLE_TEXT_OPACITY];
a.text.dialect = d ? mxConstants.DIALECT_STRICTHTML : a.view.graph.dialect;
this.initializeLabel(a);
var e = false, f = function(b) {
var d = a;
if (mxClient.IS_TOUCH || e) {
d = mxEvent.getClientX(b);
b = mxEvent.getClientY(b);
b = mxUtils.convertPoint(c.container, d, b);
d = c.view.getState(c.getCellAt(b.x, b.y))
}
return d
}, d = mxClient.IS_TOUCH ? "touchmove" : "mousemove", g = mxClient.IS_TOUCH ? "touchend" : "mouseup";
mxEvent.addListener(a.text.node, mxClient.IS_TOUCH ? "touchstart" : "mousedown", mxUtils.bind(this, function(b) {
if (this.isLabelEvent(a, b)) {
c.fireMouseEvent(mxEvent.MOUSE_DOWN, new mxMouseEvent(b, a));
e = c.dialect != mxConstants.DIALECT_SVG && mxEvent.getSource(b).nodeName == "IMG"
}
}));
mxEvent.addListener(a.text.node, d, mxUtils.bind(this, function(b) {
this.isLabelEvent(a, b) && c.fireMouseEvent(mxEvent.MOUSE_MOVE, new mxMouseEvent(b, f(b)))
}));
mxEvent.addListener(a.text.node, g, mxUtils.bind(this, function(b) {
if (this.isLabelEvent(a, b)) {
c.fireMouseEvent(mxEvent.MOUSE_UP, new mxMouseEvent(b, f(b)));
e = false
}
}));
mxEvent.addListener(a.text.node, "dblclick", mxUtils.bind(this, function(b) {
if (this.isLabelEvent(a, b)) {
c.dblClick(b, a.cell);
mxEvent.consume(b)
}
}))
}
};
graph使泳道图的label横向显示的更多相关文章
- 关于echarts中的饼状图的label文字显示过长的问题
label: { normal: { fontSize: 14, formatter(v) { let text = v.name let count = text.indexOf('¥') cons ...
- Paddle Graph Learning (PGL)图学习之图游走类模型[系列四]
Paddle Graph Learning (PGL)图学习之图游走类模型[系列四] 更多详情参考:Paddle Graph Learning 图学习之图游走类模型[系列四] https://aist ...
- Flex中如何通过showAllDataTips属性使鼠标移动到图表时显示所有的数据Tips的例子
原文 http://blog.minidx.com/2008/11/10/1616.html 接下来的例子演示了Flex中如何通过showAllDataTips属性,使鼠标移动到图表时显示所有的数据T ...
- ztree实现权限功能(横向显示)
最近在做权限功能的时候,采用的ztree实现的,但是产品要求最后一层的权限节点要横向显示.开始在网上找的解决方案是用css样式把最后一层的display设置为inline.在我本地电脑上看了下.效果不 ...
- 用Visio画泳道图
在一次会议中看到有个同事在讲解业务流程时画了一个与PD中很类似的泳道图,但是在图的左侧确有一个阶段的列,事后与他沟通,才知道他这个图是”拼”出来的,也就是说所有的图都是他一点点的在画图工具中做出来的. ...
- 怎样使MathType插入章节标记不显示
作为专业的公式编辑器,MathType可以帮助大家在Word中插入数学公式,有的时候还需要插入章节标记,那么怎样使章节标记不显示呢?下面就教大家使MathType插入章节标记不显示的技巧. 实际问题如 ...
- ios label上显示特殊字符 % "
今天在label上显示一个拼接的百分比 label.text = [NSString stringWithFormater:@"%d%",i]; 结果后面的%就是报错,然后查半天也 ...
- 小技巧,如何在Label中显示图片
这个需求其实是有的,比如QQ聊天界面里面发送的信息,可以用label来显示文字(也可以用button显示),但是有时候用户可能会发送图片.如果能让Label遇到文字就显示文字,遇到图片就显示图片就好了 ...
- 8位灰度图在LCD上显示
一.概述 1.灰度 灰度使用黑色调表示物体,即用黑色为基准色,不同的饱和度的黑色来显示图像.每个灰度对象都具有从 0%(白色)到灰度条100%(黑色)的亮度值. 使用黑白或灰度扫描仪生成的图像通常以灰 ...
随机推荐
- Malloc碎碎念
(以前为给同学分享写的点东西,很基础.)现在的比赛中堆溢出非常常见,对于glibc下malloc的理解也要深入一些. malloc_chunk的对齐属性 在glibc中,malloc_chunk以 2 ...
- Linux下卸载ORACLE的多种方法(转)
第一种# cd /u01/app/oracle/product/11.2.0/client_1/deinstall/ # ./deinstall# rm -rf /u01/app/oracle# rm ...
- Linux学习3——磁盘文件管理系统与压缩和打包操作
一.写在前面 本节将对Linux的磁盘文件系统.文件的压缩打包等操作进行简要介绍. 二.完成目标 1.了解磁盘文件系统的接本知识 2.操作文件和目录的相关命令 3.文件系统的简单操作命令 4.Lin ...
- UVA 10305 Ordering Tasks
题意: 给出n和m,n代表总共有几个箱子.接下来m行,每行有a,b,表示b在a之后.输出一个合理的序列. 分析: 简单的拓扑排序: 代码: #include <iostream>#incl ...
- MVC+simpleinjector 简单使用
一.首先添加NuGet包如下图
- c# 委托 delegate
委托是一种存储函数引用的类型,在事件和事件的处理时有重要的用途 通俗的说,委托是一个可以引用方法的类型,当创建一个委托,也就创建一个引用方法的变量,进而就可以调用那个方法,即委托可以调用它所指的方法. ...
- elegant 的长整数加法 string 实现
string strAdd(string &v1, string &v2){ string res = ""; ; int len1 = v1.size(), le ...
- Scala基础入门-1
首先需要Scala开发环境的搭建,网上自己找教程. 声明常量与变量 val foo = 0 // 常量 var bar = 0 // 变量 在Scala中,更加鼓励使用val来进行声明,也就是推荐使用 ...
- dot.js教程文档api
dot.js是一个短小精悍的js模板引擎,压缩版仅有4K大小,最近使用dot的时候整理出这个dot.js教程文档,其实称不上什么教程,只是对dot.js的介绍和实例,希望能帮助到一部分需要的人. 使用 ...
- android模块
网络模块 1.URL --------openStream() return InputStream --------openConnection() return URLConnection 2.U ...