I am working on color legend using d3 and currently my legend is shown vertically but I want it to display horizontally. I have attached code snippet and also shared jsfiddle link.
var svg = d3.select(selector_id)
.append("svg")
.attr("height", (legendheight) + "px")
.attr("width", (legendwidth) + "px")
.style("position", "absolute")
.style("left", "0px")
.style("top", "0px")
svg
.append("g")
.attr("transform", "translate(" + (legendwidth - margin.left - margin.right + 3) + "," + (margin.top) + ")")
.call(legendaxis);
};
I want something like this: https://i.sstatic.net/cCxSa.png
I have also attached fiddle link for more info: