Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
194
rated 0 times [  195] [ 1]  / answers: 1 / hits: 21235  / 12 Years ago, thu, february 28, 2013, 12:00:00

I have a problem since a few days. I have a graph and when I use Zoom Behavior it works, but I need to know when I reach maximum zoom to load new given



// Specifies the zoom scale's allowed range, [min, max]
d3.behavior.zoom().x(x).scaleExtent([1,10]).on(zoom, draw)


See my code
http://jsfiddle.net/albanlopez/D4MRP/


More From » events

 Answers
37
rect.call(zm=d3.behavior.zoom().x(x).scaleExtent([1,10]).on(zoom, draw));


After a new test i have the answer :



var currentZoom = d3.event.scale;


But only available/readable in the draw() function called by .on(zoom, draw)



rect.call( zm = d3.behavior.zoom().x(x).scaleExtent([1,10]).on(zoom, draw));

function draw() {
// trace l'axe X
svg.select(g.x.axis).call(xAxis);
// trace l'axe Y
svg.select(g.y.axis).call(yAxis);
// trace la courbe
svg.select(path.line).attr(d, line);

console.log(zm.scale(), zm.translate()); // , zm.translate[1] = Y
console.log(d3.event.scale, d3.event.translate[0]); // , d3.event.translate[1] = Y
}

[#79919] Thursday, February 28, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
skylerselenem

Total Points: 282
Total Questions: 101
Total Answers: 107

Location: Nicaragua
Member since Tue, Dec 8, 2020
4 Years ago
;