How to set text color for my d3 chart title?

57,530

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

Then I found out the correct answer is

.style('fill', 'darkOrange')

Share:
57,530
jhyap
Author by

jhyap

present) Software QA Lead Python language intermediate level C language intermediate level ex) Software Development Engineer (Data Visualization) Data visualization and Analysis advance level C# winsform programming intermediate level JavaScript intermediate level GrADS beginner-intermediate level jqplot - intermediate-advance level online map api - intermediate-advance level d3.js - beginner level GIS newbie

Updated on July 09, 2022

Comments

  • jhyap
    jhyap almost 2 years

    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?

  • Nevin Madhukar K
    Nevin Madhukar K about 10 years
    aww.. was writing that out just now. Glad you found the ans. :)
  • jhyap
    jhyap about 10 years
    Thanks you very much :)
  • Felix Kling
    Felix Kling about 10 years
    Yeah, SVG is weird like that.
  • Admin
    Admin almost 5 years
    what the heck? why does it even matter?
  • Dev
    Dev over 2 years
    its still not working for me