This commit is contained in:
sebseb7
2025-12-25 03:28:12 +01:00
parent acbf168218
commit ce87faa551
6 changed files with 1183 additions and 13 deletions

View File

@@ -233,6 +233,7 @@ export default class Chart extends Component {
let yAxisKey = 'left';
let color = undefined;
let fillColor = undefined;
let fillOpacity = 0.5;
if (channelConfig) {
const item = channelConfig.find(c => c.id === id);
if (item) {
@@ -240,6 +241,7 @@ export default class Chart extends Component {
if (item.yAxis) yAxisKey = item.yAxis;
if (item.color) color = item.color;
if (item.fillColor) fillColor = item.fillColor;
if (item.fillOpacity !== undefined) fillOpacity = item.fillOpacity;
}
}
@@ -251,15 +253,10 @@ export default class Chart extends Component {
yAxisKey: yAxisKey,
};
if (color) sObj.color = color;
// Enable area fill if fillColor is set (with 50% transparency)
// Enable area fill if fillColor is set (with configurable opacity)
if (fillColor) {
sObj.area = true;
// Convert hex to rgba with 50% opacity
const hex = fillColor.replace('#', '');
const r = parseInt(hex.substring(0, 2), 16);
const g = parseInt(hex.substring(2, 4), 16);
const b = parseInt(hex.substring(4, 6), 16);
sObj.areaColor = `rgba(${r}, ${g}, ${b}, 0.5)`;
sObj.fillOpacity = fillOpacity;
}
return sObj;
});
@@ -310,7 +307,7 @@ export default class Chart extends Component {
strokeWidth: 3,
},
'& .MuiAreaElement-root': {
fillOpacity: 0.5,
fillOpacity: series.find(s => s.area)?.fillOpacity ?? 0.5,
},
}}
/>