score:1
Accepted answer
SVG attribute preserveAspectRatio
indicates whether or not to force uniform scaling.
xMinYMin - Force uniform scaling. Align the of the element's viewBox with the smallest X value of the viewport. Align the of the element's viewBox with the smallest Y value of the viewport.
<svg preserveAspectRatio="xMinYMin" viewBox="0 0 300 100"></svg>
Note viewBox as opposed to width and height attributes.
Source: stackoverflow.com
Related Query
- How can I scale an SVG so that the content drawn in it to fit the container size?
- How can I scale my map to fit my svg size with d3 and geojson path data
- How can I center my maps on the container and adjust the size so that it occupies the entire container?
- How can I copy the content of my SVG and append it to another SVG frame?
- How can I fix my chart so that the scale of the x axis is defined by a group of labels?
- How can I exactly fit the size of a map to the container?
- How to access the DOM element that correlates to a D3 SVG object?
- d3.js - How can I set the cursor to hand when mouseover these elements on SVG container?
- How can I set the each line color or width in SVG path
- How to use SVG gradients to display varying colors relative to the size of the colored region
- How can I display a placeholder image in my SVG until the real image is loaded?
- How can I find the translated co-ordinates of an SVG element?
- How can I get the natural width and height of an svg image element?
- D3 word-cloud: how to auto size the font so words will not run out , and to scale words to all the screen?
- D3 renders SVG. How can I get that SVG programmatically?
- How can I determine the overall size of a force directed graph
- How can I dynamically change the position and the size of direction arrows on a directed d3.js force layout?
- How to get the width and height of an image? ( getBBox() size of SVG return 0 )
- How to get a value from a stylesheet into the code so that it can be used programmatically?
- How can the elements in SVG can't be dragged out of the scope of SVG?
- How can I put the Germany map on a svg in HTML? D3js
- how can I see the current element that represents a bar to which the hovering is applied
- How can I get the dom svg element from d3 node data?
- How can I apply a clipPath in SVG with multiple paths and NOT clip out the area between the paths?
- How can I animate the top of my svg element like in this gif using d3.js?
- How to set the exact size of an inline SVG element?
- Sometimes svg chart doesn't fit in the container but it works when screen refresh
- d3.js: How to deal with svg elements that are being appended on the same position, one on top of the other?
- D3.js: how to decide both the area and the color of each square by the size of each content in treemap?
- How can I set the background color of a svg element which contains a D3 heat map?
More Query from same tag
- Saving data from the d3.js ajaxrequest in a variable to create axis with data
- How to add drop shadow to d3.js pie or donut chart
- Can you set style in d3 via something like foo.style({color:blah, background:blah})?
- D3: setting scale on choropleth map
- Why "d" is undefined in attrTween?
- D3: Create bars of many colored rectangles
- D3.js Highlighting links on node selection
- D3.js grouped bar chart rendering x axis incorrectly
- dimple.js - scatter-plot, series listed twice in tooltip
- custom tooltip on cumulativeLineChart in nvd3
- NVD3 - line chart NaN on safari using latest versions
- dc.js - d3.js LineChart under CompositeChart hide axis indexer
- Convert R dataframe into tough JSON list of lists for d3.hierarchy model
- How to register multiple external listeners to the same selection in d3?
- dimplejs timeseries is not plotting with timeaxis
- images generated to canvas from svg, animation result, looks slow
- Wrapping D3 functions inside objects doesn't work. Why?
- Plotting an empty interval for elasticsearch date histogram
- d3.path plots only first feature of feature collection
- D3 - Having trouble updating stacked bar chart
- Transition on axis with appended text
- Using generic function for drawing line d3js
- Install D3 on Meteor Angular2
- Control multi line spreading of x-axis tick in billboard.js
- c3 click and highlight multiple selections
- Change the Class attribute
- D3js within Java application
- How to draw single Pixel lines with d3.js / SVG
- how to make scrollable axis/ pan along x-axis in d3js
- Drag and Drop functionality in D3 tree for touch devices