I am adding highcharts to my Angular-Firebase app using Highcharts-NG and the highchart is not assuming the size of the div. However, when I got to inspect the element so I can custom size the chart it magically assumes the div size. I've done a search and have tried some of the fixes I have found but none work. Is this a known issue? How do I get it to size properly without inspect element?
I have a youtube video of the problem here: LINK
<div ng-show="overviewOn">
<div class="col-md-12 text-center">
<table class="table table-bordered">
<thead>
<th>Total Score</th>
<th>Strokes Gained Putting</th>
<th>Penalty Strokes</th>
</thead>
<tbody>
<td>{{round.totalScore}}</td>
<td>{{round.sgPutting | number:2 }}</td>
<td>{{round.penalty}}</td>
</tbody>
</table>
</div>
<div class="col-md-12 shotTypeChart">
<div style="width:100%;margin: 0 auto">
<highchart id="sgShotTypeChart" config="sgShotTypeChartConfig"></highchart>
</div>
</div>
<div class="col-md-12 clubChart">
<highchart id="sgClubChart" config="sgClubsChartConfig"></highchart>
</div>
</div>
$scope.sgClubsChartConfig = {
options: {
chart: {
type: 'column'
},
plotOptions: {
column: {
dataLabels: {
enabled: true,
crop: false,
overflow: 'none',
formatter: function () {
return Highcharts.numberFormat(this.y, 2);
}
}
}
},
tooltip: {
pointFormat: "Strokes Gained: {point.y:.2f}",
style: {
padding: 10,
fontWeight: 'bold',
}
}
},
series: [{
showInLegend: false,
data: sgByClubData,
name: 'Strokes Gained'
}],
title: {
text: 'Strokes Gained by Club'
},
loading: false,
yAxis: {
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: 'gray'
},
},
title: {
text: null
}
},
xAxis: {
categories: clubsData,
},
credits: {
enabled: false
},
useHighStocks: false,
};
I've found not so delicate way to fix it. Just add these lines:
setTimeout(function() {
$(window).resize();
}, 0);
来源:https://stackoverflow.com/questions/28835572/highcharts-ng-size-does-fill-div-until-inspect-element