我正在一个AngularJS项目中工作,我试图用angular-google-chart工具添加一个Google甘特图,但它不起作用。
以下是代码:
JS代码
var app = angular.module('myApp', [
'ngRoute',
'angular.filter',
'googlechart'
]);
app.value('googleChartApiConfig', {
version: '1.1',
optionalSettings: {
packages: ['gantt'],
language: 'en'
}
});
app.controller("chartController", function ($scope) {
$scope.ganttChart = {
"type": "gantt",
"data": {
"cols": [
{id: 'Task ID', type: 'string'},
{id: 'Task Name', type: 'string'},
{id: 'Start Date', type: 'date'},
{id: 'End Date', type: 'date'},
{id: 'Duration', type: 'number'},
{id: 'Percent Complete', type: 'number'},
{id: 'Dependencies', type: 'string'}
],
"rows": [
{c: [
{v: 'Research'},
{v: 'Find sources'},
{v: new Date(2015, 0, 1)},
{v: new Date(2015, 0, 5)},
{v: null},
{v: 100},
{v: null}
]},
{c: [
{v: 'Write'},
{v: 'Write paper'},
{v: null},
{v: new Date(2015, 0, 9)},
{v: daysToMilliseconds(3)},
{v: 25},
{v: 'Research'}
]}
]
}
};
});
function daysToMilliseconds(days) {
return days * 24 * 60 * 60 * 1000;
}HTML代码
<div google-chart chart="ganttChart" style="height:600px; width:100%;"></div>当我运行应用程序而不是显示图表时,无效的可视化类型:甘特会出现,控制台不会显示任何错误。
我在这个小提琴 (Google甘特图的例子,没有angular-google-chart工具)中尝试了这个数据组合,它工作得很好。
有人能帮我吗?谢谢!!为我的英语道歉!
https://stackoverflow.com/questions/35886898
复制相似问题