0

line chart with d3.js ... from here ::(http://bl.ocks.org/stepheneb/1182434)

but when start dragging all point go to left and x-axis which is ime scale is start from 01/01/70 than need too much panning to get in real values 2010... once we pan than al work good but at starting all go to 01/01/70 .. any idea ?

var x =  d3.time.scale().range([0, width]);
var zoomChart = d3.behavior.zoom()
    .x(x)
    .on("zoom", zoomedChart);

function zoomedChart() {
    svg.select(".x.axis").call(xAxis);
    svg.select(".y.axis").call(yAxis);   
    svg.select(".yy.axis").call(yyAxis);   
    drawLines();
}   


 svg.append("rect").attr("x", 0)
          .attr("y", 0)
          .attr("width", width)
          .attr("height", height).attr("class", "dummy")
          .call(zoomChart);


   var supercumulate = alllinesdata;
   x.domain(d3.extent(supercumulate, function (d) { return d.date; }));
    xmin = new Date(d3.min(supercumulate, function (d) { return d.date; }));

    xmax = new Date(d3.max(supercumulate, function (d) { return d.date; }));
    if(xmin!= 'undefined' && xmax!=undefined && xmin.getTime()==xmax.getTime()){
        xmin = xmin.setDate(xmin.getDate() - 1);
        xmax = xmax.setDate(xmax.getDate() + 1);
        x.domain(d3.extent([xmin, xmax]));
    }

enter image description here

Amit Rana
  • 1,117
  • 1
  • 10
  • 32

0 Answers0