I am using a for loop to assign my Highcharts data certain variables under a condition.
One of these variables I would like to assign is linkedTo= ":previous" IF graphData.Title appears more then once. I am having problems executing this logic in my existing for loop.
For example, on the first graphData.Title === "LOW" I would like linkedTo to not exist. If the array has graphData.Title === "LOW" more then once assign the variable linkedTo= ":previous"
The way I am currently handling this is creating a condition on LOW and then having another condition if graphTitle is LOW and greater then 1 assign it the linkedTo variable.
I expect this same outcome for every other possible condition on the title.
for (let i = 0; i < graphData.length; i++) {
let graphColor = "#000000";
let graphIndex = 0
let linkedTo = ""
if (graphData[i].title === "LOW") {
graphColor = "#0D6302";
graphIndex = 4;
} else if (graphData[i].Title === "LOW" && graphData[i].Title === "LOW" > 1) {
graphColor = "#0D6302";
graphIndex = 4;
linkedTo = ":previous"
} else if (graphData[i].title === "MEDIUM-LOW") {
graphColor = "#0B7070";
graphIndex = 3;
} else if (graphData[i].title === "MEDIUM") {
graphColor = "#DC9603";
graphIndex = 2;
} else if (graphData[i].title === "MEDIUM-HIGH") {
graphColor = "#DD5F0C";
graphIndex = 1;
} else if (graphData[i].title === "HIGH") {
graphColor = "#C50710";
graphIndex = 0;
}
Aucun commentaire:
Enregistrer un commentaire