Search code examples
nativescriptangular2-nativescriptnativescript-telerik-ui

TypeError: Cannot read property 'cartesianChart' of undefined in nativescript


i an new in nativescript. i try to learn chart in nativescript but it's give "TypeError: Cannot read property 'cartesianChart' of undefined" error.

home.componet.html

<RadCartesianChart tkExampleTitle tkToggleNavButton>
<CategoricalAxis tkCartesianHorizontalAxis></CategoricalAxis>
<LinearAxis tkCartesianVerticalAxis></LinearAxis>
<LineSeries tkCartesianSeries [items]="categoricalSource" categoryProperty="Country" valueProperty="Amount"></LineSeries>

home.component.ts

    import { Component, OnInit,ViewChild,AfterViewInit ,ElementRef} from '@angular/core';
import { WebView, LoadEventData } from "ui/web-view";
import { ObservableArray } from "tns-core-modules/data/observable-array";
import{DataService} from "../data.service"
import{Country} from "../country"

@Component({
  moduleId: module.id,
  selector: 'app-home',
  providers: [DataService],
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {

  private _categoricalSource: ObservableArray<Country>;

  constructor(private _dataService: DataService) { }

  get categoricalSource(): ObservableArray<Country> {
      return this._categoricalSource;
  }

  ngOnInit() {
      this._categoricalSource = new ObservableArray(this._dataService.getCategoricalSource());
  }

}

Solution

  • I was facing the same issue and solved it by removing the android platform and adding it again.

    tns platform remove android
    tns platform add android