Thomas Seiwert
Thomas Seiwert

Reputation: 41

D3.js y-Axis time scale

is it possible to have a line chart with a time-scaled y-Axis in D3.js?

I found the documentation: https://github.com/mbostock/d3/wiki/Time-Scales

and there doesn't seem to be a limitation for the Y-Axis.

Do you have any examples?

Upvotes: 0

Views: 712

Answers (1)

Stacey Burns
Stacey Burns

Reputation: 1092

Its pretty much the same as using a linear scale:

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);

Upvotes: 1

Related Questions