D3.js y-Axis time scale

D3.js y-Axis time scale

本文关键字:scale time y-Axis js D3      更新时间:2023-09-26

是否有可能在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);