If you want the SVG to scale to fit its parent element, it needs to have a
Instead of setting the
height of your SVG, use those values for the
.attr("width", width + margin.right + margin.left) .attr("height", height + margin.top + margin.bottom);
.attr("viewBox", [0, 0, (width + margin.right + margin.left), (height + margin.top + margin.bottom)].join(' '))
You may want to tweak the width and height components of the
viewBox if you want, to remove the gap on the right, so it fits more neatly.
- Fix responsive SVG breaking out of Bootstrap grid?
- Breaking line in Bootstrap tooltip inside D3 svg
- How do I show a bootstrap tooltip with an SVG object?
- Why are some of the grid lines randomly disappearing on my responsive D3 chart?
- How can I center text on a D3.js SVG grid rect?
- SVG line out of arc starting position - d3.js
- d3-generated SVG is not responsive
- Using Bootstrap Tooltip with SVG Object - Not Displaying Despite specifying Container
- C3 chart is not visible in Bootstrap grid layout
- Bind Bootstrap tooltip to dynamically created SVG element with d3
- Bootstrap popover on svg element repositions itself incorrectly when page is scrolled
- create a responsive svg with react
- How to prevent SVG text from flowing out of its circle?
- Making a responsive angled svg shape with pattern
- SVG Text responsive positioning
- How to snap svg element to grid while dragging in force layout
- How to create responsive svg using d3.js
- How to fix unwanted circle on / break down of SVG path element for Sankey links with d3?
- I am trying to use multiple 2 arrays for binding data for svg circles but cannot figure out how
- D3js SVG open lines display a fill artifact, how to fix it?
- How can the elements in SVG can't be dragged out of the scope of SVG?
- d3.js - How to fix grid `z-index` issue?
- Fix SVG element while scrolling vertically, issues with Firefox
- How to scale svg within bootstrap panel
- How to create SVG with grid lines using D3JS
- D3: How to implement horizontally responsive SVG elements?
- SVG clipPath with USE breaking in Safari when updating linked shape
- Map zooming out of svg in IE9
- bootstrap dropdown in svg with d3
More Query from same tag
- d3.js data missing, how can I fix it?
- d3js: how to toggle css class after clicking on anelement
- D3.symbol in the corner of the screen. I would like to move it
- Fast and responsive interactive charts/graphs: SVG, Canvas, other?
- D3 tree graph with links
- D3.js Scatterplot with symbols
- How to enhance D3.js 'smooth scrolling' demo?
- d3.js transition end event
- Redrawing a D3/SVG chart for printing
- Type definition of object in d3.js version 5?
- D3 v4 force directed graph with rectangles
- D3 SVG path is not filling with linear scale gradient
- Error prerendering server of a pie chart with D3.js in svg format
- Transition chord diagram when one chord has zero value
- How to add plots on a small multiple visualization using d3
- node attributes in D3
- Bubble visualization with a JSON file
- D3.js Zooming and panning a collapsible tree diagram
- How can I set up a d3 chart inside a custom directive in Angular?
- Change text color depending on background using D3
- Set Colors of zoomable treemap conditionally
- XAxis label problems
- D3.js how do I arrange nodes of a force layout to be on a circle
- How to structure nested nodes that need updating in d3 v4 force layout?
- How to display value labels above graph bars?
- How do I append text to my rect in d3?
- D3 zoom, drag do not work on Angular2 Material Design
- Displaying data in different timezone