<community>of XML and SVG Developers</community>
This is a discussion on tool tips javascript and svg calling the functions problem within the SVG Questions forums, part of the SVG Forums category; Would anyone know how i could get this java script working in a external java script file interacting with svg ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| interacting with svg rectangle elements. I need the user to get a tool tip when the user moves there mouse onto the element... This is the java script... function GetTrueCoords(evt) { newScale = SVGRoot.currentScale; translation = SVGRoot.currentTranslate; TrueCoords.x = (evt.clientX - translation.x)/newScale; TrueCoords.y = (evt.clientY - translation.y)/newScale; } function ShowTooltip(evt, turnOn, text) { try { if (!evt || !turnOn) { var node = SVGDocument.getElementById('tooltip') var nodeText = SVGDocument.getElementById('tooltipText') SVGRoot.removeChild(node) SVGRoot.removeChild(nodeText) } else { GetTrueCoords(evt); var xRectPos = TrueCoords.x - 50; var yRectPos = TrueCoords.y - 35; var xTextPos = xRectPos + 8; var yTextPos = yRectPos + 15; // Create rect node var myRect = evt.target.ownerDocument.createElementNS(null,"rec t"); myRect.setAttributeNS(null,"id","tooltip"); myRect.setAttributeNS(null,"x",xRectPos); myRect.setAttributeNS(null,"y",yRectPos); myRect.setAttributeNS(null,"rx","3"); myRect.setAttributeNS(null,"ry","3"); myRect.setAttributeNS(null,"fill-opacity", "0.7"); myRect.setAttributeNS(null,"width",text.length*Coo l; myRect.setAttributeNS(null,"height","20"); myRect.setAttributeNS(null,"fill","white"); myRect.setAttributeNS(null,"stroke","blue"); SVGRoot.appendChild(myRect); // Create text node to insert var textNode = evt.target.ownerDocument.createElementNS(null,"tex t"); textNode.setAttributeNS(null,"id","tooltipText"); textNode.setAttributeNS(null,"x",xTextPos); textNode.setAttributeNS(null,"y",yTextPos); textNode.setAttributeNS(null,"style","fill:blue;fo nt-size:13;text-anchor:start;"); textNode.appendChild(evt.target.ownerDocument.crea teTextNode(text)); SVGRoot.appendChild(textNode); } } catch(er){} } could someone tell me how i would set my svg file to call all these functions so the tool tips would work thanks... |
| |||
|
Hi Steve Here are some SVG Tooltip examples: http://www.mecxpert.de/svg/tooltips.html and also: http://svg-whiz.com/svg/Tooltip.svg (I like the second example)
__________________ rogramming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook) |
Inkjet Printer Inks...
Buy your inkjet printer inks at great savings.
Hard Disk Drive Data Recovery Lancashire >>
Data Clinic performs data recovery on extremely damaged hard drives.