2016-01-13 101 views
1

我有一個包含大量數據的圖表,這意味着我在x軸上有一個滾動條。當我在X軸上滾動時Y軸消失。d3使Y軸位置固定,即使是滾動條x

我可以設置爲固定的Y軸位置。 (總是看到這個Y軸)?

https://jsfiddle.net/ou28se1z/1/ 我試圖添加.attr("position", "fixed")但它不工作

//Add Y axis 
svg.append("g") 
.attr("class", "axis") 
.attr("transform", "translate(" + padding + ",0)") 
.attr("position", "fixed") 
.call(yAxis); 

我也試圖做.style( 「位置」, 「固定」)

svg.append("g") 
.attr("class", "axis") 
.attr("transform", "translate(" + padding + ",0)") 
.style("position", "fixed") 
.call(yAxis); 

,但它不是工作

回答

0

http://codepen.io/brantwills/pen/igsoc

var zoom = d3.behavior.zoom() 
    .x(x) 
    .y(y) 
    .scaleExtent([1, 10]) 
    .on("zoom", zoomed);  

function zoomed() { 
    svg.select(".x.axis").call(xAxis); 
    svg.select(".y.axis").call(yAxis); 
    svg.selectAll('path.line').attr('d', line); 

    points.selectAll('circle').attr("transform", function(d) { 
     return "translate(" + x(d.point.x) + "," + y(d.point.y) + ")"; } 
    ); 

}