这是来自http://bl.ocks.org/simenbrekken/6634070的D3JS代码。我想调整它,所以我可以通过编程方式添加它。
this.x_axis = d3.scaleTime()
.domain([this.now - (this.limit - 2), this.now - this.duration])
.range([0, this.width]);
this.y_axis = d3.scaleLinear()
.domain([0, 100])
.range([this.height, 0]);
console.log(typeof this.x_axis); // Return `function`.
console.log(typeof this.y_axis); // Return `function`.
this.line = d3.line()
.curve(d3.curveBasis)
.x(function (d, i) {
console.log(typeof this.x_axis); // Return `undefined`?!?!?!
return this.x_axis(this.now - (this.limit - 1 - i)*this.duration);
})
.y(function (d) {
return this.y_axis(d);
});