estos son los datos que tengo:
y he creado 4 arreglos respectivamente
public underlyingsFirstRow = [{perf:0,color:''}]; public underlyingsSecRow = [{ perf: 0, color: '' }]; public underlyingsThirdRow = [{ perf: 0, color: '' }]; public underlyingsFourthRow = [{ perf: 0, color: '' }];
Quiero que underLingsFirstRow contenga el primer elemento de cada una de las matrices
ejemplo [1.09,1.44,0.72,0.98,....,1.22]
y para los subyacentesSecRow [0.96,1.40,0,0.93,0,0.99,...,1.09]
ya que la fila de datos tercera, quinta y decimoséptima tiene solo un elemento y es 0.72
Quiero que el subyacente SecRow tenga un valor de 0, lo que indica que no hay ningún valor allí, así que puedo usarlo para mostrar algunos puntos en un gráfico y quiero hacer lo mismo para la matriz restante que he creado.
esto es lo que he escrito
this.underlyingsFirstRow.shift(); this.underlyingsSecRow.shift(); this.underlyingsThirdRow.shift(); this.underlyingsFourthRow.shift(); this.products.map(p => p.Underlyings.map((u, index,array) => { if (index == 0) { this.underlyingsFirstRow.push({ perf: (Number((u.perf100 * 100).toFixed(2))), color: u.colorPerf }); } else if (index == 1) { console.log() if (p.Underlyings.length > 1) this.underlyingsSecRow.push({ perf: (Number((u.perf100 * 100).toFixed(2))), color: u.colorPerf }); else { this.underlyingsSecRow.push({ perf: 0, color:'white' }); } } else if (index == 2) { this.underlyingsThirdRow.push({ perf: (Number((u.perf100 * 100).toFixed(2))), color: u.colorPerf }); } else if (index == 3) { this.underlyingsFourthRow.push({ perf: (Number((u.perf100 * 100).toFixed(2))), color: u.colorPerf }); } }));
para la primera matriz funcionó ya que todos tienen al menos un elemento
¿Hay alguna manera de obtener los datos deseados?