Active
Project:
d3.js
Version:
7.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
30 Dec 2013 at 17:14 UTC
Updated:
4 May 2015 at 00:41 UTC
Jump to comment: Most recent
Comments
Comment #1
asherry commentedIt's a great idea. Do you have any current working examples out there? This is mostly on the js side.
Comment #2
miromarchi commentedNo working example. And also at the moment, my programming skills are low and I don't know how to work on it, also I lack of time. I moved this to a future sprint. I'm working on http://www.retebuonvivere.org/rete (rete means network in italian). So, I opened this issue only to share the simple idea of a fit screen
space. At the moment I only tried to set width to 100% in d3 graph view - graph rendering - settings, but this results in a crushed svg space. On the contrary, if I set the settings to a normal width: e.g. 800, and then, using the browser Inspect-element function, I change it to 100%, it works exactly the way I expect: fit to width of parent div.Comment #3
miromarchi commentedI ended up with a more responsive layout. As you said this is on the js side. I paste the lines in our d3.network library (which btw anyone can get at https://github.com/miromarchi/rbv_network:
This is not completely responsive, because if you resize the window the layout doens't follow. But when the page loads it fits always the container as I wanted. It's something!
Comment #4
karolus commentedThere is also another way to make a chart scale for responsive/fluid areas.
1. Add this code to your JS for the chart, within the variable defining the SVG d3.select:
Here, viewBox is set to 400 x 400px as default, but will scale to any size.
2. Add this to your CSS (may need to make some adjustments per your specific usage):
As you can see, some settings are commented out, but may work better in your situation.
And, as a caveat, the graph scales, but preserves aspect ratio, as a flat SVG image would. I don't know of any way to make a D3 chart fluid.