mike628
mike628

Reputation: 49351

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.

Upvotes: 0

Views: 984

Answers (1)

Lars Kotthoff
Lars Kotthoff

Reputation: 109232

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

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

Complete demo here.

Upvotes: 1

Related Questions