javascript - How to make the dc.js charts responsive -


is there way make dc.js charts responsive?

i'm struggling lot make charts fit desktop size.

i'm using twitter bootstrap 3. store width of div variable , pass chart width. not make chart responsive. on first load charts width according size of screen.

but face challenge in it, have different file dc.js chart.

and i'm calling through iframe.

when call through iframe width 0 divs, , no charts appear in webpage.

but when reload iframe alone, charts appearing.

i tried load frame when click on particular navigation item. didn't work me.

someone me overcome issue.

i've set plunker dc.js demo have rerendering when resized, , getting width of container element determine size. embedded in iframe , working as-is. suggest playing plunker fit css, i'm making simplest possible iframe setup. i'm imagining did similar this, i"m not sure went wrong. helps.

responsive dc chart in iframe

given standard page iframe:

<body>   <h1>test</h1>   <iframe src="iframe.html" class="iframe"></iframe> </body> 

and iframe containers , scripts load chart:

<body> <h2>inside iframe</h2>     <div id="box-test"></div>    <div id="pie-chart"></div>     <script src="script.js" type="text/javascript"></script>  </body> 

a call width need

var width = document.getelementbyid('box-test').offsetwidth; 

using width initial render

chart   .width(width)   .height(480)   .margins({top: 10, right: 50, bottom: 30, left: 50})   .dimension(experimentdimension)   .group(speedarraygroup)   .elasticy(true)   .elasticx(true); 

and function handle on window resize

window.onresize = function(event) {   var newwidth = document.getelementbyid('box-test').offsetwidth;   chart.width(newwidth)     .transitionduration(0);   pie.transitionduration(0);   dc.renderall();   chart.transitionduration(750);   pie.transitionduration(750); }; 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -