我正在使用Highcharts-NG向我的Angular-Firebase应用添加highcharts,并且高图不假设div的大小。但是,当我检查元素时,我可以自定义图表大小,它神奇地假设div大小。我已经完成了一次搜索并尝试了一些我找到的修复但没有工作。这是一个已知的问题?如何在没有检查元素的情况下正确调整大小?
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,
};
答案 0 :(得分:1)
我发现没有那么精致的方法来修复它。只需添加以下行:
setTimeout(function() {
$(window).resize();
}, 0);