Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个使用D3.js的工作线性条形图,它也有基于时间的 x 轴。条形绑定到计数属性,而轴绑定到日期属性。轴上的刻度不与条对齐。知道如何将它们排成一行吗?
这是 jsFiddle:http: //jsfiddle.net/MmEjF/
这是因为图表有 14 个柱,但有 15 个刻度线。
第一个刻度线应该是数据集开始前的一个月。
您可以通过将 xTimeDomain 的开始时间提前一个月来解决此问题:
xTimeDomain[0] = new Date(new Date(xTimeDomain[0]).setMonth(xTimeDomain[0].getMonth()-1));