Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 谷歌时间线图表错误_Angular - Fatal编程技术网

Angular 谷歌时间线图表错误

Angular 谷歌时间线图表错误,angular,Angular,我使用angular 4和google timeline图表,它给出了一个错误,如“错误类型错误:无法读取未定义的”属性“timeline”,我的代码如下 index.html <!doctype html> <html lang="en"> <head> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"

我使用angular 4和google timeline图表,它给出了一个错误,如“错误类型错误:无法读取未定义的”属性“timeline”,我的代码如下

index.html

<!doctype html>
<html lang="en">
    <head>          
        <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    </head>
    <body>
        <app-root></app-root>
    </body>
</html>
dasbordComponets.html

 <div id="graph" style="height: 180px;"></div>

我现在正在使用Google timeline Angular尝试使用此存储库
npm I ng2 Google charts
您只需安装它并遵循以下代码:

HTML

<h1>Timeline chart</h1>
<google-chart [data]="timelineChartData"></google-chart>
模块.ts

declare var google: any;

public initGraph() {
    google.charts.load('current', {'packages': ['timeline']});
    google.charts.setOnLoadCallback(this.testGraph());
}

public testGraph () {
    var container = document.getElementById('graph');
    var chart = new google.visualization.Timeline(container);
    var dataTable = new google.visualization.DataTable();

    dataTable.addColumn({ type: 'string', id: 'President' });
    dataTable.addColumn({ type: 'date', id: 'Start' });
    dataTable.addColumn({ type: 'date', id: 'End' });
    dataTable.addRows([
        [ 'Washington', new Date(1789, 3, 30), new Date(1797, 2, 4) ],
        [ 'Adams',      new Date(1797, 2, 4),  new Date(1801, 2, 4) ],
        [ 'Jefferson',  new Date(1801, 2, 4),  new Date(1809, 2, 4) ]]);

    chart.draw(dataTable);
}
public timelineChartData:any =  {
    chartType: 'Timeline',
    dataTable: [
      ['Name', 'From', 'To'],
      [ 'Washington', new Date(1789, 3, 30), new Date(1797, 2, 4) ],
      [ 'Adams',      new Date(1797, 2, 4),  new Date(1801, 2, 4) ],
      [ 'Jefferson',  new Date(1801, 2, 4),  new Date(1809, 2, 4) ]
    ]
 }
...
@NgModule({
    imports: [
        ...
        Ng2GoogleChartsModule,
        ...
    ],

...

这是一个正在工作的问题。

不,这不是类似的问题。我的错误是错误类型错误:无法读取未定义的属性“Timeline”