Question for .js masters, dynamically I am building cards on the frontend and that’s not a problem. I got stuck when I want to push data to array. I am pulling a list of visible cards ‘risk1, zone1’ from visibleColumnCards and then I iterate ‘datatableData’ and pushing (‘risk1 and zone1’) data values to array.
Problem is that in dtFilteredCard ‘risk1 and zone1’ values are combined, what I would like to do is to access values e.g. dtFilteredCard[0] (risk1), dtFiltered[1] (zone1). And to conclude there is always a simple solution, but damn I can’t figure it out.
Thank you in advance!
cardsConfig = [];
let dtFilteredCard = [];
let sortedValuesCard = [];
visibleColumnCards.forEach(function (colValue, colKey) {
cardData = colValue.data; //risk1, zone1
datatableData.forEach(function (dtValue, dtKey) {
let newValue = { name: dtValue.customerIdentifier, y: Number(dtValue[cardData]) };
dtFilteredCard.push(newValue);
});
sortedValuesCard = dtFilteredCard.sort((a, b) => b["y"] - a["y"]).slice(0, 5);
cardsConfig.push({
id: colKey,
countUpContainer: "cu-" + colKey,
title: colValue.card_title,
hcContainer: "hc-container-card-" + colKey,
hcData: sortedValuesCard,
hcHeight: "130px",
hcUnit: "%",
hcLegend: false,
});
});