0

I want to make it dynamic. Please anyone can help me to do this . Actually i am new in to angular & Typescript.

Code Snippet Here: Manually I am adding row column. How to make it dynamic. Is it possible to iterate in loop.

We are using google charts.

const data = google.visualization.arrayToDataTable([
['Encounter Type', 'No of Encounters'],
[this.dataList[0][0], this.dataList[0][1]],
[this.dataList[3][0], this.dataList[3][1]],
[this.dataList[1][0], this.dataList[1][1]],
[this.dataList[2][0], this.dataList[2][1]],
]);

1 Answer 1

1

if you simply want to add the rows from dataList,
use a forEach statement

first, create an array with the column headings...

let arrayData = [
  ['Encounter Type', 'No of Encounters']
];

use forEach to load the rows...

this.dataList.forEach(function (row) {
  arrayData.push([row[0], row[1]]);
});

then create the data table from the array...

const data = google.visualization.arrayToDataTable(arrayData);
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.