d3使Y轴的位置固定,即使滚动条x [英] d3 make Y axis position fixed even the scroller x

查看:222
本文介绍了d3使Y轴的位置固定,即使滚动条x的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含大量数据的图表,这意味着我在x轴上有一个滚动条. 当我在X轴上滚动时,Y轴消失了.

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.

我可以固定设置为Y轴位置吗? (总是看到这个Y轴)?

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

https://jsfiddle.net/ou28se1z/1/ 我试图添加.attr("position", "fixed"),但是它不起作用

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);

我也尝试做.style("position","fixed")

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

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

但不起作用

推荐答案

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

这篇关于d3使Y轴的位置固定,即使滚动条x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆