score:22
You can prevent the text
element receiving mouse events (and thus a mouseout event triggering when you move the mouse over it) by setting pointer-events
to none
:
svg.select("#main").append("text")
.attr("text-anchor", "middle")
.attr("pointer-events", "none")
.text(function(){ return "The movie title";});
You probably also want to set the events on the circle
and not on the g
element:
svg.select("#main").selectAll("circle")
.data(circles).enter()
.append("circle")
.attr("r",function(d){return d.r})
.attr("fill","#F0E8D0")
.on("mouseover",function(){
//code for transition
})
.on("mouseout",function(){
//code for transition
})
score:29
An alternate solution is to use mouseenter
and mouseleave
instead of mouseover
and mouseout
.
mouseenter
is similar to mouseover
except that it is not triggered when the pointer (mouse) is moved from one of listener's (circle in this case) descendants' physical space (text in this case) to its own physical space.
Same reasoning for 'mouseleave'
Source: https://developer.mozilla.org/en-US/docs/Web/Events/mouseenter and https://developer.mozilla.org/en-US/docs/Web/Events/mouseleave
Source: stackoverflow.com
Related Query
- D3.js - why mouseover and mouse out fired for each child elements?
- How can I connect two parent node into one child node and how to make a tooltip for each node in the tree pragmatically? in D3 js (SVG)
- How do I add bubbles on each of the y-axis values that I have and how do I add mouseover function for each of them?
- Inhibit mouse interactions for certain svg child elements
- How to select elements from array field in dc.js / crossfilter / d3 and use each of them as separate data point for chart?
- Appending multiple non-nested elements for each data member with D3.js
- D3.js binding an object to data and appending for each key
- Why do the mouseenter/mouseleave events fire when entering/leaving child elements in an SVG?
- Why my D3 line graphs shows black areas for each entity?
- Where can I get the .geojson file for India and not separate files for each state/territory or any other distinction?
- The mouse over event is not fired during the drag and drop action in d3.js
- d3 using a different X scale and Y scale domain for each selection
- In D3, how can I create multiple elements for each data element based on value in data?
- Mouseover issues in D3.js, containing Path elements and changing tooltip data once focus is brushed?
- D3 V4 zoom via mouse and programmatic are zooming independent from each other
- How to update multiple elements for each data
- How do i figure out the x and y position of my mouse in d3?
- why doesn't d3-geo-zoom pan correctly for more then 1 canvas elements on the page?
- Why Do I need to use Custom Event for Tooltip and Brush in D3?
- D3 mouseover effect for each chart on one page
- How to specify the colors and toggle labels for each category in R sunburst?
- D3 and SVG namespaces for custom svg elements or attributes to be valid?
- Simultaneously extracting list of dimensions and creating scale for each in d3.js - Expand on process?
- D3 is attempting to set attributes of SVG as NaN and I can't figure out why
- d3 multi line with mouse over cursor for both y AND x value
- Sankey Diagram (D3) - How to use multiple units for link values and how to add notes to mouseover popup box?
- Fill same line color in to circle on Multi Line chart when mouse over and remove color from circle when mouse out
- How to insert text sibling elements for each existing circle element of svg group?
- Axis and svg text elements hide each other
- Separate mouse clicks for circles and background in D3 circle pack
More Query from same tag
- How to Scale/Choose D3 Projection Settings from .shp File
- Treemap in d3 v5 doesn't support nodes anymore
- How to animate drawing a sequence of line segments
- How do I draw line from the outer most arc of the circle
- Can I call a JavaScript function on an iFrame or similar widget from Python?
- python-nvd3 lineplusbarwithfocus chart error
- D3 : Retrieve data from SVG
- Adding points to Voronoi Diagram in d3
- How do I create and write to a new file (csv) and have the browser download it with javascript or D3.js?
- How to scale an integer to date with range and domain
- d3.js creating two elements per data point
- I cannot select the ("text") in my svg when I want to change the values
- d3.json works but $.getJson fails
- (c3.js) how to capture a column state, wheter it's shown or not in the graph?
- how can i extend a d3 interface in typescript?
- D3.js clip paths cut off the edge of my graph
- Highlight all content inside g tag, whenever mouse above said tag. D3
- d3 circles shifting position on click-to-zoom
- VueJS lifecycle after submit form
- Export manually edited htmlwidget to SVG or similar
- Grouping a nested array
- AngularJS D3. How to append anything to existing graph (draw over it)?
- D3.js Fisheye.js strange mousemove behavior
- Convert d3 chart (svg) to an image and display it
- D3.JS: How to animate lines
- How to specify timeout in d3 xhr send request
- Pan/Zoom to specific group ID/getBBox() with d3.behavior.zoom
- D3 update pattern not working as expected
- Clear the interval in d3.js
- d3 Uncaught TypeError: zoomed.x is not a function