Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.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_Typescript_Highcharts - Fatal编程技术网

Angular 高端图表、物业类型';系列';不相容

Angular 高端图表、物业类型';系列';不相容,angular,typescript,highcharts,Angular,Typescript,Highcharts,我正在使用Highchart创建一个角度图表, 但我在编译时遇到了这个错误。 属性是兼容的,但类型脚本编译器 抛出一个错误。我不明白为什么以及如何避免这个错误。 有什么建议吗? 我用的是角度11 error TS2322: Type '{ chart: { type: string; }; title: { text: string; }; xAxis: { categories: string[]; }; yAxis: { title: { text: string; }; }; serie

我正在使用Highchart创建一个角度图表, 但我在编译时遇到了这个错误。 属性是兼容的,但类型脚本编译器 抛出一个错误。我不明白为什么以及如何避免这个错误。 有什么建议吗? 我用的是角度11

 error TS2322: Type '{ chart: { type: string; }; title: { text: string; }; xAxis: { categories: string[]; }; yAxis: { title: { text: string; }; }; series: ({ name: string; data: number[]; type: string; color?: undefined; } | { name: string; data: number[]; type: string; color: string; })[]; }' is not assignable to type 'Options'.
  Types of property 'series' are incompatible.
    Type '({ name: string; data: number[]; type: string; color?: undefined; } | { name: string; data: number[]; type: string; color: string; })[]' is not assignable to type 'SeriesOptionsType[]'.
      Type '{ name: string; data: number[]; type: string; color?: undefined; } | { name: string; data: number[]; type: string; color: string; }' is not assignable to type 'SeriesOptionsType'.
        Type '{ name: string; data: number[]; type: string; color?: undefined; }' is not assignable to type 'SeriesOptionsType'.       
          Type '{ name: string; data: number[]; type: string; color?: undefined; }' is not assignable to type 'SeriesXrangeOptions'.   
            Types of property 'data' are incompatible.
              Type 'number[]' is not assignable to type 'XrangePointOptionsObject[]'.
                Type 'number' has no properties in common with type 'XrangePointOptionsObject'.

3   [options]="chartOptions"
    ~~~~~~~~~~~~~~~~~~~~~~~~
从'@angular/core'导入{Component,OnInit};
从“Highcharts”导入*作为Highcharts;
标题='myHighchart';
海图:海图类型=海图;
数据=[{
名称:“itsolutionstaff.com”,
数据:[500700555444477787794456667898945654],
类型:“样条曲线”,
},{      
名称:“nicesippets.com”,
数据:[6774556778774557654],
类型:“样条曲线”,
颜色:“#3183F5”
}];
图表选项={
图表:{
类型:“样条线”
},
标题:{
文本:“每月网站访问者”
},
xAxis:{
类别:[“一月”、“二月”、“三月”、“四月”、“五月”、“六月”、“七月”、“八月”、“九月”、“十月”、“十一月”、“十二月”]
},
亚克斯:{
标题:{
正文:“访客”
} 
},
系列:这是我的数据
};


>
您的数据是正确的,请检查“任意”转换的工作方式,
图表选项:任意=…

当您想要遵循这些规则时,您不应该使用以下预定义的序列启动图表:
series:this.data

您可以为系列的每个元素创建一个变量,例如
名称
数据
颜色
等,甚至可以将其保留在数组中。但是,系列的整个结构应在
图表选项中定义,否则图表将出错

series: [
  {
    name: this.name1,
    type: "spline",
    data: this.data1
  },
  {
    type: "spline",
    data: this.data2,
    name: "Nicesnippets.com",
    color: "#3183F5"
  }
]
您也可以始终创建自己的TS接口或扩展现有接口

演示: