Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.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
Javascript 如何在Angular 8中添加smoothie图表_Javascript_Angular_Smoothie.js - Fatal编程技术网

Javascript 如何在Angular 8中添加smoothie图表

Javascript 如何在Angular 8中添加smoothie图表,javascript,angular,smoothie.js,Javascript,Angular,Smoothie.js,我是Angular 8的初学者,我正在Angular 8中添加smoothie图表,在Angular 8中没有添加google smoothie图表的教程。请帮助我解决这个问题,或者给我一些例子 npm安装smoothie添加了我的angular 8项目 从smoothie导入{SmoothieChart};已添加到app.component.ts 代码: App.component.html <div> <canvas id="mycanvas" width="800"

我是Angular 8的初学者,我正在Angular 8中添加smoothie图表,在Angular 8中没有添加google smoothie图表的教程。请帮助我解决这个问题,或者给我一些例子

npm安装smoothie添加了我的angular 8项目 从smoothie导入{SmoothieChart};已添加到app.component.ts 代码:

App.component.html

<div>
  <canvas id="mycanvas" width="800" height="200"></canvas>
</div>
在Javascript中,smoothie.streamTodocument.getElementByIdchart,500;
在angular 8如何添加上述代码中,首先需要让angular初始化DOM,因此不能在ngOnInit中进行初始化,因为元素尚未插入DOM中,需要实现

然后,您可以使用document.getElementById,但这不是在Angular中实现它的最佳方法,您应该检索相关元素

参考这个问题。有关生命周期,请参阅此。
<div>
  <canvas id="mycanvas" width="800" height="200"></canvas>
</div>