【发布时间】:2015-03-03 14:08:04
【问题描述】:
我正在尝试将一个附加参数传递给 graffle 的连接函数,以便我可以根据该新参数在行尾绘制带/不带箭头的连接。
要建立联系,我通常会这样做:
connections.push(paper.connection(obj1, obj2, "#000"));
现在我想以这种方式添加这个新参数:
connections.push(paper.connection(condCol, ret, "#000",true));
但参数始终是undefined
这就是我改变连接功能的方式:
Raphael.fn.connection = function (obj1, obj2, line, bg, addArrow) {
//...
if (line && line.line) {
//...
} else {
// based on the 'addArrow' parameter I can figure out
// whether I should put an arrow at the end of the line or not
var settings;
if (addArrow) {
//If addArrow was true, draw a arrow at the end of the line
settings = { "stroke": color, fill: "none", 'stroke-width': 2, 'arrow-end': 'block-midium-midium' };
}
else {
//If addArrow was false, just draw a line
settings = { "stroke": color, fill: "none", 'stroke-width': 2 };
}
return {
bg: bg && bg.split && this.path(path).attr({ stroke: bg.split("|")[0], fill: "none", "stroke-width": bg.split("|")[1] || 3 }),
line: this.path(path).attr(settings), //use the settings
from: obj1,
to: obj2
};
}
}
你知道为什么这不起作用吗??
提前致谢。
【问题讨论】:
标签: javascript svg raphael