First off, the <g> element doesn't care about
y attributes (as in: they're just ignored). You can use
Second, you will need to check that the element you get in the dragmove handler actually is the <g> element, and not a child element of it. This is because <g> elements have no actual hit area themselves. Their children do though, and the mouse events first go to the children then bubble up to the parent. You can inspect
evt.currentTarget to see this in action.
target is the element that was hit originally,
currentTarget is the event target that is currently handling the event (e.g the <g> element if the event bubbled up).