Thursday, 15 March 2012

javascript - time scale displays wrong year -



javascript - time scale displays wrong year -

i'm trying display timescale axis years tick labels year displayed wrong. sample code below shows : "1951 1952 1953 1953 1954". looks roundoff error if show month switches jan december: "jan-1951 jan-1952 jan-1953 dec-1953 dec 1954..."

var svgcontainer = d3.select("body").append("svg") .attr("width", 3000) .attr("height", 300); var axisscale = d3.time.scale() .domain([new date("1950-11-11"), new date("1980-07-14")]) .range([0, 3000]) .nice(d3.time.year); var xaxis = d3.svg.axis() .scale(axisscale) .ticks(d3.time.year, 1) .tickformat(d3.time.format("%y")); svgcontainer.append("g").call(xaxis);

update: bug shows in firefox (see http://imgur.com/oqfhe7d). it's downwards js implementation differences.

javascript d3.js

No comments:

Post a Comment