How to set text color for my d3 chart title?

JavascriptTextSvgColorsd3.js

Javascript Problem Overview


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?

Javascript Solutions


Solution 1 - Javascript

All the while I was doing .style("fill", "darkOrange")

Then I found out the correct answer is

.style('fill', 'darkOrange')

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjhyapView Question on Stackoverflow
Solution 1 - JavascriptjhyapView Answer on Stackoverflow