d3.js - controlling ticks and bins on a histogram

穿精又带淫゛_ 提交于 2019-12-03 08:23:56

From the documentation on .ticks():

The specified count is only a hint; the scale may return more or fewer values depending on the input domain.

Instead of messing around with .ticks(), just make the bins yourself:

tempScale = d3.scale.linear().domain([0, bins]).range([lowerBand, upperBand]);
tickArray = d3.range(bins + 1).map(tempScale);

and pass that array to .tickValues() and .bins().

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!