score:0
Accepted answer
You're assigning the rectangle's attributes to the group (i.e, svg:g
) beneath it. In the line below, remove the .append("svg:g")
and it should work.
square.enter().append('svg:rect').append("svg:g")
Also, you're setting opacity to zero:
.attr('opacity', 0)
This makes your rectangle invisible. Set it to 1 instead for full visibility, or some number in between for a translucent fill effect.
Source: stackoverflow.com
Related Query
- ("svg:rect") element does not appear on the screen when run
- d3.select("#element") not working when code above the html element
- Tooltip does not appear for the overlapped circles in d3.js
- D3.js Right click opens popup but does not affect the source svg when pop up closed
- d3.js node translation does not work when changed the node to image
- d3.create() returns an element with .node(), but does not display in the browser
- d3 svg zoom does not work when neighbouring element exists
- The nested in foreignobject svg does not appear
- Why does D3 not insert elements inside the selected element, when using data().enter()?
- .on("drag", function()) and .on("contextmenu", function()) does not work when used on the same code
- Is there a javascript command for 'only run when the mouse is over but stop when its not over'
- Why does the text not appear inside the svg rects
- D3.js graph does not appear when source is saved in file
- D3.js does not display anything on the screen
- D3js v4: scaleOrdinal does not have the rangePoints()
- mouseout/mouseleave gets fired when mouse moves INSIDE the svg path element
- Why does this D3 code add the <p> element outside the body, instead of inside it?
- IE11 does not accept SVG height and width when using D3
- d3.transition().attr('x', y) does not work when d3.attr('x', y) does
- d3.js when click outside the elements, hide the element
- Renderer2 does not render SVG element while using d3 js - Angular 4
- D3.js text element does not display unicode character correctly
- d3.event.x does not get the x cursor's position
- Does the d3 treemap layout get cached when a root node is passed to it?
- D3 4.0+ does not create a global d3 variable when imported into Jupyter Notebook
- bisectLeft function does not work if the second parameter is numerical
- <g> element does not adapt to <svg> on Firefox
- How to make labels appear only when the chart is zoomed in
- The mouseover event for D3.js does not work in Leaflet
- D3 word-cloud: how to auto size the font so words will not run out , and to scale words to all the screen?
More Query from same tag
- D3 Uncaught TypeError: Cannot read property 'age' of undefined
- Creating nested HTML structures with D3.js
- add brush capability in d3 line chart
- .attr not defined d3js
- How to get D3 force bubble chart to draw?
- D3.js Force Layout : How to stop initial movement in force layout graph?
- d3.js firefox mouse events perormance
- Modify HTML contents for updating nodes in D3js?
- How to properly add and use D3 Events?
- How do I access the x- and y-scale of the d3 plot in nvd3?
- D3 creating X-axis
- Unable to determine correct version D3 for sample code I found
- Issues with adding a link via mouse click to two nodes in force directed graph
- d3 timeline make axis fragmented (color-code) based on time offset
- my tooltip in d3 won't show up in the right place
- How Can I display dates on the x-axis using nvd3 line charts
- angular (1.5) nvd3 Nested Doughnut Rings
- d3.js ajax default headers/before send
- How to draw gradient arc using d3.js?
- D3 Panning Chart with Dates
- I am trying to use multiple 2 arrays for binding data for svg circles but cannot figure out how
- how to disable sorting data in x axis in d3 line chart?
- Float text to the right of D3.Js Graph
- How to modify a d3 force layout with voronoi polygons to trigger events on grouped elements?
- How to load data from Django to a variable for a D3 graph
- NVD3.js line graphs fail to scale y axis to max and min values
- 0 y axis position of SVG g element
- D3, dates on the x axis, data the width of a date
- The second call to D3 reusable line chart only draws axes but not lines
- Nodes of a radial force layout only take up a quarter of the circle