Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

d3 chart displayed outside bootstrap div

i'm facing with an issue where in d3 bar chart is getting generated outside div region on each selectpicker selection.

var svg = d3.select("#barchart").append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom)
  .append("g")
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

Full blown code can be found at the below jsbin location

http://jsbin.com/sodivamiqa/edit?html,js,output

Month,Success_Count,Failure_Count
Dec,32,12
Jan,35,5
Feb,5,2
March,40,2
April,30,25
May,12,10

Output Image

like image 597
Ahshan Md Avatar asked May 12 '16 04:05

Ahshan Md


1 Answers

100% will keep it inside the div.

var svg = d3.select("#barchart").append("svg")
            .attr("width",'100%')
            .attr("height", '100%')
            .append("g")
            .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
like image 71
YaakovHatam Avatar answered Nov 10 '22 10:11

YaakovHatam