ngx-charts-line-chart失败,无法读取未定义的属性“ getColor”

时间:2019-07-15 23:22:07

标签: angularjs ngx-charts

我正在设置一个折线图的简单示例,它会因未定义错误的getColor而失败。如果删除[结果]数据,则会显示图表,但在缺少数据时会失败。不确定如何跟踪此问题?

使用ngx图12.0.1 我从https://github.com/marjan-georgiev/Angular-CLI-ngx-charts-Demo复制了示例代码,然后在下面的示例所示的首页中添加了第二张图表。

我尝试删除尽可能多的变量以获得结果。

标签:

<div style="height: 100px">
  <ngx-charts-line-chart
    [view]="view"
    [results]="single"
    class="chart-container"
    [scheme]="colorScheme"
    [legend]="showLegend"
    [gradient]="gradient"
    [xAxis]="showXAxis"
    [yAxis]="showYAxis"
    [showXAxisLabel]="showXAxisLabel"
    [showYAxisLabel]="showYAxisLabel"
    [xAxisLabel]="xAxisLabel"
    [yAxisLabel]="yAxisLabel"
    (select)="onSelect($event)"
    (activate)="onActivate($event)"
    (deactivate)="onDeactivate($event)"
  >
  </ngx-charts-line-chart>
</div>

component data:
single: any[] = [
    {
      name: "Germany",
      value: 8940000
    },
    {
      name: "USA",
      value: 5000000
    },
    {
      name: "France",
      value: 7200000
    },
    {
      name: "Mars",
      value: 720000
    }
  ];


  colorScheme = {
    domain: ["#5AA454", "#A10A28", "#C7B42C", "#AAAAAA"]
  };

Console Error with [results]: 
    ERROR TypeError: Cannot read property 'getColor' of undefined
    at Object.eval [as updateDirectives] (LineSeriesComponent.html:14)


Console Error without [results]:
The chart is build on the page and, of course, empty. The following
error shows up when I click on any portion of the empty chart.

Error: <rect> attribute x: Expected length, "NaN".  
    platform-browser:1973

0 个答案:

没有答案