Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.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 无法使我的highchart在angular 5中响应_Javascript_Html_Angular_Typescript_Highcharts - Fatal编程技术网

Javascript 无法使我的highchart在angular 5中响应

Javascript 无法使我的highchart在angular 5中响应,javascript,html,angular,typescript,highcharts,Javascript,Html,Angular,Typescript,Highcharts,我在Angular 5中使用Highcharts来显示饼图。我已经创建了多个图表,并将它们存储在一个图表数组中,并使用ngFor指令来显示它们 My component.ts文件和component.html文件 从'@angular/core'导入{Component,OnInit,ViewChild,ElementRef}; 从“角度高度图表”导入{Chart}; 从“Highcharts”导入*作为Highcharts; 从“../services/author count.servic

我在Angular 5中使用Highcharts来显示饼图。我已经创建了多个图表,并将它们存储在一个图表数组中,并使用ngFor指令来显示它们

My component.ts文件和component.html文件

从'@angular/core'导入{Component,OnInit,ViewChild,ElementRef};
从“角度高度图表”导入{Chart};
从“Highcharts”导入*作为Highcharts;
从“../services/author count.service”导入{AuthorCountService};
从“../shared/Company”导入{Company};
@组成部分({
选择器:“应用程序详细信息正文”,
templateUrl:'./details body.component.html',
样式URL:['./details body.component.scss']
})
导出类DetailsBodyComponent实现OnInit{
构造函数(私有authorCountService:authorCountService){}
公司列表:公司[];
图表列表:图表[]=[];
恩戈尼尼特(){
this.authorCountService.getJsonData().subscribe((res)=>{
this.companyList=res;
console.log(this.companyList);
this.companyList.forEach((company)=>{
让chartitem=新图表({
图表:{
plotBackgroundColor:null,
plotBorderWidth:null,
影子:错,
键入:“馅饼”
},
标题:{
文本:company.companyname
},
工具提示:{
pointFormat:“{point.y}”
},
打印选项:{
馅饼:{
allowPointSelect:true,
光标:“指针”,
数据标签:{
启用:对,
格式:“{point.name}
{point.y}” } } }, 系列:[ { “数据”:[ {“name”:“Male”,“y”:company.authorcount.Male}, {“name”:“Female”,“y”:company.authorcount.Female} ] } ] }); this.chartList.push(chartitem); }); console.log(this.chartList); }); } }
。第一项{
边缘顶部:65px;
}

唯一作者计数
每个竞争对手的唯一作者数量为


我在处理Highcharts时遇到了完全相同的问题。我遵循了这篇关于迪伦梦想的教程。他正在使用一个叫做gridstack的框架

链接:


看看下面的JSFIDLE


希望这对您有所帮助

这是我的解决方案,希望它对任何人都有帮助

ngOnInit() {

    this.innerWidth = window.innerWidth;
    this.chartOptions = {
      chart: {
        type: 'line',
        height: 120,
        width: this.innerWidth - 50
      },.....
   };

   this.chart = new Chart(this.chartOptions);
}
直接更改屏幕并重新编辑

 @HostListener('window:resize', ['$event'])
  onResize(event) {
    this.innerWidth = window.innerWidth;
    this.chartOptions.chart.width = this.innerWidth - 50;
    this.chart = new Chart(this.chartOptions);
  }

下面是Angular 5中响应图表的现场演示:您可能会发现它很有用。
 @HostListener('window:resize', ['$event'])
  onResize(event) {
    this.innerWidth = window.innerWidth;
    this.chartOptions.chart.width = this.innerWidth - 50;
    this.chart = new Chart(this.chartOptions);
  }