Estimate the total wattage your solar energy system needs.
Solar Panel Wattage Calculator
Your average electricity usage per day, found on your utility bill.
Average hours of direct sunlight your location receives daily. Varies by season and geography.
Accounts for energy losses due to shading, dirt, temperature, and inverter efficiency. Typically 0.75 to 0.90.
The rated power output of a single solar panel. Common values are 300W to 450W.
Your Solar System Estimate
Required System Size (kW)—
Total Panel Wattage Needed (W)—
Number of Panels Required—
Estimated Daily Energy Production (kWh)—
Formula Used:
Required System Size (kW) = (Average Daily Energy Consumption (kWh) / Peak Sun Hours Per Day) / System Loss Factor
Total Panel Wattage (W) = Required System Size (kW) * 1000
Number of Panels = Total Panel Wattage (W) / Individual Solar Panel Wattage (W)
Estimated Daily Energy Production (kWh) = Required System Size (kW) * Peak Sun Hours Per Day * System Loss Factor
System Size Breakdown
Daily Energy Production vs. Consumption
Key Assumptions and Intermediate Values
Metric
Value
Unit
Average Daily Consumption
—
kWh
Peak Sun Hours
—
Hours
System Loss Factor
—
–
Individual Panel Wattage
—
W
Required System Size
—
kW
Total Panel Wattage
—
W
Number of Panels
—
–
Estimated Daily Production
—
kWh
What is a Solar Panel Wattage Calculator?
A solar panel wattage calculator is an online tool designed to help homeowners and businesses estimate the total power output, measured in watts (W) or kilowatts (kW), required for a solar photovoltaic (PV) system. It takes into account your current electricity consumption, local sunlight availability, and system efficiencies to determine the appropriate system size. This is a crucial first step in the solar installation process, ensuring your system can meet your energy needs effectively and economically.
Who should use it? Anyone considering installing solar panels for their home or business should use this calculator. It's beneficial for:
Homeowners looking to reduce their electricity bills and carbon footprint.
Business owners aiming for energy independence and cost savings.
Individuals curious about the feasibility and scale of a solar installation in their specific location.
Those comparing quotes from different solar installers to ensure they are sized appropriately.
Common misconceptions about solar panel sizing include assuming that more panels always mean more savings, or that a system sized for one home will work for another identical-looking one without considering location-specific factors. This calculator helps demystify the process by providing a data-driven estimate.
Solar Panel Wattage Calculator Formula and Mathematical Explanation
The core of the solar panel wattage calculator relies on a few key formulas to bridge the gap between your energy needs and the solar system's potential output. The primary goal is to determine the total wattage required to generate enough electricity to cover your consumption, considering real-world inefficiencies.
Step-by-Step Derivation:
Calculate Required Daily Energy Generation (kWh): This is your average daily energy consumption, adjusted for system losses. The formula is:
Required Daily Generation (kWh) = Average Daily Energy Consumption (kWh) / System Loss Factor
This step ensures that the system is sized to produce enough energy *after* accounting for inefficiencies.
Determine Required System Size (kW): This is the total DC (Direct Current) power capacity your solar array needs to produce the required daily energy within the available peak sun hours. The formula is:
Required System Size (kW) = Required Daily Generation (kWh) / Peak Sun Hours Per Day
This tells you the overall capacity needed from your panels.
Calculate Total Panel Wattage (W): Since system size is often expressed in kilowatts (kW) and individual panel ratings in watts (W), we convert the required system size to watts.
Total Panel Wattage (W) = Required System Size (kW) * 1000
Calculate Number of Panels: This determines how many individual solar panels you'll need to achieve the total required wattage.
Number of Panels = Total Panel Wattage (W) / Individual Solar Panel Wattage (W)
Estimate Daily Energy Production (kWh): This is a check to see how much energy the calculated system size is expected to produce.
Estimated Daily Energy Production (kWh) = Required System Size (kW) * Peak Sun Hours Per Day * System Loss Factor
This value should ideally be close to or slightly exceed your Average Daily Energy Consumption.
Variable Explanations:
Understanding the variables is key to using the solar panel wattage calculator effectively:
Variable
Meaning
Unit
Typical Range
Average Daily Energy Consumption
The amount of electricity your household or business uses on an average day.
kWh (kilowatt-hours)
10 – 100+
Peak Sun Hours Per Day
The equivalent number of hours per day when solar irradiance averages 1000 W/m². It's not just daylight hours, but hours of strong, direct sunlight.
Hours
2 – 7 (varies greatly by location and season)
System Loss Factor
A multiplier representing the percentage of energy lost due to factors like panel temperature, soiling, shading, inverter efficiency, wiring losses, and module degradation.
Decimal (0 to 1)
0.75 – 0.90 (e.g., 0.85 means 15% loss)
Individual Solar Panel Wattage
The rated power output of a single solar panel under Standard Test Conditions (STC).
W (watts)
300 – 450
Required System Size
The total DC power capacity of the solar array needed to meet energy goals.
kW (kilowatts)
Calculated
Total Panel Wattage
The sum of the wattage of all panels in the system.
W (watts)
Calculated
Number of Panels
The quantity of individual solar panels required.
Count
Calculated
Estimated Daily Energy Production
The projected amount of energy the solar system will generate daily.
kWh
Calculated
Practical Examples (Real-World Use Cases)
Let's illustrate how the solar panel wattage calculator works with practical scenarios:
Example 1: Average Suburban Home
A homeowner in a sunny region uses an average of 30 kWh per day. Their location receives about 5 peak sun hours daily. They are using standard 350W panels and estimate a system loss factor of 0.85 (15% loss).
Inputs: Daily kWh = 30, Peak Sun Hours = 5, Loss Factor = 0.85, Panel Wattage = 350W
Interpretation: This homeowner would need approximately a 7.06 kW system, comprising about 21 panels, each rated at 350W. This system is estimated to produce around 30 kWh daily, meeting their average consumption.
Example 2: High-Energy Business
A small commercial building uses significantly more energy, averaging 150 kWh per day. They are in a location with 4.5 peak sun hours and anticipate a higher system loss factor of 0.80 due to some shading and equipment. They are considering higher-efficiency 400W panels.
Inputs: Daily kWh = 150, Peak Sun Hours = 4.5, Loss Factor = 0.80, Panel Wattage = 400W
Interpretation: The business requires a substantial 41.67 kW system, needing around 105 panels of 400W each. This system is projected to generate approximately 150 kWh daily, covering their high energy demands.
How to Use This Solar Panel Wattage Calculator
Using the solar panel wattage calculator is straightforward. Follow these steps to get your personalized solar system estimate:
Gather Your Energy Data: Find your average daily electricity consumption in kilowatt-hours (kWh). This is usually available on your monthly utility bills or by logging into your utility provider's online portal. If you only have monthly or annual usage, divide it by 30 (for monthly) or 365 (for annual) to get a daily average.
Determine Peak Sun Hours: Research the average peak sun hours for your specific geographic location. Online resources and solar installer consultations can provide this data. Remember, this is different from total daylight hours.
Estimate System Losses: Consider potential energy losses. A common starting point is a loss factor of 0.85, but factors like shading, roof orientation, and equipment efficiency can influence this. Consult with a solar professional for a more precise estimate.
Choose Panel Wattage: Decide on the wattage of the individual solar panels you plan to use. Common residential panels range from 300W to 450W. Higher wattage panels mean fewer panels are needed for the same total system size, but they might be more expensive per panel.
Input the Values: Enter the gathered data into the corresponding fields of the calculator: 'Average Daily Energy Consumption (kWh)', 'Peak Sun Hours Per Day', 'System Loss Factor', and 'Individual Solar Panel Wattage (W)'.
Calculate: Click the 'Calculate Wattage' button.
How to Read Results:
Required System Size (kW): This is the most critical output, indicating the total power capacity your solar array needs.
Total Panel Wattage (W): The sum of the power ratings of all panels.
Number of Panels: The quantity of individual panels needed to achieve the total wattage.
Estimated Daily Energy Production (kWh): A projection of how much energy your system will generate daily. Compare this to your average daily consumption.
Decision-Making Guidance:
The results from this solar panel wattage calculator provide a strong estimate, but they are not a final quote. Use this information to:
Understand the scale of the solar project required for your needs.
Have informed discussions with solar installers.
Compare different system sizes and panel options.
Assess if your roof has sufficient space for the calculated number of panels.
If the estimated system size is larger than anticipated, consider energy efficiency improvements in your home or business to reduce your consumption first. You might also explore options like battery storage for energy management.
Key Factors That Affect Solar Panel Wattage Results
While the solar panel wattage calculator provides a solid estimate, several real-world factors can influence the actual performance and required size of your solar system:
Geographic Location & Shading: Your latitude significantly impacts the number of peak sun hours. Even within a location, shading from trees, buildings, or chimneys can drastically reduce output, potentially requiring a larger system or specific panel placement. This is why the 'Peak Sun Hours' and 'System Loss Factor' are crucial inputs.
Roof Orientation and Tilt Angle: In the Northern Hemisphere, a south-facing roof is ideal for maximizing solar exposure. The tilt angle of the panels, optimized for your latitude, also plays a role. Incorrect orientation or tilt can decrease energy generation, necessitating a larger system to compensate.
Seasonal Variations: Peak sun hours and ambient temperatures fluctuate throughout the year. The calculator typically uses annual averages. Winter months may see lower production, while summer might yield more, affecting overall energy balance. Battery storage can help manage these variations.
Panel Degradation: Solar panels degrade slowly over time, typically losing a small percentage of their efficiency each year (e.g., 0.5% per year). While modern panels are warrantied against excessive degradation, this long-term factor might influence the initial sizing decision for systems intended to last 25+ years.
Inverter Efficiency and Type: The inverter converts DC power from panels to AC power for your home. Different inverter types (string, microinverters, power optimizers) have varying efficiencies and performance characteristics, especially under partial shading. This is factored into the 'System Loss Factor'.
Energy Consumption Patterns: While the calculator uses average daily consumption, actual usage patterns matter. If you use most of your energy during non-solar hours (evenings), you might need a larger system or battery storage to maximize self-consumption and reduce reliance on grid electricity, especially if net metering policies are unfavorable.
Local Climate and Temperature: Solar panels perform slightly less efficiently at very high temperatures. While the 'System Loss Factor' accounts for this generally, extremely hot climates might experience a more pronounced effect, potentially requiring slightly oversizing the system.
Future Energy Needs: Consider potential increases in energy consumption due to adding electric vehicles, upgrading appliances, or expanding your home. Sizing the system slightly larger initially can be more cost-effective than adding panels later.
Frequently Asked Questions (FAQ)
Q1: How accurate is a solar panel wattage calculator?
The accuracy depends heavily on the quality of the input data, especially average daily consumption and peak sun hours for your specific location. It provides a strong estimate for initial planning but should be verified by a professional solar assessment.
Q2: Do I need to cover 100% of my energy usage?
Not necessarily. Many homeowners aim to offset a significant portion (e.g., 80-100%) of their electricity bill. The decision depends on your budget, available roof space, local incentives, and net metering policies. Some may choose a smaller system for cost savings or environmental reasons.
Q3: What are peak sun hours?
Peak sun hours are the equivalent number of hours per day when solar irradiance averages 1,000 watts per square meter. It's a measure of solar energy intensity, not just the length of daylight. A cloudy day has fewer peak sun hours than a clear day, even if the daylight duration is the same.
Q4: Can I use the calculator if I don't know my exact daily kWh?
Yes, you can estimate. Look at your annual electricity usage (in kWh) on your utility bill and divide by 365 to get a rough daily average. For more accuracy, check your monthly bills for the past year and average those figures.
Q5: What does a system loss factor of 0.85 mean?
A system loss factor of 0.85 means that approximately 15% of the energy generated by the solar panels is lost due to various factors such as temperature, dirt on panels, inverter inefficiency, wiring resistance, and module degradation over time. The calculator uses this to ensure the system is sized to produce enough energy *after* these losses.
Q6: How many solar panels do I need?
The number of panels depends on your total required system wattage and the wattage of individual panels. The calculator provides this estimate. For example, a 7 kW system using 350W panels would require approximately 20 panels (7000W / 350W).
Q7: Should I size my system for 100% of my usage or more?
Sizing for 100% is common, but consider your goals. If your utility offers favorable net metering (crediting you full retail rate for excess energy sent to the grid), oversizing slightly might be beneficial. If net metering is poor, sizing closer to your actual usage or incorporating battery storage becomes more important to avoid losing value on excess generation.
Q8: What is the difference between AC and DC wattage?
Solar panels generate Direct Current (DC) electricity. Your home uses Alternating Current (AC) electricity. The inverter handles this conversion. Solar system size is typically quoted in DC watts (e.g., 5000W or 5kW DC), but the actual AC output available to your home will be slightly less due to inverter and other system losses.
Related Tools and Internal Resources
Solar ROI CalculatorCalculate the return on investment for your solar panel system, considering installation costs, energy savings, and incentives.
Solar Panel Cost EstimatorGet an estimate of the total cost for installing a solar panel system based on your location and system size.
Home Energy Audit GuideLearn how to identify energy inefficiencies in your home that could be reduced before sizing your solar system.
Understanding Net MeteringExplore how net metering policies work and how they impact the financial benefits of solar energy.
Solar Battery Storage CalculatorEstimate the size and cost of a battery storage system to complement your solar panels for backup power and optimized usage.
Benefits of Renewable EnergyDiscover the environmental and economic advantages of switching to renewable energy sources like solar power.
var chartInstance = null; // Global variable to hold chart instance
function validateInput(id, min, max, errorMessageId, helperTextId) {
var input = document.getElementById(id);
var errorDiv = document.getElementById(errorMessageId);
var helperText = document.getElementById(helperTextId);
var value = parseFloat(input.value);
errorDiv.style.display = 'none'; // Hide error by default
input.style.borderColor = '#ccc'; // Reset border color
if (isNaN(value)) {
errorDiv.textContent = 'Please enter a valid number.';
errorDiv.style.display = 'block';
input.style.borderColor = '#dc3545';
return false;
}
if (value max) {
errorDiv.textContent = 'Value cannot be greater than ' + max + '.';
errorDiv.style.display = 'block';
input.style.borderColor = '#dc3545';
return false;
}
return true;
}
function calculateWattage() {
// Input validation
var isValidDailyKwh = validateInput('dailyKwh', 0, null, 'dailyKwhError');
var isValidPeakSunHours = validateInput('peakSunHours', 0, 24, 'peakSunHoursError');
var isValidSystemLossFactor = validateInput('systemLossFactor', 0, 1, 'systemLossFactorError');
var isValidPanelWattage = validateInput('panelWattage', 100, null, 'panelWattageError');
if (!isValidDailyKwh || !isValidPeakSunHours || !isValidSystemLossFactor || !isValidPanelWattage) {
return; // Stop calculation if any input is invalid
}
var dailyKwh = parseFloat(document.getElementById('dailyKwh').value);
var peakSunHours = parseFloat(document.getElementById('peakSunHours').value);
var systemLossFactor = parseFloat(document.getElementById('systemLossFactor').value);
var panelWattage = parseFloat(document.getElementById('panelWattage').value);
// Calculations
var requiredDailyGeneration = dailyKwh / systemLossFactor;
var requiredSystemSize = requiredDailyGeneration / peakSunHours; // in kW
var totalPanelWattage = requiredSystemSize * 1000; // in W
var numberOfPanels = totalPanelWattage / panelWattage;
var estimatedDailyProduction = requiredSystemSize * peakSunHours * systemLossFactor; // in kWh
// Display results
document.getElementById('requiredSystemSize').textContent = requiredSystemSize.toFixed(2);
document.getElementById('totalPanelWattage').textContent = totalPanelWattage.toFixed(0);
document.getElementById('numberOfPanels').textContent = Math.ceil(numberOfPanels).toFixed(0); // Round up panels
document.getElementById('estimatedDailyProduction').textContent = estimatedDailyProduction.toFixed(2);
// Update table
document.getElementById('tableDailyKwh').textContent = dailyKwh.toFixed(2);
document.getElementById('tablePeakSunHours').textContent = peakSunHours.toFixed(1);
document.getElementById('tableLossFactor').textContent = systemLossFactor.toFixed(2);
document.getElementById('tablePanelWattage').textContent = panelWattage.toFixed(0);
document.getElementById('tableRequiredSize').textContent = requiredSystemSize.toFixed(2);
document.getElementById('tableTotalWattage').textContent = totalPanelWattage.toFixed(0);
document.getElementById('tableNumPanels').textContent = Math.ceil(numberOfPanels).toFixed(0);
document.getElementById('tableEstProduction').textContent = estimatedDailyProduction.toFixed(2);
// Update chart
updateChart(dailyKwh, estimatedDailyProduction);
}
function resetCalculator() {
document.getElementById('dailyKwh').value = '30';
document.getElementById('peakSunHours').value = '5';
document.getElementById('systemLossFactor').value = '0.85';
document.getElementById('panelWattage').value = '350';
// Clear errors
document.getElementById('dailyKwhError').textContent = ";
document.getElementById('dailyKwhError').style.display = 'none';
document.getElementById('peakSunHoursError').textContent = ";
document.getElementById('peakSunHoursError').style.display = 'none';
document.getElementById('systemLossFactorError').textContent = ";
document.getElementById('systemLossFactorError').style.display = 'none';
document.getElementById('panelWattageError').textContent = ";
document.getElementById('panelWattageError').style.display = 'none';
// Reset input borders
document.getElementById('dailyKwh').style.borderColor = '#ccc';
document.getElementById('peakSunHours').style.borderColor = '#ccc';
document.getElementById('systemLossFactor').style.borderColor = '#ccc';
document.getElementById('panelWattage').style.borderColor = '#ccc';
// Reset results
document.getElementById('requiredSystemSize').textContent = '–';
document.getElementById('totalPanelWattage').textContent = '–';
document.getElementById('numberOfPanels').textContent = '–';
document.getElementById('estimatedDailyProduction').textContent = '–';
// Reset table
document.getElementById('tableDailyKwh').textContent = '–';
document.getElementById('tablePeakSunHours').textContent = '–';
document.getElementById('tableLossFactor').textContent = '–';
document.getElementById('tablePanelWattage').textContent = '–';
document.getElementById('tableRequiredSize').textContent = '–';
document.getElementById('tableTotalWattage').textContent = '–';
document.getElementById('tableNumPanels').textContent = '–';
document.getElementById('tableEstProduction').textContent = '–';
// Clear chart
if (chartInstance) {
chartInstance.destroy();
chartInstance = null;
}
var canvas = document.getElementById('wattageChart');
var ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
}
function copyResults() {
var requiredSystemSize = document.getElementById('requiredSystemSize').textContent;
var totalPanelWattage = document.getElementById('totalPanelWattage').textContent;
var numberOfPanels = document.getElementById('numberOfPanels').textContent;
var estimatedDailyProduction = document.getElementById('estimatedDailyProduction').textContent;
var dailyKwh = document.getElementById('tableDailyKwh').textContent;
var peakSunHours = document.getElementById('tablePeakSunHours').textContent;
var lossFactor = document.getElementById('tableLossFactor').textContent;
var panelWattage = document.getElementById('tablePanelWattage').textContent;
var assumptions = "Key Assumptions:\n" +
"- Average Daily Consumption: " + dailyKwh + " kWh\n" +
"- Peak Sun Hours: " + peakSunHours + "\n" +
"- System Loss Factor: " + lossFactor + "\n" +
"- Individual Panel Wattage: " + panelWattage + " W\n";
var resultsText = "Solar System Estimate:\n" +
"- Required System Size: " + requiredSystemSize + " kW\n" +
"- Total Panel Wattage: " + totalPanelWattage + " W\n" +
"- Number of Panels: " + numberOfPanels + "\n" +
"- Estimated Daily Production: " + estimatedDailyProduction + " kWh\n\n" +
assumptions;
// Use a temporary textarea to copy text
var textArea = document.createElement("textarea");
textArea.value = resultsText;
textArea.style.position = "fixed";
textArea.style.left = "-9999px";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'Results copied!' : 'Copying failed!';
// Optionally show a temporary message to the user
console.log(msg);
} catch (err) {
console.log('Oops, unable to copy');
}
document.body.removeChild(textArea);
}
function updateChart(dailyKwh, estimatedDailyProduction) {
var canvas = document.getElementById('wattageChart');
var ctx = canvas.getContext('2d');
// Destroy previous chart instance if it exists
if (chartInstance) {
chartInstance.destroy();
}
// Set canvas dimensions dynamically based on container width
var chartContainer = canvas.parentElement;
canvas.width = chartContainer.offsetWidth;
canvas.height = 300; // Fixed height or make it responsive too
chartInstance = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Energy Consumption', 'Estimated Production'],
datasets: [{
label: 'Daily Energy (kWh)',
data: [dailyKwh, estimatedDailyProduction],
backgroundColor: [
'rgba(0, 74, 153, 0.6)', // Primary color for consumption
'rgba(40, 167, 69, 0.6)' // Success color for production
],
borderColor: [
'rgba(0, 74, 153, 1)',
'rgba(40, 167, 69, 1)'
],
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false, // Allows custom height
scales: {
y: {
beginAtZero: true,
title: {
display: true,
text: 'kWh'
}
}
},
plugins: {
legend: {
display: false // Hide legend as labels are clear
},
title: {
display: true,
text: 'Daily Energy Comparison'
}
}
}
});
}
// Add event listeners for FAQ toggles
document.addEventListener('DOMContentLoaded', function() {
var faqQuestions = document.querySelectorAll('.faq-question');
faqQuestions.forEach(function(question) {
question.addEventListener('click', function() {
var answer = this.nextElementSibling;
if (answer.style.display === 'block') {
answer.style.display = 'none';
} else {
answer.style.display = 'block';
}
});
});
// Initial calculation on page load if inputs have default values
calculateWattage();
});
// Simple Chart.js implementation (requires Chart.js library to be included externally or embedded)
// For this specific requirement, we need to embed a basic chart or use SVG.
// Since external libraries are forbidden, let's use a simplified approach or note the dependency.
// Given the constraint "NO external chart libraries", a pure SVG or Canvas approach without libraries is needed.
// Let's implement a basic Canvas chart directly.
// — Basic Canvas Chart Implementation (No external library) —
// This requires manual drawing logic. For simplicity and adherence to the prompt,
// I'll simulate the chart drawing using basic canvas API.
// NOTE: A full-featured charting library like Chart.js is usually preferred for complexity and features.
// The previous `updateChart` function assumed Chart.js. Let's replace it with a pure Canvas version.
function updateChart(dailyKwh, estimatedDailyProduction) {
var canvas = document.getElementById('wattageChart');
var ctx = canvas.getContext('2d');
var chartContainer = canvas.parentElement;
// Clear previous drawing
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Set canvas dimensions
canvas.width = chartContainer.offsetWidth;
canvas.height = 300; // Fixed height
var barWidth = 50;
var barSpacing = 30;
var chartAreaWidth = canvas.width – 40; // Padding
var chartAreaHeight = canvas.height – 60; // Padding for labels
var maxValue = Math.max(dailyKwh, estimatedDailyProduction) * 1.1; // Max value for scaling, add 10% buffer
if (maxValue === 0) maxValue = 1; // Avoid division by zero
// Draw labels and title
ctx.fillStyle = '#004a99′;
ctx.font = '16px Segoe UI';
ctx.textAlign = 'center';
ctx.fillText('Daily Energy Comparison', canvas.width / 2, 20);
// Draw Y-axis scale and labels
ctx.fillStyle = '#333′;
ctx.font = '12px Segoe UI';
ctx.textAlign = 'right';
var numTicks = 5;
for (var i = 0; i <= numTicks; i++) {
var yPos = canvas.height – 40 – (i * (chartAreaHeight / numTicks));
var value = (maxValue / numTicks) * i;
ctx.fillText(value.toFixed(1), 30, yPos + 5);
ctx.beginPath();
ctx.moveTo(40, yPos);
ctx.lineTo(canvas.width – 20, yPos);
ctx.strokeStyle = '#eee';
ctx.stroke();
}
// Draw bars
var consumptionX = 60;
var productionX = consumptionX + barWidth + barSpacing;
// Consumption Bar
var consumptionHeight = (dailyKwh / maxValue) * chartAreaHeight;
ctx.fillStyle = 'rgba(0, 74, 153, 0.6)';
ctx.fillRect(consumptionX, canvas.height – 40 – consumptionHeight, barWidth, consumptionHeight);
ctx.fillStyle = '#004a99';
ctx.fillText('Consumption', consumptionX + barWidth / 2, canvas.height – 25);
ctx.fillText(dailyKwh.toFixed(2) + ' kWh', consumptionX + barWidth / 2, canvas.height – 45);
// Production Bar
var productionHeight = (estimatedDailyProduction / maxValue) * chartAreaHeight;
ctx.fillStyle = 'rgba(40, 167, 69, 0.6)';
ctx.fillRect(productionX, canvas.height – 40 – productionHeight, barWidth, productionHeight);
ctx.fillStyle = '#28a745';
ctx.fillText('Production', productionX + barWidth / 2, canvas.height – 25);
ctx.fillText(estimatedDailyProduction.toFixed(2) + ' kWh', productionX + barWidth / 2, canvas.height – 45);
// Adjust bar width if canvas is too narrow
if (canvas.width < 200) {
barWidth = 20;
barSpacing = 15;
consumptionX = 30;
productionX = consumptionX + barWidth + barSpacing;
// Redraw with adjusted values if needed, or ensure it scales reasonably.
// For simplicity, let's assume the initial calculation is sufficient for most cases.
}
}