Created
April 10, 2014 16:41
-
-
Save vicapow/10400706 to your computer and use it in GitHub Desktop.
custom symbol generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mySymbols(){ | |
var symbol = d3.svg.symbol(); | |
var my_types = []; // our other types | |
my_types.NewSymbolName = function(size){ | |
return 'Custom Symbol 1 Path' | |
} | |
var me = function(datum, index){ | |
var type = symbol.type(), size = symbol.size(); | |
if(type instanceof Function){ | |
type = type(datum, index); | |
} | |
if(size instanceof Function){ | |
size = size(datum, index); | |
} | |
// generating a built in type. | |
if(d3.svg.symbolTypes.indexOf(type) !== -1) { | |
return symbol(datum, index); | |
} | |
return my_types[type](size); | |
}; | |
var my_size = symbol.size(); | |
me.size = function(size){ | |
if(arguments.length){ | |
symbol.size(size); | |
return me; | |
} | |
return symbol.size(); | |
}; | |
var my_type = symbol.type(); | |
me.type = function(type){ | |
if(arguments.length){ | |
symbol.type(type); | |
return me; | |
} | |
return symbol.type(); | |
}; | |
return me; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment