gpt4 book ai didi

javascript - D3.js y 轴时间刻度

转载 作者:行者123 更新时间:2023-12-03 09:21:38 25 4
gpt4 key购买 nike

D3.js 中是否可以制作带有时间刻度 y 轴的折线图?

我找到了文档: https://github.com/mbostock/d3/wiki/Time-Scales

Y 轴似乎没有限制。

有什么例子吗?

最佳答案

它与使用线性刻度几乎相同:

var svg = d3.select('#your_svg_id').select("svg")
.attr('width', 300)
.attr('height', 300)
.append("g");

var yScale = d3.time.scale()
.domain([new Date(1980, 0, 1), new Date() ])
.range([100, 0]);
// Domian being the from and to date and range the from to positioning of the axis

svg.append("svg:g")
.attr("class", "y axis")
.call(yAxisGen);

关于javascript - D3.js y 轴时间刻度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31824990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com