Reputation: 45
I just got this nice chart here
https://jsfiddle.net/eo8223ay/1/
<body>
<div id="chart1" class="chart"></div>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js"></script>
</body>
But the problem is when I scroll x axis , the y axis disappeared. I tried the solution here but no luck. The solution here looks great but it wont work on my example.
I know axis in d3 are actually svg , so how do I achieve of that a fixed y-axis ?
Upvotes: 1
Views: 1940
Reputation: 1
window.onscroll = function() {myFunction()};
function myFunction() {
if(window.pageYOffset == 0)
{
d3.select("#test").nodes()[0].setAttribute("transform", "translate(200, " + 10 +")")
}
if (window.pageYOffset > 0) {
d3.select("#test").nodes()[0].setAttribute("transform", "translate(200, " + window.pageYOffset +")")
}
}
Upvotes: 0