简体   繁体   中英

D3 text for axis not showing

Heres my code:

    var height = 500,
        width = 500,
        margin = 25,
        offset = 50;
    var data = [4, 8, 15, 16, 23, 42];
    var axisWidth = width - 2 * margin;
    var x = d3.scale.linear()
     .range([0, axisWidth])
     .domain([0,42]);
    var xAxis = d3.svg.axis()
    .scale(x)
        .ticks(20, ",.1s")
        .tickSize(6, 0)
     .orient("bottom");
    var chart = d3.select(".chart")
        .attr("width", width)
        .attr("height", height);

    chart.append("g")
        .attr("class", "x axis")
       .attr("transform", "translate(0,200)")
        .call(xAxis);

I have followed several examples and they all have a line connecting the ticks and text values for the ticks , all I have is the ticks?? Any clue why ? Using Chrome.

You need to set the style for the lines as well:

path, line {
  fill: none;
  stroke: black;
}

Complete demo here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM