d3 tick marks on integers only

后端 未结 5 1488
旧巷少年郎
旧巷少年郎 2020-12-03 10:04

I have a d3 bar chart whose values range from 0-3. I would like the y-axis to only show integer values, which I can do by

var yAxis = d3.svg.axis().scale(y).         


        
5条回答
  •  时光取名叫无心
    2020-12-03 10:16

    You could add .ticks(4) and .tickSubdivide(0) as I've done below:

    var yAxis = d3.svg.axis()
        .scale(y)
        .orient("right")
        .ticks(4)
    .tickFormat(d3.format("d"))
        .tickSubdivide(0);
    

提交回复
热议问题