2013-05-28 31 views
1

我正在使用拉斐尔JS绘制矩形对象。 JS编码由运行时转换为ABAP编码并显示在内部浏览器中。 虽然显示一切都很好,但我想用鼠标移动SVG对象时发布一个特定的Qucikinfo。有谁知道如何通过矩形对象发布快速信息?通过点击对象的信息也可以。我不whant使用一个圆形物体..矩形SVG对象快速信息/拉斐尔JS

ABAP:

CONCATENATE: 'var' a_name '= paper.rect(' a_x_pos ',' a_y_pos ',' 
a_width ',' a_height ',' a_corner_radius ');' 
INTO l_html_line SEPARATED BY space. 

JS:

var name = paper.rect(x_pos, y_pos, width, height, corner_radius) 

回答

0

你可以看看这个:http://stratha.us/raphael_js_tooltip

代码是非常小:

Raphael.el.tooltip = function (tp) { 
    this.tp = tp; 
    this.tp.ox = 0; 
    this.tp.oy = 0; 
    this.tp.hide(); 
    this.hover(
    function(event) { 
     this.mousemove(function(event) { 
     this.tp.translate(event.clientX - 
      this.tp.ox,event.clientY - this.tp.oy); 
     this.tp.ox = event.clientX; 
     this.tp.oy = event.clientY; 
     }); 
     this.tp.show().toFront(); 
    }, 
    function(event) { 
     this.tp.hide(); 
     this.unmousemove(); 
    } 
); 
    return this; 
}; 

然后你只需要拨打

name.tooltip(paper.text(0 , 0 , "Hi, I am a tooltip")); 

在旁注中,ABAP代码看起来非常难以维护。我会邀请你在codereview.stackexchange.com上发布整个代码,我相信有更好的方法来做到这一点。

+1

非常感谢您的回答!我在codereview.stackexchange.com上发布了我的代码:http://codereview.stackexchange.com/questions/26735/quickinfo-for-rectangle-svg-object-raphael-js – user2428086