score:3
Accepted answer
Robert's answer already covers how to solve the problem, but here's the D3 way of doing it in addition. In particular, you can use d3.transform()
to parse the value of the transform
attribute:
var t = d3.transform(d3.select(this).attr("transform"));
console.log(t.translate);
Updated jsfiddle here;
score:3
You can use getAttribute e.g.
this.getAttribute("transform")
or the SVG DOM
this.transform.baseVal.getItem(0).matrix.e + ", " + this.transform.baseVal.getItem(0).matrix.f)
baseVal.numberOfItems gets you how many components there are to the transform and getItem(0).type gets its type i.e. 2 = translate in this case.
This alerts 50, 50 for me on Firefox.
Source: stackoverflow.com
Related Query
- How to get translate property from a group?
- How to get maximum value from an array of objects to use in d3.scale.linear().domain()
- In d3, how to get the interpolated line data from a SVG line?
- D3js: how to get Lat/Log geocoordinates from mouse click?
- D3 - How to get correct scale and translate origin after manual zoom and pan to country path
- How to get the data from the c3.js
- How do I use d3.domain to get d3.min and d3.max from multiple columns in a JSON file?
- 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 to get the specific JSON array from a value in that array
- How to get projected path definition strings (not SVG elements) from a GeoJSON dataset with D3?
- How to summarize an array with group and rollup from d3-array?
- How to get text() from checkbox if is checked?
- How can I get a list of tree-ancestors and tree-descendants from this d3.js layout.tree?
- how to get data with tsv or csv to array in d3.js from a txt file?
- How to use python pandas to get intersection of sets from a csv file
- How do I get the index number from the array in d3?
- How do I get data from a rectangle in D3?
- Passing JSON from Grails Controller to d3 - how to get the .gsp side working?
- NVD3: How to get values from tooltip or legend instead of labels?
- How to get a value from a stylesheet into the code so that it can be used programmatically?
- How to get the background attribute from the nodes of treemap in d3?
- How to get the X value of a ticks from the x axis?
- dc.js - how to get chart.chartGroup to put the chart in the group
- How do I move an svg node from one group to another?
- How to debug when get error from D3
- How to get corresponding colors from d3 sunburst parent to final child?
- How can I get the dom svg element from d3 node data?
- How to get data from d3js polyline?
- How to get a single property of all children in a nested object using javascript?
More Query from same tag
- Bar chart with d3.js and an associative array
- How to make grouped stacked bar chart in d3js?
- d3.js circle hover animation
- 10 points within unit circle - finding optimal distribution with D3 force layout?
- D3.js nodes jump when restarting simulation to add or remove nodes
- d3.js using a conditional return within text attribute
- D3 removal animation 'delayed' by updating - any way to prevent multiple calls to the same animation?
- How can you access data that's nested like this in a csv file?
- D3 V3 to D3 V4 Tree Array Reordered Wrong Using Hierarchy
- D3.js how to create this zoom behavior?
- d3 zoom - how to set initial transform
- reusable Bar chart showing bars one over another which have same names
- round SVG images on Joomla site do not get displayed in Firefox
- Memetracker like visualization code
- Append a line to an end of a path in area chart d3
- How to fix map boundaries on d3 cartographic raster reprojection?
- Show text only after transition is complete d3.js
- How to select elements according to an attribute(fill color) in D3.js with SelectAll
- D3 - ticks wrong positioned
- Resize graph plotted in d3.js graph
- Taking time duration in json
- How do I count distinct values in d3 nest rollup?
- D3 Bar chart - Remove labels with zero value
- How to make a moving transition of points from a to b
- Webpack error: Module has no exported member 'Rgb'
- Dimple.js line chart with composite axis, no links between points on series
- Repeat an object with different input data
- Interactive Notes in a div element from table d3.js
- D3 x-axis tick format & tick value issues
- d3.js - Reload chart