Skip to content

Commit

Permalink
grapher: shift right when plotting past right edge
Browse files Browse the repository at this point in the history
  • Loading branch information
stepheneb committed Mar 8, 2012
1 parent ec03712 commit f681b83
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/simple-graph.js
Expand Up @@ -212,8 +212,8 @@ function simpleGraph(elem, data, options) {
return d ? "#ccc" : "#666";
},

fx = xScale.tickFormat(options.datacount),
fy = xScale.tickFormat(options.datacount);
fx = xScale.tickFormat(10),
fy = xScale.tickFormat(10);

// Regenerate x-ticks…
var gx = vis.selectAll("g.x")
Expand Down Expand Up @@ -568,8 +568,18 @@ function simpleGraph(elem, data, options) {

graph.set_data = function(_) {
if (!arguments.length) return data;
var domain = xScale.domain(),
xextent = domain[1] - domain[0],
shift = xextent * 0.8;
graph.generateDataPoints(_);
graph.update();
if (points.length > domain[1]) {
domain[0] += shift;
domain[1] += shift;
xScale.domain(domain);
graph.redraw();
} else {
graph.update();
}
return graph;
};

Expand Down

0 comments on commit f681b83

Please sign in to comment.