javascriptsvgd3.js

How to set text color for my d3 chart title?


I have my d3 chart title, text append on the svg as per below:

svg.append("text")
    .attr("x", (width / 2))             
    .attr("y", 0)
    .attr("text-anchor", "middle")  
    .style("font-size", "14px")
    .text(text);

reference here

But I would like to set the text color to some other color. Is that possible?


Solution

  • I found out the way to set the text color is

    .style('fill', 'darkOrange')