gpt4 book ai didi

javascript - Angularjs 和谷歌图表 API : chart type is not defined

转载 作者:行者123 更新时间:2023-11-28 06:50:15 25 4
gpt4 key购买 nike

我正在开发一个 Web 应用程序 (Angularjs-J2EE)。在主页上我显示了一个图表。当我启动服务器(Tomcat)后第一次访问此主页时,我收到此错误:

Chart not displayed due to error: The chart type is not defined.. Full error object follows. ng-google-chart.js:197 Object {id: "google-visualization-errors-0", message: "The chart type is not defined."}

如果我刷新主页,就不会再出现此错误。图表显示良好。
如果有人知道为什么...

谢谢。

Controller :

$scope.chartObject = {type:"PieChart"};
var datas = CaNetPieChart.query(function(){
$scope.chartObject.data = {"cols": [
{id: "t", label: "Article", type: "string"},
{id: "s", label: "Colis", type: "number"}
], "rows": [
{c: [
{v: "CA Net"},
{v: datas[0].valeur},
]},
{c: [
{v: "CA Net N-1"},
{v: datas[1].valeur}
]}
]};
$scope.chartObject.type = "PieChart";
$scope.chartObject.options = {
'backgroundColor': '#f5f5f5',
'title': "Comparaison CA et CA N-1" ,'height':"200"
}
});

和 HTML:

<div class="col-md-6" >
<div google-chart chart="chartObject" style="{{chart.cssStyle}}"/>
</div>

最佳答案

让我们尝试一下这段代码。

$scope.loanchart = function(){
$scope.chartObject = {};

$scope.chartObject.data = {"cols": [
{id: "t", label: "Topping", type: "string"},
{id: "s", label: "Slices", type: "number"}
], "rows": [
{c: [
{v: "Mushrooms"},
{v: 3},
]},
{c: [
{v: "Olives"},
{v: 31}
]},
{c: [
{v: "Zucchini"},
{v: 5},
]}
]};
$scope.chartObject.type = "PieChart";
$scope.chartObject.options = {
'title': 'How Much Pizza I Ate Last Night'
};
};

关于javascript - Angularjs 和谷歌图表 API : chart type is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33020957/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com