Это мой HTML-код, который я делаю, это вызвать API и привязать данные к диаграммам, и это для нескольких диаграмм ...
<ng-container *ngFor="let historyitem of historydata?.data; let i=index;">
<div class="post history_post wow fadeInUp" id="{{historyitem.id}}" *ngIf="historyitem.party?.length > 0">
<canvas baseChart width="400" height="200" [data]="chartdata" [labels]="chartlabel" [colors]="ChartColors" [legend]="true" [chartType]="ChartType"></canvas>
</div>
</ng-container>
и этокак я получаю разрешение API, и я сомневаюсь, как связать партию -> места для наборов данных или данных и связать партию -> имя_партии к метке ??Я все еще не понимаю, как это сделать, я могу получить одну диаграмму, если вызываю метод карты, но метод карты не работает для нескольких объектов массива. Как решить эту проблему?
{
"data": [
{
"id": 15,
"year": 2018,
"government": "INC,JDS",
"election_type": "GENERAL_ELECTION",
"state_government_url": "karnataka-inc-jds-2018",
"start_date": "2018-05-23",
"end_date": "2023-05-23",
"description": "The 15th Karnataka Legislative Assembly was constituted after the Karnataka Legislative Assembly elections in 2018. Polling was held on 12 May[1] for 222 constituencies out of the 224-member assembly,[2] with counting of votes and results declared on 15 May.[3] The term of the assembly is for five years.",
"likes_count": 0,
"comments_count": 0,
"share_count": 0,
"favourites_count": 0,
"liked": false,
"emoji": "NA",
"added_to_favourite": false,
"party": []
},
{
"id": 16,
"year": 2018,
"government": "BJP",
"election_type": "GENERAL_ELECTION",
"state_government_url": "karnataka-bjp-2018",
"start_date": "2018-05-17",
"end_date": "2018-05-19",
"description": "The 15th Karnataka Legislative Assembly was constituted after the Karnataka Legislative Assembly elections in 2018. Polling was held on 12 May[1] for 222 constituencies out of the 224-member assembly,[2] with counting of votes and results declared on 15 May.[3] The term of the assembly is for five years.",
"likes_count": 0,
"comments_count": 0,
"share_count": 0,
"favourites_count": 1,
"liked": false,
"emoji": "NA",
"added_to_favourite": true,
"party": []
},
{
"id": 14,
"year": 2013,
"government": "INC",
"election_type": "GENERAL_ELECTION",
"state_government_url": "karnataka-inc-2013",
"start_date": "2013-05-13",
"end_date": "2018-05-17",
"description": "INC",
"likes_count": 3,
"comments_count": 0,
"share_count": 0,
"favourites_count": 1,
"liked": true,
"emoji": "0x1F62F",
"added_to_favourite": false,
"party": [
{
"party": {
"party_name": "INC",
"party_abbervation": "Indian National Congress"
},
"seats": 122
},
{
"party": {
"party_name": "BJP",
"party_abbervation": "Bharatiya Janata Party"
},
"seats": 40
},
{
"party": {
"party_name": "JD(S)",
"party_abbervation": "Janata Dal (Secular)"
},
"seats": 40
},
{
"party": {
"party_name": "IND",
"party_abbervation": "Independent"
},
"seats": 9
},
{
"party": {
"party_name": "KJP",
"party_abbervation": "Karnataka Janatha Paksha"
},
"seats": 6
},
{
"party": {
"party_name": "BSRCP ",
"party_abbervation": "Badavara Shramikara Raitara Congress Party"
},
"seats": 4
}
]
},
{
"id": 13,
"year": 2008,
"government": "BJP",
"election_type": "GENERAL_ELECTION",
"state_government_url": "karnataka-bjp-2008",
"start_date": "2008-05-30",
"end_date": "2013-05-05",
"description": "BJP",
"likes_count": 2,
"comments_count": 0,
"share_count": 0,
"favourites_count": 1,
"liked": false,
"emoji": "NA",
"added_to_favourite": true,
"party": [
{
"party": {
"party_name": "BJP",
"party_abbervation": "Bharatiya Janata Party"
},
"seats": 117
},
{
"party": {
"party_name": "INC",
"party_abbervation": "Indian National Congress"
},
"seats": 82
},
{
"party": {
"party_name": "JD(S)",
"party_abbervation": "Janata Dal (Secular)"
},
"seats": 31
},
{
"party": {
"party_name": "IND",
"party_abbervation": "Independent"
},
"seats": 7
}
]
}
],
"code": 201,
"message": "State government information retrieved successfully."
}