javascript - NVD3 Chart responsive issue -


nvd3 responsive issue

i have code second page used same chart here. on page responsive , trying figure out why chart not responsive here.

enter image description here

  var colors = ["rgba(74, 210, 255, .8)", "rgba(85, 172, 238, .8)", "rgba(205, 32, 31, .8)"];    d3.scale.colors = function() {          return d3.scale.ordinal().range(colors);      };        var colors = d3.scale.colors();      /*var colors = d3.scale.category20();*/       var keycolor = function(d, i) {return colors(d.key)};            var chart;      nv.addgraph(function() {          chart = nv.models.stackedareachart()              .useinteractiveguideline(true)              .x(function(d) { return d[0] })              .y(function(d) { return d[1] })              .showcontrols(false)              .showyaxis(true)              .showlegend(false)              .rightalignyaxis(true)              .controllabels({stacked: "stacked"})              .color(keycolor)              .duration(500);            chart.xaxis.tickformat(function(d) { return d3.time.format('%a')(new date(d)) });          chart.yaxis.tickformat(d3.format('f'));            chart.legend.margin({                          top: 30                      });            d3.select('#chart1')              .datum(histcatexplong)              .transition().duration(1000)              .call(chart)              .each('start', function() {                  settimeout(function() {                      d3.selectall('#chart1 *').each(function() {                          if(this.__transition__)                              this.__transition__.duration = 1;                      })                  }, 0)              });            nv.utils.windowresize(chart.update);          return chart;      });
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>    <div class="slide1">     <div class="col-xs-12" id="margin-chart">        <svg id="chart1" style="width: 100%; height: 300px;"></svg>     </div>  </div>

you need call chart.update() when slidetoggle function finishes make nvd3 redraw chart new dimensions.

i.e.:

$('#chart').slidetoggle(function() {     chart.update(); }); 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -