我正在尝试在引导面板内呈现角度图表(基于 chart.js)图表。目前,图表在面板内时根本不显示,但在放置在面板外时会显示。当我在浏览器中查看源代码时,我看到高度和宽度设置为零。
图表不显示
<div class="panel-group" ng-model="experiments.active" role="tablist" aria-multiselectable="true" bs-collapse>
<div class="panel panel-default" ng-repeat="experiment in experiments">
<div class="panel-collapse" role="tabpanel" bs-collapse-target>
<div class="panel-body">
<canvas id="pie" class="chart chart-pie" data="viewCountData" labels="viewCountLabels" options="viewCountOptions" style="height: 50px; width: 50px"></canvas>
</div>
</div>
</div>
</div>
图表确实显示
<div class="panel-group" ng-model="experiments.active" role="tablist" aria-multiselectable="true" bs-collapse>
<div class="panel panel-default" ng-repeat="experiment in experiments">
<div class="panel-collapse" role="tabpanel" bs-collapse-target>
<div class="panel-body">
</div>
</div>
</div>
</div>
<canvas id="pie" class="chart chart-pie" data="viewCountData" labels="viewCountLabels" options="viewCountOptions" style="height: 50px; width: 50px"></canvas>
页面来源:
不确定高度和宽度设置为零的位置或原因。我也尝试过在css中设置高度和宽度,但仍然没有运气。
.chart {
height: 400px;
width: 600px;
}
#pie {
height: 400px;
width: 600px;
}
我也尝试过调整图表选项
viewCountOptions = {
responsive: false,
maintainAspectRatio: false
};