あなたが考慮したいと思うかもしれません
:ここ
x.domain([d3.timeDay.offset(d3.min(data, function(d) {
return d.date;
}), -2), d3.timeDay.offset(d3.max(data, function(d) {
return d.date;
}), +2)]);
更新bl.ocksです:開始から2日間減算とx
ドメインの末端で2日間を追加すると、例えば
、 d3fc extent componentを試してください。あなたのケースでは、次のように、あなたはXスケールのいずれかの側に1日追加することができます。
var xExtent = fc.extentDate()
// the property of the data that defines the x extent
.accessors([function(d) { return d.date; }])
// pad in domain units (in this case milliseconds)
.padUnit('domain')
// ensure that the scale is padded by one day in either direction
.pad([millisPerDay, millisPerDay]);
x.domain(xExtent(data));
また、Yドメインの範囲の計算を簡素化するために、このコンポーネントを使用することができます。
var yExtent = fc.extentLinear()
// the property of the data that defines the y extent
.accessors([function(d) { return d.close; }])
// pad by 10% in the +ve direction
.pad([0, 0.1])
// ensure that the extent includes zero
.include([0]);
y.domain(yExtent(data));
はここです完全な例:https://bl.ocks.org/ColinEberhardt/4b8737e0251f92075693a6e04df72638