d3js v4: Only show labels on x-axis

前端 未结 1 1137

I\'m creating a stacked bar chart. I would like to show only the tick\'s label text on the x-axis, but without the ticks and the horizontal x-axis line.

How do I go

1条回答
  •  执念已碎
    2021-01-07 00:02

    Put this is the CSS:

    .axis path, .axis line {
      fill: none;
      stroke: none;
    }
    

    Here is a demo:

    var svg = d3.select("svg");
    var x = d3.scaleLinear().domain([1, 10]).range([10, 390])
    svg.append('g')
      .attr('class', 'axis')
      .attr('transform', 'translate(0,50)')
      .call(d3.axisBottom(x));
    .axis path, .axis line {
      fill: none;
      stroke: none;
    }
    
    

    0 讨论(0)
提交回复
热议问题