简体   繁体   English

使用带有时间刻度的d3轴,您如何在时间上均匀地间隔宽的间隙

[英]using a d3 axis using a time scale, how do you evenly space wide gaps in time

This is for a multiline chart. 这是用于多折线图的。

I'm displaying 20 points but in between them you might have a gap of days or weeks. 我要显示20分,但在它们之间可能有几天或几周的间隔。 This causes the axis to bump the points left and right when looking at a gap of three weeks. 当观察三个星期的间隙时,这将导致轴左右颠簸。 in general the points will be hourly, but long gaps may occur. 一般来说,积分是每小时一次,但可能会出现长时间的差距。 I tried using d3.svg.axis.tickValues to set the values but it still spaces them unevenly. 我尝试使用d3.svg.axis.tickValues设置值,但它仍然不均匀地隔开它们。

You need to use a scale 你需要用秤

d3.scale.linear().domain([..]).range([...]); More info here : https://github.com/mbostock/d3/wiki/Quantitative-Scales 更多信息在这里: https : //github.com/mbostock/d3/wiki/Quantitative-Scales

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM