Closed velociwabbit closed 5 years ago
I have done some more research about this issue .
I am not at all sure what the x and y values in the transform refer to because i tested a centered zoom (where the xy cross is at w/2 h/2 and came up with some really interesting data
I start zooming and x=y=0 and k=1. then i zoom in and clientX clientY stay the same throughout all of the actions
But transform x and transform y change... which makes no sense to me (given that the clientX and cleintY have not changed... only the wheel zoom in function.
Why would x and y change values if i am zooming in using the wheel at 0,0 offset?
Also the 0,0 values for x and y when i start to pan are the reason why panning does not work. They should reflect the dragging of the mouse after the first mousemove.
I looked at the scaleX scaleY source code and it is a bit of a head spinner. There is no easy way to track the act of transforming back to an individual pixel value for a point.
If this data is all correct then what does the dishwasher do ( ok bad joke but i hope you get my point)
Transform
x ,y ,k , clienX, clientY
0 0 1.00 342 406
-46 -46 1.15 342 406
-98 -98 1.32 342 406
-159 -159 1.52 342 406
-228 -228 1.74 342 406
-308 -308 2.00 342 406
-400 -400 2.30 342 406
-505 -505 2.64 342 406
-626 -626 3.03 342 406 zoomin in
-765 -765 3.48 342 406
-924 -924 4.00 342 406
-1107 -1107 4.59 342 406
-1318 -1318 5.28 342 406
-1559 -1559 6.06 342 406
-1837 -1837 6.96 342 406
-2156 -2156 8.00 342 406 zooming out
-1837 -1837 6.96 342 406
-1559 -1559 6.06 342 406
-1318 -1318 5.28 342 406
-1107 -1107 4.59 342 406
-924 -924 4.00 342 406
-765 -765 3.48 342 406
-626 -626 3.03 342 406
-505 -505 2.64 342 406
-400 -400 2.30 342 406
-308 -308 2.00 342 406
-228 -228 1.74 342 406
-159 -159 1.52 342 406
-98 -98 1.32 342 406
-46 -46 1.15 342 406
-0 -0 1.00 342 406
40 40 0.87 342 406
75 75 0.76 342 406
132 132 0.57 342 406
155 155 0.50 342 406
175 175 0.44 342 406
155 155 0.50 342 406
132 132 0.57 342 406 way out
105 105 0.66 342 406
Please use Stack Overflow tag d3.js to ask for help. Stack Overflow provides a better collaborative forum: thousands of D3-related questions have been asked there, and some answers may be relevant to you.
When asking for help, please include a link to demonstrate the issue, preferably as an Observable notebook. It is often impossible to debug from code snippets alone. Isolate the issue and reduce your code as much as possible before asking for help. The less code you post, the easier it is for someone to debug, and the more likely you are to get a helpful response.
If you have a question about D3’s behavior and want to discuss it with other users, also consider the d3-js Google Group or joining the d3-js Slack.
Thank you! 🤗
so it is not a bug?
It’s hard to tell from your description what problem you are reporting. It’s expected that transform.x and transform.y can change when you zoom in using the wheel if the mouse isn’t exactly at the origin (in the local coordinates of the zoomed element).
When reporting an issue, please include a link to a live example, preferably as an Observable notebook or as a pull request in the appropriate repository with tests. You should demonstrate that the described behavior is not the expected behavior using the minimum amount of code.
A good bug report should isolate specific methods that exhibit unexpected behavior and define precisely how expectations were violated. What did you expect the method or methods to do, and how did the observed behavior differ? By isolating the issue, you assist the investigation.
Non-actionable bugs may be closed until you provide additional information. If you can’t isolate the bug further, please reply and ask for help. However, please be patient: open-source maintainers have many competing responsibilities—fixing other bugs, answering questions, developing features, writing documentation, etc.
The problem is that i am not sure that the observed it is incorrect. I will research it further this evening
sorry for not following protocol.
On Tue, Aug 27, 2019 at 2:50 PM Mike Bostock notifications@github.com wrote:
It’s hard to tell from your description what problem you are reporting. It’s expected that transform.x and transform.y can change when you zoom in using the wheel if the mouse isn’t exactly at the origin (in the local coordinates of the zoomed element).
When reporting an issue, please include a link to a live example, preferably as an Observable notebook https://observablehq.com or as a pull request in the appropriate repository https://github.com/d3 with tests. You should demonstrate that the described behavior is not the expected behavior https://github.com/d3/d3/blob/master/API.md using the minimum amount of code.
A good bug report should isolate specific methods that exhibit unexpected behavior and define precisely how expectations were violated. What did you expect the method or methods to do, and how did the observed behavior differ? By isolating the issue, you assist the investigation.
Non-actionable bugs may be closed until you provide additional information. If you can’t isolate the bug further, please reply and ask for help. However, please be patient: open-source maintainers have many competing responsibilities—fixing other bugs, answering questions, developing features, writing documentation, etc.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/d3/d3-zoom/issues/189?email_source=notifications&email_token=ACHMT3KAUTTBGNTJTFSWDETQGWOTLA5CNFSM4IQIRO72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5JHHUA#issuecomment-525497296, or mute the thread https://github.com/notifications/unsubscribe-auth/ACHMT3NQHRPLHTZFR6OQLATQGWOTLANCNFSM4IQIRO7Q .
If you want me to look, please post live code. Good luck with your research!
Ok here is live code.
The crosshairs are at exacly xy 300,300
If you move your mouse to that value and then wheel in or out (it takes some fiddling to get exactly on that value).
But once you are on it (the tool tip will show you) The transform x and transform y values increase or decrease by about 40 for every 0.20 of wheel increase or decrease.
It was my understanding that pure scale (which is a wheel in or wheel out at the center of the svg) should have d3.event.transform.x and d3.event.transform.y values of zero.
I am thinking that this is a matrix affine transformation issue or a viewing frustum change of some sort.
I have looked at the code for scaling which is a normalize then interpolate which is fine. I am struggling to understand why these x and y values are changing when clientX and clientY are staying the same.
I am flummoxed ... where are the x and y values calculated and why are they changing for ostensibly a scale from center?
<html><body style= ' margin :0px; padding:0px; '>
<svg style= ' margin :0px; padding:0px; ' >
<line class="linex" stroke="#ff00ff" x2="600" y1="300" y2="300" ></line>
<line class="liney" stroke="#ff00ff" x1="300" x2="300" y2="600" ></line>
</svg>
<div id='loc' style="position:absolute; top :-1025px; left:100px; display:block; z-index:1000; line-height: 1.5; font-weight: 400; font-family: Roboto; font-size: 16px; color: #00b4dc; padding: 20px; background: #ffffff; border-radius: 3px; " ></div>
<script src="https://d3js.org/d3.v4.js"></script>
<script>
var data = [ { x : "0.0005" , y : "0.0011" }
, { x : "0.0039" , y : "0.0007" }
, { x : "-0.003" , y : "0.0005" }
, { x : "0.005" , y : "0.0347" }
, { x : "0.0005" , y : "0.005" }
, { x : "0.0004" , y : "0.0006" }
, { x : "0.0005" , y : "0.0006" }
, { x : "0.0005" , y : "0.0056" }
, { x : "0.0049" , y : "0.0043" }
, { x : "0.0049" , y : "0.0053" }
, { x : "0.0049" , y : "0.0017" } ]
var svg = d3.select('svg');
var xScale = d3.scaleLinear().domain([-.1, .1]).range([0 , 600])
var yScale = d3.scaleLinear().domain([-.1, .1]).range([ 600, 0 ])
var zoom = d3.zoom().on('zoom', () =>{
document.getElementById('loc').style.left = ( d3.event.sourceEvent.clientX + 10) + 'px'
document.getElementById('loc').style.top = ( d3.event.sourceEvent.clientY + 10) + 'px'
document.getElementById('loc').innerHTML = '[ ' + d3.event.sourceEvent.clientX + ',' + d3.event.sourceEvent.clientY + ']' + '<br/> tranx = ' + d3.event.transform.x.toFixed(0) + '<br/>trany = ' + d3.event.transform.y.toFixed(0) + ' <br/>tran k = ' + d3.event.transform.k.toFixed(2)
scat.attr('transform', d3.event.transform) })
var scat = svg.attr('width', 600).attr('height',600).call(zoom).insert('g', ':first-child')
scat.selectAll('circle').data(data).enter() .append('circle') .attr('r', 5 ).attr('cx', d => xScale(d.x) ).attr('cy', d=> yScale(d.y )).style('fill', ()=> '#00b4dc' )
</script>
I am not sure if this is a bug or a design feature. (I could argue both ways).
I have setup a rect with a zoom call as follows
But it will not generate an event call for mousedown panning until after a wheel event has fired.
Is this on purpose?
Also in looking at the transform x and y coordinates they appear to be in % of screen is this correct?
In other words when i put my mouse in the lower left corner i get [0,97.] and the opposite for the upper right corner. I just want to confirm this because I cannot move the mouse to generate a 99% on either axis.
thanks