D3.js:显示有限的刻度 [英] D3.js: display limited number of ticks

查看:111
本文介绍了D3.js:显示有限的刻度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用d3.ticks. 根据文档,我应该可以限制数量轴上显示的刻度线数.

I'm trying to use d3.ticks. According to the documentation, I should be able to restrict the number of ticks displayed on the axis.

但是,这似乎完全没有限制滴答声的数量:

However, this doesn't seem to restrict the number of ticks at all:

xAxis = d3.svg.axis().scale(xScale).orient("bottom").ticks(2)

是因为我的体重秤是顺序的吗?

Is it because my scale is ordinal?

JSFiddle此处: http://jsfiddle.net/samselikoff/9tfD2/1/

JSFiddle here: http://jsfiddle.net/samselikoff/9tfD2/1/

推荐答案

axis.ticks仅在基础比例尺实现ticks函数时有效,而序数比例尺则不能.默认情况下,序数刻度的轴刻度包含刻度的域,但是您可以通过提供 axis.tickValues .

axis.ticks only works when the underlying scale implements a ticks function, which ordinal scales do not. By default, the axis ticks for an ordinal scale are comprised of the scale's domain, but you can override this by supplying explicit tick values with axis.tickValues.

这篇关于D3.js:显示有限的刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆