首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基本区域EChart不编译与ngx?

基本区域EChart不编译与ngx?
EN

Stack Overflow用户
提问于 2022-11-23 18:56:44
回答 1查看 18关注 0票数 -1

我试图让基本面积图ngx-echarts一起在斯塔克布利茨上工作。

我已经安装了ngx-echarts并导入了模块。我在app.component.ts中添加了如下选项:

代码语言:javascript
复制
option = {
  xAxis: {
    type: 'category',
    boundaryGap: false,
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [820, 932, 901, 934, 1290, 1330, 1320],
      type: 'line',
      areaStyle: {}
    }
  ]
};

并在app.component.html中声明了图表。

代码语言:javascript
复制
<div echarts [autoResize]="false" [options]="option" class="demo-chart"></div>

它产生了一个很长的错误:

代码语言:javascript
复制
Type '{ xAxis: { type: string; boundaryGap: boolean; data: string[]; }; yAxis: { type: string; }; series: { data: number[]; type: string; areaStyle: {}; }[]; }' is not assignable to type 'EChartsOption'.
Types of property 'xAxis' are incompatible.
Type '{ type: string; boundaryGap: boolean; data: string[]; }' is not assignable to type 'XAXisOption | XAXisOption[]'.
Type '{ type: string; boundaryGap: boolean; data: string[]; }' is not assignable to type 'CategoryAxisBaseOption & { gridIndex?: number; gridId?: string; position?: CartesianAxisPosition; offset?: number; categorySortInfo?: OrdinalSortInfo; } & { ...; }'.
Type '{ type: string; boundaryGap: boolean; data: string[]; }' is not assignable to type 'CategoryAxisBaseOption'.
Types of property 'type' are incompatible.
Type 'string' is not assignable to type '"category"'.

有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2022-11-23 19:45:17

好的算出来了。显然,保存图表配置的属性必须在ngOnInit中初始化,这样图表才能呈现。

这是一个工作演示。

https://stackblitz.com/edit/angular-ivy-fubqan?file=src%2Fapp%2Fapp.component.ts

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74551778

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档