I have mentioned my complete code of my project.
Component.ts
This was the method to populate data in a table:
public get_planet_positions(pos_array) {
let planet_pos_array = []
let data_array = [[
[], [], [], []
], [
[], [], [], []
], [
[], [], [], []
], [
[], [], [], []
]]
let planets = [
"Sun",
"Moo",
"Mar",
"Mer",
"Jup",
"Ven",
"Sat",
"Rah",
"Ket",
"Asc"
]
var messageStringAfter = "";
for (let i = 0; i < planets.length; i += 1) {
planet_pos_array.push([
planets[i],
this.planet_alphabet[pos_array[i]]
])
console.log(planet_pos_array)
}
for (let i = 0; i < data_array.length; i += 1) {
for (let j = 0; j < data_array.length; j += 1) {
for (let k = 0; k < planet_pos_array.length; k += 1) {
if (i + "," + j == planet_pos_array[k][1]) {
data_array[i][j].push(planet_pos_array[k][0]);
}
}
}
}
return data_array
}
This loop was to call that function 10 times:
for (let i = 1; i < this.arrays.length; i++) {
console.log("ll", this.arrays[i])
this.planets_array
.push(this.get_planet_positions(this.arrays[i]));
}
HTML
To create a table dynamically:
<div class="col-md-4" *ngFor="let ar of arrays|slice:1:7;index as i">
<div>
<div class="chart_row" *ngFor="let row of planets_array[i]">
<div class="chart_cell chart cell " *ngFor="let cell of row ; index as j;odd as odd; even as even" [ngClass]="['cell1','cell2','cell3','cell4','cell5','cell6']">
<div class="">
<p class="para">{{j+1}}</p>
</div>
<br>
</div>
</div>
</div>
Actual Output
Expected Output
Each box should be populated with a different color. Is there an easy way to do this? If so, would love to see the best way to do this.
Thank you so much in advance.