Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Danielle Hill
26,062 PointsResponsive d3.js
Can anyone offer insight on how to make my d3.js svg bar graph responsive? I'm working on a project and can't get the svg to resize.
3 Answers

Zoltán Holik
3,401 Points d3.select(window).on('resize', resize);
function resize(){
// need to update all the svg chart properties
}
And try to do not use fixed width and height values for the SVG.
http://eyeseast.github.io/visible-data/2013/08/28/responsive-charts-with-d3/
Danielle Hill
26,062 PointsThanks for the insight Zoltan!

Fidel Torres
25,286 PointsI have added svg width: 100% height:100%
and a css class to the svg element in my case rect with this on them
transform: scale(0.125); // this one for mobiles to follow Mobile first @media only screen and (target tablet/desktop){ transform: scale(0.5);//bigger number that matches your screen