Search

12/30/2009

HTML, SVG or Canvas Labels?

HTML, SVG or Canvas Labels?


1. //Add the name of the node in the correponding label
2. //and a click handler to move the graph.
3. //This method is called once, on label creation.
4. onCreateLabel: function(domElement, node){
5. domElement.innerHTML = node.name;
6. domElement.onclick = function(){
7. rgraph.onClick(node.id);
8. };
9. },
10. //Change some label dom properties.
11. //This method is called each time a label is plotted.
12. onPlaceLabel: function(domElement, node){
13. var style = domElement.style;
14. style.display = '';
15. style.cursor = 'pointer';
16.
17. if (node._depth <= 1) {
18. style.fontSize = "0.8em";
19. style.color = "#ccc";
20.
21. } else if(node._depth == 2){
22. style.fontSize = "0.7em";
23. style.color = "#494949";
24.
25. } else {
26. style.display = 'none';
27. }
28.
29. var left = parseInt(style.left);
30. var w = domElement.offsetWidth;
31. style.left = (left - w / 2) + 'px';
32. }

沒有留言: