fix main stats of battery view of growatt
This commit is contained in:
parent
dfa2f89295
commit
68d057b919
|
|
@ -151,22 +151,25 @@ function MainStatsSodioHome(props: MainStatsSodioHomeProps) {
|
||||||
pathsToSearch.push('Node' + i);
|
pathsToSearch.push('Node' + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const total = pathsToSearch.length;
|
||||||
let i = 0;
|
let i = 0;
|
||||||
pathsToSearch.forEach((devicePath) => {
|
pathsToSearch.forEach((devicePath) => {
|
||||||
if (
|
if (
|
||||||
Object.hasOwnProperty.call(chartData[category].data, devicePath) &&
|
Object.hasOwnProperty.call(chartData[category].data, devicePath) &&
|
||||||
chartData[category].data[devicePath].data.length != 0
|
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({
|
series.push({
|
||||||
...chartData[category].data[devicePath],
|
...chartData[category].data[devicePath],
|
||||||
color:
|
color:
|
||||||
color === 'blue'
|
color === 'blue'
|
||||||
? blueColors[i]
|
? blueColors[colorIndex]
|
||||||
: color === 'red'
|
: color === 'red'
|
||||||
? redColors[i]
|
? redColors[colorIndex]
|
||||||
: color === 'green'
|
: color === 'green'
|
||||||
? greenColors[i]
|
? greenColors[colorIndex]
|
||||||
: orangeColors[i]
|
: orangeColors[colorIndex]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,8 @@ export const transformInputToBatteryViewDataJson = async (
|
||||||
categories.forEach((category) => {
|
categories.forEach((category) => {
|
||||||
pathsToSave.forEach((path) => {
|
pathsToSave.forEach((path) => {
|
||||||
if (pathsToSave.indexOf(path) >= old_length) {
|
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: [] };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue