7

I'm setting up a simple example of the line chart and it fails with the getColor on undefined error. If I remove the [results] data, the chart displays but then fails on missing data. Not sure how to track this problem down?

Using ngx-charts 12.0.1 I copied the example code from https://github.com/marjan-georgiev/Angular-CLI-ngx-charts-Demo and then added a second chart to the home page shown in the example below.

I've tried removing as many variables as possible to get results.

Tag:

<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
Dave B
  • 101
  • 1
  • 7

0 Answers0