2

我正在使用 Highcharts-NG 将 highcharts 添加到我的 Angular-Firebase 应用程序中,并且 highchart 没有假设 div 的大小。但是,当我检查元素以便可以自定义图表大小时,它会神奇地假定 div 大小。我已经进行了搜索并尝试了一些我找到的修复程序,但没有任何工作。这是一个已知的问题?如何在不检查元素的情况下使其正确调整大小?

我在这里有一个关于这个问题的 youtube 视频:链接

<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,
        };
4

1 回答 1

1

我发现没有那么微妙的方法来解决它。只需添加这些行:

 setTimeout(function() {
                    $(window).resize();
                }, 0);
于 2015-06-29T15:51:19.563 回答