fix main stats of battery view of growatt

This commit is contained in:
Yinyin Liu 2026-03-26 10:21:53 +01:00
parent dfa2f89295
commit 68d057b919
2 changed files with 9 additions and 5 deletions

View File

@ -151,22 +151,25 @@ function MainStatsSodioHome(props: MainStatsSodioHomeProps) {
pathsToSearch.push('Node' + i);
}
const total = pathsToSearch.length;
let i = 0;
pathsToSearch.forEach((devicePath) => {
if (
Object.hasOwnProperty.call(chartData[category].data, devicePath) &&
chartData[category].data[devicePath].data.length != 0
) {
// Spread color indices evenly across the palette for better contrast
const colorIndex = total <= 1 ? 0 : Math.round(i * 9 / (total - 1));
series.push({
...chartData[category].data[devicePath],
color:
color === 'blue'
? blueColors[i]
? blueColors[colorIndex]
: color === 'red'
? redColors[i]
? redColors[colorIndex]
: color === 'green'
? greenColors[i]
: orangeColors[i]
? greenColors[colorIndex]
: orangeColors[colorIndex]
});
}
i++;

View File

@ -226,7 +226,8 @@ export const transformInputToBatteryViewDataJson = async (
categories.forEach((category) => {
pathsToSave.forEach((path) => {
if (pathsToSave.indexOf(path) >= old_length) {
chartData[category].data[path] = { name: path, data: [] };
const displayIndex = pathsToSave.indexOf(path);
chartData[category].data[path] = { name: 'Battery Cluster ' + (displayIndex + 1), data: [] };
}
});
});