How to limit d3.svg.axis to integer labels?

前端 未结 3 728
醉话见心
醉话见心 2020-12-18 17:39

Is there any possibility to limit the number of d3.svg.axis integer labels displayed on the graph? Take for instance this graph. There are only 5 sizes here: [0, 1, 2,

3条回答
  •  离开以前
    2020-12-18 18:25

    You should be able to use d3.format instead of writing your own format function for this.

    d3.svg.axis()
        .tickFormat(d3.format("d"));
    

    You can also use tickFormat on your scale which the axis will automatically use by default.

提交回复
热议问题