I have this for that generates a series. The main problem is that I only have 9 colors.
for (let i = 0; i < dataZCsv.length; i++) {
let colorNumber = i;
if (colorNumber > 8) {
}
let dataBlok = {
name: nazvyZCsv[i],
data: dataZCsv[i],
visible: jednaStopaTF,
regression: hodnoty.trendy,
regressionSettings: {
type: 'polynomial',
color: Highcharts.getOptions().colors[i --> colorNumber],
dashStyle: 'ShortDot',
name: " ",
hideInLegend: true
}
};
serie.push(dataBlok);
serie[0].visible = true;
};
So even if i exceeds 8, it will start writing i greater than 8 to the color: Highcharts.getOptions().colors[i] and this is problem. I have only 9 colors. So I need to do that when it exceeds 8, it starts counting again from 0. But i still need to use it in other variables (name: nazvyZCsv[i], data: dataZCsv[i]), where it must be up to the maximum value (dataZCsv.length).
Ideally, I would make a separate variable for the color number colorNumber, which when it reaches 8 starts again from 0 to end of dataZCsv.length.
Something like:
let colorNumber = i;
if (colorNumber > 8) {
colorNumber = 0;
colorNumber++;
}
or:
let colorNumber = i;
if (colorNumber > 8) {
colorNumber = 0;
for (let j = 0; j < dataZCsv.length - 9; j++) {
colorNumber + j;
}
}
But this not work in for
I've been stuck for several hours and I still don't see a solution. Can you help me, please?
Aucun commentaire:
Enregistrer un commentaire