score:1
Accepted answer
If you want the position of the circle you moused-over, I would create my .on
handler on the circles instead of the g
element (this way you know which element received the event):
...
var circles = circleGroup.selectAll("circle")
.data(circleData)
.enter()
.append("circle")
.on("mouseover", mouseover)
...
function mouseover() {
var self = d3.select(this);
alert(self.attr('cx'));
}
Updated fiddle.
EDITS FOR COMMENT
Opps, missed the transition. How about:
function mouseover()
{
var self = d3.select(this);
var translate = d3.transform(self.attr("transform")).translate;
alert(+self.attr('cx') + translate[0]);
}
Updated fiddle 2.
Source: stackoverflow.com
Related Query
- How to get a circle position in a g element in SVG using D3.js
- How do I change the position of a circle svg element using the transform attribute?
- How do I get the width of an svg element using d3js?
- How to get reference to SVG (child) elements nested in another SVG element (parent) using D3?
- How to get SVG child element position relative to SVG position on page, D3.js?
- How to create variable number of image or circle elements in an SVG element using a loop in D3 js(v3)
- how i get height of a svg element using d3js
- how to get svg element type
- Using Javascript D3 library, how can I determine mouse position in data set of an area element on mousemove event?
- How to get value from the element using selection in d3
- How to get web element (id) from the element position in D3.js force graph
- How do I get the d3 svg points to stay in their correct position on the leaflet map when zooming?
- What is the fastest way to get SVG element given a position (x,y)?
- How to get SVG circle to drag along SVG path?
- How to get the svg position within document?
- How to fix unwanted circle on / break down of SVG path element for Sankey links with d3?
- how to get the coordinates of the center of a circle using d3.js
- Using d3.behavior.drag, How to keep a drag image visible outside of the svg element
- How to get position of empty SVG group?
- How can I get the dom svg element from d3 node data?
- D3JS: help to create a SVG text element inside a circle using D3js
- How can I animate the top of my svg element like in this gif using d3.js?
- How to change properties of elements in a SVG when I mouseover an element of a second SVG using D3
- How to select all types of child element inside an SVG using d3.js
- How to insert text sibling elements for each existing circle element of svg group?
- D3/SVG. How do I position a child svg element beyond its parent's extent?
- Get the closest element to a SVG node using Jquery closest() function
- How to get element on mouse position within d3.xhr and async queue?
- How can I get this svg circle to appear above my d3 path and not below?
- How to get the position and width of a tspan element
More Query from same tag
- How to make ordinal tick labels adjust automatically in D3
- NPM Issue with @types/d3 install from Oreilly book code
- Refactoring d3js: multiple arcs & text blocks into tidy js functions
- How to chain a JS function with d3.transition
- Removing bar graph's bars, on click
- How can is draw rectangle based on two date?
- Learning D3 Js with Observablehq
- Cursor is always crosshair in D3 due to slider
- Keeping element order (selection.order) with exit transitions in d3
- Why exit() not work here?
- Django translations - translate days of week
- d3 globe - says rotate is not a function
- Simple bar chart in d3.js
- D3: Create bars of many colored rectangles
- d3 Force Directed Graph General Update Pattern - exit() selection not working
- D3.js and dragdealer JS
- How can I make last node in d3 zoomable sunburst as a hyperlink?
- How to understand isNaN
- Instantiating text elements of correct type SVGTextElement before appending
- How to prevent d3 from triggering drag on right click?
- Rect in in d3js svg disappears after routing to another page in AngularJS
- Draw rect according to json array?
- What is the best way to fill D3 node circles with images?
- Unable to apply sort to rects
- Getting error on applying transition in d3
- d3-voronoi-map path not drawn
- D3.js: Placin' the text on the arcs of the doughnut chart
- Rotated rectangle not match text bbox
- How to get a subselection of a D3.js selection
- d3.json cant read from json file more than one object