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%(黑色)的亮度值. 使用黑白或灰度扫描仪生成的图像通常以灰 ...
随机推荐
- Unable to resolve target 'android-XX'的问题解决
1.问题现象(Unable to resolve target 'android-XX') 将低版本的代码导入eclipse时,常遇到这样的问题:Unable to resolve target 'a ...
- OAuth2.0授权机制说明
授权机制说明 1 简介 优酷对第三方应用用户授权采用OAuth2.0标准 2 OAuth2.0 授权方式 优酷支持OAuth 2.0的三种授权方式,请根据平台选用不同的授权方式: 2.1 通用授权 ...
- Android长方形图片生成正圆形,以及矩形图片生成圆角
一般要做正圆形图片,只能是正方形的基础上才能实现,否则就变成椭圆了,下面说说如何使长方形的图片生成正圆形图片 废话不多说,没图没真相,先上图吧: 原图: 变成正圆后: 下面上代码: public ...
- 【深搜加剪枝】【HDU1455】【Sticks】
题目大意:有一堆木棍 由几个相同长的木棍截出来的,求那几个相同长的木棍最短能有多短? 深搜+剪枝 具体看代码 #include <cstdio> #include <cstdlib& ...
- 只获取linux ip的命令
ifconfig eth0 | awk '/inet addr/{print substr($2,6)}'
- 前端开发必备的Sublime 3插件
Sublime的大名已经无需我介绍了,首先先介绍如何启用插件安装功能: 打开Sublime 3,然后按 ctrl+` 或者在View → Show Console 在打开的窗口里黏贴这个网站上的代码( ...
- javascript——touch事件介绍与实例演示
分类: javascript2014-02-12 16:42 1742人阅读 评论(0) 收藏 举报 touch事件touchmovetouchstarttouchend 前言 诸如智能手机和平板 ...
- ViewState存储到服务器
把viewstate保存在服务器上 将ViewState持久化保持在服务器端的代码,这样ViewState不占用网络带宽,因此其存取只是服务器的磁盘读取时间.并且它很小,可以说是磁盘随便转一圈就能同时 ...
- 远程访问数据库查询数据量一大就Hang
最近刚为客户升级了一套Oracle Database,一切进展顺利,眼看就要顺利验收时,发现有部分客户端软件连接新版本数据库时会Hang,问题非常诡异. 系统环境如下 升级前的环境OS:Windows ...
- c#中的数据类型简介(枚举)
C#中的数据类型简介(枚举) 枚举的定义 根据MSDN上给出的定义,枚举是一个指定的常数集,其基础类型可以是除Char外的任何整型. 如果没有显式声明基础类型,则使用 Int32. Enum 是 .N ...