Ava Lucas Ava Lucas - 1 year ago 52
CSS Question

Why does my css not working on d3js

I am very new to d3js and I am having issues with making my css work. Here is my syntax:

my css

div.chart{
font-family:sans-serif;
font-size:0.7em;
}
div.bar {
background-color:DarkRed;
color:white;
height:3em;
line-height:3em;
padding-right:1em;
margin-bottom:2px;
text-align:right;
}


My d3js

$("document").ready(function(){

d3.json("https://api.myjson.com/bins/fwhm5",function(data){
d3.select("body")
.append("div")
.attr("class","chart")
.selectAll(".bar")
.data(data.cash)
.enter()
.append("div")
.attr("class","div")
.style("width",function(d){return d.count/100 + "px"})
.text(function(d){return Math.round(d.count)})


})


})


Everything except the css is working.
Here is the codepen url https://codepen.io/anon/pen/VzLMzb

Answer Source
.append("div")
      .attr("class","div")

Shouldn't that be

.append("div")
      .attr("class","bar")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download