Good morning, everyone! I’m attempting to place a chart.js bar chart into one of my ion segment components. I’ve got them (charts) functioning fine elsewhere in my application (following Josh Morony’s great tutorial: Adding Responsive Charts & Graphs to Ionic Applications | Josh Morony), but adding them into segments is proving troublesome. This is mostly to my unfamiliarity with Typescript.
I’ve tried writing a function within export class:
loadPerformanceChart(){
this.barChart = new Chart(this.itemPerformance.nativeElement, { ... }
}
and then calling that function on ionChange:
<ion-segment [(ngModel)]="item_detailed_info" (ionChange)="loadPerformanceChart()" padding>
<ion-segment-button value="offers">8 Offers</ion-segment-button>
<ion-segment-button value="performance">Performance</ion-segment-button>
<ion-segment-button value="history">History</ion-segment-button>
</ion-segment>
Everything compiles fine, but once the ionChange event fires, I get a Runtime Error that reads
Error in ./ItemdetailsPage class ItemdetailsPage - caused by: Cannot read property ‘nativeElement’ of undefined
Can anyone help me out here? I’m at a full stop until I figure this out.