I have the following class that gets sent as an IEnumerable from an API:
public class LogsDto
{
public decimal Value { get; set; }
public DateTime Time_Stamp { get; set; }
public string TagName { get; set; }
}
This is the Angular class that the data is passed into as an array:
export class Logs {
value: number;
timestamp: string;
tagName: string;
}
Sample data will come across as so:
{ "value": 100, "time_Stamp": "2017-05-04T00:07:47.407", "tagName": "Tag 1" },
{ "value": 200, "time_Stamp": "2017-05-04T00:07:47.407", "tagName": "Tag 2" },
{ "value": 300, "time_Stamp": "2017-05-04T00:07:47.407", "tagName": "Tag 3" },
{ "value": 150, "time_Stamp": "2017-05-04T00:07:57.407", "tagName": "Tag 1" },
{ "value": 250, "time_Stamp": "2017-05-04T00:07:57.407", "tagName": "Tag 2" },
{ "value": 350, "time_Stamp": "2017-05-04T00:07:57.407", "tagName": "Tag 3" }
In Angular, I want to turn this into a table that is read like so:
<table>
<th>Time_Stamp</th> <th>Tag 1</th> <th>Tag 2</th> <th>Tag 3</th>
<td>2017-05-04T00:07:47.407</td> <td>100</td> <td>200</td> <td>300</td>
<td>2017-05-04T00:07:45.407</td> <td>150</td> <td>250</td> <td>350</td>
</table>
I can hard code it fine as shown above. The problem I am having is I don't know how to parse the data from columns to rows. The "tagName" property will not always be the same. Sometimes there will be 10 different tag names.
Any help is appreciated.