4

My Angular 2 project was created with angular-cli version 1.0.0-beta.30. I am using the ngx-charts version 4.1.2 library. The bar chart component is working fine but when I add a line chart, a TypeError exception is thrown when I run the application. The error is the "includes" function in line 240 of [line-chart.component.ts][1] source file when running in Chrome version 38. The line chart appears correctly in Firefox

if (!values.includes(d.name)) {
    values.push(d.name);
}

How do I make the array include function known to my application?

In my tsconfig.json file I have

"lib": ["es6", "dom"],

My package.json file contains the following

{
  "name": "dashboards",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.4.5",
    "@angular/compiler": "^2.4.5",
    "@angular/core": "^2.4.5",
    "@angular/forms": "^2.4.5",
    "@angular/http": "^2.4.5",
    "@angular/platform-browser": "^2.4.5",
    "@angular/platform-browser-dynamic": "^2.4.5",
    "@angular/router": "^3.4.1",
    "@swimlane/ngx-charts": "^4.1.2",
    "core-js": "^2.4.1",
    "d3": "^4.4.0",
    "rxjs": "^5.0.3",
    "ts-helpers": "^1.1.2",
    "zone.js": "^0.7.6"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0-beta.30",
    "@angular/compiler-cli": "^2.4.5",
    "@types/d3": "^4.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.7.0",
    "karma": "1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.1.0",
    "karma-remap-istanbul": "^0.4.0",
    "protractor": "~4.0.14",
    "ts-node": "1.7.2",
    "tslint": "^4.3.0",
    "typescript": "~2.0.10"
  }
}

My polyfills.ts file contains

import 'core-js/es6/array';

I've looked through the ngx-charts demo and other examples but I can't figure out why I am receiving the error.

Thanks

0

1 Answer 1

5

I found the problem. The polyfills.ts file contained

import 'core-js/es6/array';

I needed to add

import 'core-js/es7/array';

to the file.

I'm thinking this is due to the version of Chrome installed on my corporate PC. It is version 38. This developer.mozilla.org page for Array.includes states that support for Chrome is in version 47.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.