Practical Highcharts with Angular by Sourabh Mishra

Practical Highcharts with Angular by Sourabh Mishra

Author:Sourabh Mishra
Language: eng
Format: epub
ISBN: 9781484257449
Publisher: Apress


Now let’s talk about the ngOnInit() function . This function starts to run in the Angular lifecycle when the component load completes, so you can say it’s a page load kind of event method. Once app.component.ts loads, this method will start to execute.ngOnInit() {

this.getApiResponse(this.url).then(

data => {

const subjectMarks = [];

const names = [];

data.forEach(row => {

consttemp_row = [

row.english,

row.maths,

row.science

];

names.push(row.name);

subjectMarks.push(temp_row);

});

this.studentModel = subjectMarks;

this.studentNames = names;

var dataSeries = [];

for (var i = 0; i<this.studentModel.length; i++) {

dataSeries.push({

data: this.studentModel[i],

name: this.studentNames[i]

});

}

this.options.series = dataSeries;

Highcharts.chart('container', this.options);

},

error => {

console.log('Something went wrong.');

})

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.