score:5
Just use the tagName
property:
svg.select("." + STYLE.selected)
.call( function(){
switch( selectedElement.tagName.toLowerCase() ) {
case 'circle':
alert("here circle");
this.style("fill", function(){return d3.rgb(d3.select(this).attr("fill"));});
break;
case 'path':
alert("here path");
appendMarkerm( this, false );
break;
}
});
EDIT
d3js' select()
does not return the element itself, but a d3js wrapper for it (very much like in jQuery, e.g.). So the easiest way, would be to use the call()
method to apply a function to all matches (in the case of just select()
this is just one).
Source: stackoverflow.com
Related Query
- how to get svg element type
- 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 can I get the dom svg element from d3 node data?
- How to get a circle position in a g element in SVG using D3.js
- How to get SVG child element position relative to SVG position on page, D3.js?
- how i get height of a svg element using d3js
- How to access the DOM element that correlates to a D3 SVG object?
- How to get coordinates of an svg element?
- In d3, how to get the interpolated line data from a SVG line?
- Get width of d3.js SVG text element after it's created
- how to assign unique id to SVG text element in d3 javascript
- How do you make an SVG element mouse event bubble up through another element?
- how to get dynamic value of input element with d3?
- How can I get "call" to execute for each data element in D3?
- Get class of selected svg element in d3
- how to get the type of a scale in D3?
- how to access data of a d3 SVG Element
- How to get biggest array element based on his second sub array value
- How can I convert SVG coordinates (x,y) defined relatively to an element into absolute coordinates/position?
- How can I get the natural width and height of an svg image element?
- How can I pass attributes of an SVG element to a new event in D3?
- How can I get this D3.js HTML element in my AngularJS so that I can manipulate it?
- How to assign click event to every svg element in d3js
- How to transform (rotate) svg text element without changing coordinates?
- 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 $compile a directive on an dynamically created SVG element
- how to get attributes of element current pointed by mouse
- how to add dragend event on svg element
More Query from same tag
- D3 make g element drag
- How I can turn a figure that is upside down?
- How to get an item from d3 collection by index?
- d3 sunburst chart selection rotation not working
- D3.js (Wilkinson type) Dot Plot Example
- Combining a selection-rectangle with zoom + pan in a D3.js 4.x Force Simulation
- Unnesting and reducing data structures in javascript
- Reactjs with D3js treemap
- Combining data fetch and array iteration
- Introducing Arrow(directed), in Force Directed Graph d3
- d3: Calculate midpoint of line between two nodes, draw line extending at 90 degree angle from it to a new node
- D3 samples in a Microsoft Stack
- dragend with d3.JS
- d3.js tree with json string dont recognize as Array
- D3 merge colors to gradients
- D3 fill shape when draw with path
- how find out if force layout done placing the nodes?
- Mouse Wheel Zoom Map - DataMaps.js
- Redraw function on dropdown change with javascript
- Why piecharts begin drawing from different angles in D3?
- d3.js duplicate code for enter selection and update selection
- Using json in d3
- LinePlusBarChart with date interval outside domain
- Inverting SVG image mask
- D3 area graph transition from bottom
- D3 manually position nodes with certain ID
- ReferenceError: dc is not defined, even after importing d3,dc and crossfilter in order
- d3.js v4, adding text labels to bubbles on a bubble chart
- Changing labels of json for d3 sunburst diagram
- Save selected D3.js Treemap nodes to local file