I have a piece of code where I'm trying to determine the symbol and color to use dynamically based on a parameter being passed in (0 or 1). However I get a path error for attribute d when I try and set up the logic. Code is below
svg.selectAll(".point")
.data(data)
.enter()
.append("path")
.attr("class", "point")
.attr("d", function(d){
if(d.zeroOrOne == 1){
return d3.svg.symbol().type("cross");
}else if (d.zeroOrOne == 0){
return d3.svg.symbol().type("circle");
}
})<
.attr('fill', 'none')
.attr('stroke', function(d){
if(d.zeroOrOne == 1){
return 'blue';
}else if (d.zeroOrOne == 0){
return 'red';
}
})
.attr("transform", function(d) { return "translate(" + ratingScale(d.xParam) + "," + winsNomsScale(d.yParam) + ")"; });
If I remove the conditional sybmol logic and just d strictly to one symbol or the other everything works, but I can't figure out why adding the conditional logic is causing problems. Here's the error:
Error: attribute d: Expected moveto path command ('M' or 'm'), "function n(n,r){…