How to set the size of a d3 symbol?
You have to define the size
in the symbol generator (the d3.svg.symbol
function):
d3.svg.symbol().size(size).type(foo);//size here-----------^
Here is a demo:
var svg = d3.select("svg");var sizes = ["10", "50", "100", "200", "500", "1000", "2000"];sizes.forEach((d, i) => { svg.append('path') .attr("transform", "translate(" + (10 + (i+1) * (i+1) * 5) + ",100)") .attr("d", d3.svg.symbol().size(d).type("diamond")) .style("fill", "gold") .attr('stroke', 'black');});
<script src="https://d3js.org/d3.v3.js"></script><svg></svg>