Skip to content

Commit

Permalink
🎉 🔧 edited opacity code, unfinished
Browse files Browse the repository at this point in the history
  • Loading branch information
kunkoala committed Dec 17, 2024
1 parent 4d1a03c commit 39416c3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions frontend/src/components/LineChartComponents/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,22 @@ export default function LineChart({
return [];
}

return lineChartData.map((line) => {
const totalScenarios = lineChartData.length;
const maxOpacity = 0.2; // Maximum cumulative opacity

return lineChartData.map((line, index) => {
const lineColor = line.stroke.color ?? color(theme.palette.error.main);
const fillColor = line.fill ?? color(theme.palette.error.main);

const weight = (index + 1) / totalScenarios; // Proportional weight
const opacity = weight * maxOpacity; // Adjust opacity based on weight

return {
threshold: horizontalYAxisThreshold,
fills: {
fill: fillColor, // change the fill of the range above threshold
visible: true, // visibility of the fill
fillOpacity: line.fillOpacity ?? 0.15,
fillOpacity: opacity,
},
strokes: {
stroke: color(theme.palette.error.main), // change the stroke for points above threshold
Expand Down

0 comments on commit 39416c3

Please sign in to comment.