javascript - How to style using d3's .style() method instead of using CSS in style tags for .axis path {}? -


i have d3 code here of area chart. question styling axis , tick marks.

currently x axis , y axis styled this:

  .axis line {         fill: none;         stroke: red;         shape-rendering: crispedges;     }    .axis path {         fill: none;         stroke: blue;         shape-rendering: crispedges;     } 

i don't want use approach. let's want change stroke color of axis (to green), using d3's style() method in javascript. tried doing this:

svg.append("g")     .attr("class", "x axis")     .style("stroke", "green")     .attr("transform", "translate(0," + height + ")")     .call(xaxis); 

what ended changing axis text labels green color. not intended do.

what missing ?

how style .axis line , .axis path using style() method of d3.

please find me code here on jsfiddle

if want use javascript

after drawing axis using selectall method can change colors.

svg.append("g")     .attr("class", "x axis")     .style("stroke", "green")     .attr("transform", "translate(0," + height + ")")     .call(xaxis);   svg.selectall(".x.axis *").style({"stroke":"red"}); 

i given example changed color red. can change ticks or text color want change.

for line , path use

svg.selectall(".x.axis line, .x.axis path").style({"stroke":"red"}); 

but prefer use css changing color.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -