Guest User

Untitled

a guest
Oct 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. function mySymbols(){
  2.  
  3. var symbol = d3.svg.symbol();
  4. var my_types = []; // our other types
  5.  
  6. my_types.NewSymbolName = function(size){
  7. return 'Custom Symbol 1 Path'
  8. }
  9.  
  10. var me = function(datum, index){
  11.  
  12. var type = symbol.type(), size = symbol.size();
  13. if(type instanceof Function){
  14. type = type(datum, index);
  15. }
  16. if(size instanceof Function){
  17. size = size(datum, index);
  18. }
  19.  
  20. // generating a built in type.
  21. if(d3.svg.symbolTypes.indexOf(type) !== -1) {
  22. return symbol(datum, index);
  23. }
  24. return my_types[type](size);
  25. };
  26.  
  27. var my_size = symbol.size();
  28. me.size = function(size){
  29. if(arguments.length){
  30. symbol.size(size);
  31. return me;
  32. }
  33. return symbol.size();
  34. };
  35.  
  36. var my_type = symbol.type();
  37. me.type = function(type){
  38. if(arguments.length){
  39. symbol.type(type);
  40. return me;
  41. }
  42. return symbol.type();
  43. };
  44. return me;
  45. };
Add Comment
Please, Sign In to add comment