d3 make Y axis position fixed even the scroller x

心已入冬 提交于 2020-01-16 05:25:52

问题


I have a chart with alot of data that means I have a scroller over the x axis. when I scroll over the X axis Y axis disappear.

can i set to Y axis position fixed. ( always see this Y axis)?

https://jsfiddle.net/ou28se1z/1/ I tried to add .attr("position", "fixed") but it doesnt work

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

I also tried to do .style("position", "fixed")

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

but its not work


回答1:


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) + ")"; }
    ); 
}


来源:https://stackoverflow.com/questions/34762688/d3-make-y-axis-position-fixed-even-the-scroller-x

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!