Hi Philippe Lhoste Thanks..! it works fine. Thanks to Doug too..!
--- In [EMAIL PROTECTED], Philippe Lhoste <[EMAIL PROTECTED]> wrote: > alagu_26 wrote: > > I am new to SVG. I am trying to show data in tool tip text while > > moving mouse over the svg element. i used to two function showttip > > (evt) and hidettip(). It works fine if i disable the ZoomAndPan > > option. I enabled ZoomAndPan option and did zoom in/out. Now i cannot > > able to view the tooltip properly in mouseover. I think i need to > > change the calculations for finding x,y pos of tooltip box. If > > anybody knows how to do it. pls help me. > > > > (For tooltip box i used rect and text elements) > > I am not expert at JavaScript manipulation of SVG Dom yet, but I have > collected some useful files... > > I have an annonymous ToolTips.svg file which shows the basics on how to > show tooltips over shapes. > After googling a bit, tt is likely to come from > <http://www.svgopen.org/2002/papers/sorotokin__svg_secrets/ToolTips.sv g> > > It suffers from the same problem as you describe. > > Fortunately, I also have a DragAndDrop.svg file, written by Doug > Schepers which had the good idea to put a <desc> tag in its file, so I > can credit him without searching... > > In this file, there is a nice GetTrueCoords function which does what I > was looking for. > > To test it in the ToolTips.svg file, I just added: > > var trueCoords = r.createSVGPoint(); > > after the tt_bg declaration/init. > > Replaced: > > var x = evt.clientX + 4 > var y = evt.clientY - 1 > > by: > > // account for zooming and panning > GetTrueCoords(evt); > var x = trueCoords.x + 4; > var y = trueCoords.y - 1; > > in the Over function. > > And added the function itself at the end: > > function GetTrueCoords(evt) > { > // Find the current zoom level and pan setting, and adjust the > // reported mouse position accordingly > var newScale = r.currentScale; > var translation = r.currentTranslate; > trueCoords.x = (evt.clientX - translation.x)/newScale; > trueCoords.y = (evt.clientY - translation.y)/newScale; > }; > > It works! :-) Thanks Doug. > The tooltip is zoomed in too, if you want to keep its size constant, you > may have some additional work, which should be easy since you have the > scale. > > -- > Philippe Lhoste > -- (near) Paris -- France > -- Professional programmer and amateur artist > -- http://Phi.Lho.free.fr > -- -- -- -- -- -- -- -- -- -- -- -- ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/1U_rlB/TM --------------------------------------------------------------------~-> ----- To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membership" ---- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

