1
在我的第一個d3 js圖表中嘗試畫筆功能,並讓畫筆按預期工作。只有問題我有atm圖表線溢出x軸的界限。當選擇整個期間時,線條保持其邊界。我做錯了什麼,但不能真正看到什麼。有人得到一個指針?D3 js - 當使用畫筆線增長超出圖x軸
碼(選擇)樓下:
var margin = {top: 40, right: 185, bottom: 100, left: 40},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var margin2 = {top: 440, right: 185, bottom: 20, left: 40},
height2 = 500 - margin2.top - margin2.bottom;
var x=d3.time.scale().range([0, width]),
x2 = d3.time.scale().range([0, width]);
var y=d3.scale.linear().range([height,0]),
y2= d3.scale.linear().range([height2,0]);
var xAxis = d3.svg.axis().scale(x)
.orient("bottom")
.ticks(5);
var xAxis2 = d3.svg.axis().scale(x2)
.orient("bottom")
.ticks(5);
var yAxis = d3.svg.axis().scale(y)
.orient("left")
.ticks(5)
.tickFormat(formatPercent);
var brush = d3.svg.brush()
.x(x2)
.on("brush", brushed);
function brushed() {
x.domain(brush.empty() ? x2.domain() : brush.extent());
focus.select("#mainline").attr("d", function (d) {return valueLine(dataFilter); });
focus.select("#subline").attr("d", function (d) {return valueLine(dataAHSantal); });
focus.select(".x.axis").call(xAxis);
}