Your essential tool to calculate overtime pay in California accurately.
Calculate Your California Overtime Pay
Enter your regular hourly wage.
Enter the number of hours worked at your regular rate (typically up to 40).
Enter the number of hours worked exceeding the regular threshold (usually 40).
8 hours per day (standard California rule)
12 hours per day (alternative if applicable)
California law often requires double time after 8 hours in a day or 12 hours in a day for certain industries or agreements. Check your specific situation.
Your Overtime Pay Details
—
Key Assumptions
Results copied to clipboard!
Overtime Pay Distribution
Weekly Pay Breakdown
What is California Overtime Pay?
California overtime pay is a legal requirement that mandates employers pay their non-exempt employees a higher rate for hours worked beyond a standard threshold. This is a crucial aspect of labor law designed to protect workers from exploitation and to discourage excessive work hours. In California, overtime rules are more generous than in many other states, with provisions for both daily and weekly overtime, as well as double time for significantly long workdays. Understanding how to calculate California overtime pay is essential for both employees to ensure they are compensated correctly and for employers to remain compliant with state labor laws. This calculator is specifically designed to demystify the process of how to calculate overtime pay in california.
Who Should Use This Calculator?
This calculator is primarily for non-exempt employees working in California. This includes hourly workers, salaried workers who do not meet specific executive, administrative, or professional exemptions, and any employee whose job duties do not fall under specific legal exemptions. It's also useful for small business owners and HR professionals in California to verify their payroll calculations and ensure compliance with the complex California labor laws regarding overtime. Misconceptions about overtime eligibility are common, so using a reliable tool like this helps clarify individual situations.
Common Misconceptions
"Salaried employees are never eligible for overtime." This is false. Many salaried employees are eligible if they are non-exempt and meet the overtime thresholds.
"Only hours over 40 in a week count for overtime." In California, overtime can also apply for hours worked over 8 in a single day.
"All overtime is paid at time-and-a-half." California law mandates double time under certain circumstances.
"My employer can just give me 'comp time' instead of overtime pay." In California, for most private-sector employees, cash payment is legally required; compensatory time off (comp time) is generally not allowed.
California Overtime Pay Formula and Mathematical Explanation
Calculating California overtime pay involves understanding several key rates and thresholds. The core of how to calculate overtime pay in california relies on determining the standard time-and-a-half rate and the double time rate.
The Formulas
1. Standard Overtime Rate (Time-and-a-Half): This is the rate for hours worked over 8 in a day or over 40 in a week, up to the point where double time applies.
Standard Overtime Rate = Hourly Rate × 1.5
2. Double Time Rate: This is the rate for hours worked beyond a certain threshold, typically after 12 hours in a day or 8 consecutive hours on the 7th consecutive day of a workweek.
Double Time Rate = Hourly Rate × 2.0
3. Total Weekly Pay: This is the sum of pay for regular hours, standard overtime hours, and double time hours.
Total Weekly Pay = (Regular Hours × Hourly Rate) + (Standard Overtime Hours × Standard Overtime Rate) + (Double Time Hours × Double Time Rate)
Variable Explanations
Let's break down the variables used in the calculation of how to calculate overtime pay in california:
Variable
Meaning
Unit
Typical Range
Hourly Rate
Your regular base wage per hour.
Currency ($)
$15.00+ (minimum wage is higher in many CA cities)
Regular Hours
Hours worked up to the standard daily or weekly threshold for regular pay.
Hours
0 – 40 (typically)
Overtime Hours (Standard)
Hours worked beyond 8 in a day or 40 in a week, but before double time is triggered.
Hours
0+
Double Time Hours
Hours worked that qualify for the double time rate (e.g., after 12 hours in a day).
Hours
0+
Standard Overtime Rate
1.5 times the regular hourly rate.
Currency ($)
Hourly Rate × 1.5
Double Time Rate
2.0 times the regular hourly rate.
Currency ($)
Hourly Rate × 2.0
Total Weekly Pay
The sum of all earnings for the week.
Currency ($)
Variable
Double Time Threshold
The daily hour limit after which double time pay is required.
Hours
8 or 12 (depending on circumstances)
How the Calculator Works
Our calculator takes your Hourly Rate, Regular Hours, and Overtime Hours. It first calculates the Standard Overtime Rate (1.5x) and the Double Time Rate (2x) based on your hourly wage. It then determines how your entered overtime hours fall into standard overtime or double time categories based on common California overtime rules and the selected Double Time Threshold. Finally, it sums up the pay for regular hours, standard overtime hours, and double time hours to present your Total Pay. The calculator also highlights the intermediate rates and assumptions for clarity on how to calculate overtime pay in california.
Practical Examples (Real-World Use Cases)
Example 1: Standard Weekly Overtime
Maria is a non-exempt employee in California earning $25 per hour. This week, she worked 40 regular hours and 5 overtime hours. No daily thresholds were exceeded beyond the standard 8 hours.
Inputs:
Hourly Rate: $25.00
Regular Hours Worked: 40
Overtime Hours Worked: 5
Double Time Threshold: 8 hours per day
Calculation Steps:
Regular Pay: 40 hours * $25.00/hour = $1000.00
Standard Overtime Rate: $25.00 * 1.5 = $37.50/hour
Overtime Pay: 5 hours * $37.50/hour = $187.50
Total Pay: $1000.00 + $187.50 = $1187.50
Results:
Overtime Rate (Time-and-a-Half): $37.50
Double Time Rate: $50.00
Total Pay for the Week: $1187.50
Maria correctly earns her regular pay plus time-and-a-half for the 5 extra hours she worked, demonstrating a basic application of how to calculate overtime pay in california.
Example 2: Daily Overtime and Double Time
John works as a contractor in California and earns $40 per hour. His workweek was particularly demanding. On Monday, he worked 10 hours. On Tuesday, he worked 12 hours. Wednesday through Friday, he worked 8 hours each day.
This example highlights how daily thresholds trigger different overtime rates. John's pay reflects standard overtime for hours between 8 and 12 on Monday, and double time for the hours exceeding 12 on Tuesday. This demonstrates a more complex scenario of how to calculate overtime pay in california.
How to Use This California Overtime Pay Calculator
Using our California Overtime Pay Calculator is straightforward. Follow these simple steps to get an accurate estimate of your overtime earnings.
Enter Your Hourly Rate: Input your regular base wage per hour in the designated field. Ensure this is your standard rate before any overtime multipliers are applied.
Input Regular Hours Worked: Enter the total number of hours you worked this week that qualify for your regular hourly rate. This is typically up to 40 hours, but check your specific pay period rules.
Input Overtime Hours Worked: Enter the total number of hours you worked beyond your regular hours. The calculator will help determine how these hours are categorized (standard overtime vs. double time).
Select Double Time Threshold: Choose the applicable daily threshold for double time pay from the dropdown. The most common is 8 hours per day, but 12 hours per day can apply in certain situations. Consult your employer or California labor law resources if unsure.
Click "Calculate Overtime": Once all fields are populated, click the calculate button.
Reading the Results
The calculator will display:
Primary Result (Total Pay): Your estimated total earnings for the week, including regular and all overtime pay.
Overtime Rate (Time-and-a-Half): The calculated rate for standard overtime hours.
Double Time Rate: The calculated rate for hours qualifying for double pay.
Key Assumptions: Important notes about the calculation, such as the overtime multipliers used and the daily threshold applied.
Decision-Making Guidance
Use these results to:
Verify your paycheck accuracy.
Understand your potential earnings for extra work.
Negotiate with your employer if you believe you are being underpaid.
Plan your finances based on expected earnings.
Remember, this calculator provides an estimate based on common California overtime regulations. Your specific employment agreement or union contract might have slightly different terms, but the core principles of how to calculate overtime pay in california remain.
Key Factors That Affect California Overtime Pay Results
Several factors influence the accuracy and outcome of your overtime pay calculation. Understanding these is crucial for a precise understanding of how to calculate overtime pay in california.
Hourly Rate Accuracy: Ensure you are using your correct base hourly wage. Bonuses, commissions, or shift differentials might need to be factored into the regular rate of pay for overtime calculations, which can be complex and may require consulting a legal professional.
Definition of Regular Rate of Pay: California law (and federal law) requires that the overtime rate be based on the employee's "regular rate of pay," which includes not just the hourly wage but also other forms of remuneration like non-discretionary bonuses. This calculator assumes the hourly rate entered is the complete regular rate for simplicity.
Workweek vs. Day Calculation: California has a "double-duty" overtime standard. This means overtime is due if an employee works more than 8 hours in a day OR more than 40 hours in a week. Double time is typically required after 12 hours in a day or 8 hours on the seventh consecutive day in a workweek. Our calculator accounts for the daily threshold you select.
Exempt vs. Non-Exempt Status: This calculator is designed for non-exempt employees. Exempt employees (often those in executive, administrative, or professional roles meeting specific salary and duty tests) are generally not entitled to overtime pay. Misclassifying an employee can lead to significant legal liabilities for employers.
Industry-Specific Regulations: Certain industries (e.g., healthcare, transportation) might have specific nuances or alternative workweek schedules approved by the state that alter standard overtime rules. Always verify industry-specific California labor laws.
Union Contracts and Collective Bargaining Agreements: If you are part of a union, your collective bargaining agreement may stipulate different or more favorable overtime rates and conditions than the state minimum. Always refer to your specific contract.
Meal and Rest Break Premiums: If an employer fails to provide legally mandated meal or rest breaks, they may owe premium pay. This is separate from overtime but impacts overall compensation.
Seventh Consecutive Day Overtime: California law mandates time-and-a-half for the first 8 hours worked on the seventh consecutive day of work in a workweek, and double time for any hours worked over 8 on that seventh day. Our calculator focuses on daily and weekly thresholds but it's important to be aware of this rule.
Frequently Asked Questions (FAQ)
Q1: What is the minimum wage in California and how does it affect overtime?
A1: As of 2024, the general minimum wage in California is $16.00 per hour. However, many cities and counties have higher local minimum wages. Your regular hourly rate must be at least the applicable minimum wage. Overtime is calculated based on this regular rate, so a higher minimum wage means a higher base for calculating overtime pay.
Q2: Can my employer force me to work overtime?
A2: In California, for non-exempt employees, employers can generally require employees to work overtime, provided it doesn't violate public policy or specific contractual agreements. Employees cannot be retaliated against for refusing to work excessive hours if they have a valid reason recognized by law.
Q3: What if my employer pays me a salary? Am I still eligible for overtime?
A3: It depends on your "exempt" status. Employees are exempt from overtime if they meet specific criteria related to job duties (executive, administrative, professional) AND a minimum salary threshold (which is 2x the state minimum wage annually). If you are a salaried employee but do not meet ALL the exemption criteria, you are considered "non-exempt" and are entitled to overtime pay based on your calculated regular rate of pay.
Q4: How do I calculate overtime if my hourly rate changes during the week?
A4: This is complex. Generally, California law requires calculating a "regular rate of pay" that averages all earnings over the workweek. If your rate changes, you would typically calculate pay for each hour at its specific rate and then apply the overtime multiplier to the relevant hours based on the average rate, or a specific rate if dictated by law or contract. This calculator assumes a single, consistent hourly rate for simplicity.
Q5: Does California overtime apply to all types of work?
A5: The general overtime rules apply to most non-exempt employees. However, there are specific exemptions for certain occupations (e.g., outside sales, some agricultural workers, certain computer professionals meeting specific salary and non-discretionary bonus criteria). Always verify your classification.
Q6: What is an "alternative workweek schedule" in California?
A6: An alternative workweek schedule (AWS) allows employees to work longer daily shifts (e.g., 4 days of 10 hours) in exchange for a full day off, while still being paid regular rates for those longer days, provided the schedule is properly adopted and approved. Standard overtime rules (over 8 hours/day) do not apply *within* the approved AWS. However, hours worked beyond the schedule still trigger overtime. This calculator assumes a standard workweek.
Q7: How is overtime calculated on holidays?
A7: Overtime pay on holidays is calculated the same way as any other day. If working on a holiday results in you working more than 8 hours in that day or more than 40 hours in the workweek, you are entitled to the appropriate overtime rate (time-and-a-half or double time) for those hours. Some employers offer holiday pay premiums in addition to or instead of overtime, which should be detailed in your employment agreement.
Q8: What should I do if my employer is not paying me correctly for overtime?
A8: First, gather documentation of your hours worked and pay received. You can then speak with your employer to try and resolve the issue. If unresolved, you have the right to file a wage claim with the California Labor Commissioner's Office. Consulting with an employment lawyer specializing in California wage and hour laws is also a strong option.
Analyze your pay stubs to ensure all deductions and earnings are accurate.
function isNumeric(value) {
return !isNaN(parseFloat(value)) && isFinite(value);
}
function validateInput(id, errorId, min, max) {
var input = document.getElementById(id);
var errorSpan = document.getElementById(errorId);
var value = input.value.trim();
var isValid = true;
errorSpan.textContent = ";
errorSpan.classList.remove('visible');
input.style.borderColor = 'var(–border-color)';
if (value === "") {
errorSpan.textContent = 'This field is required.';
isValid = false;
} else if (!isNumeric(value)) {
errorSpan.textContent = 'Please enter a valid number.';
isValid = false;
} else {
var numValue = parseFloat(value);
if (numValue max) {
errorSpan.textContent = 'Value exceeds maximum limit.';
isValid = false;
}
}
if (!isValid) {
input.style.borderColor = '#dc3545';
}
return isValid;
}
function calculateOvertime() {
var hourlyRate = parseFloat(document.getElementById('hourlyRate').value);
var regularHours = parseFloat(document.getElementById('regularHours').value);
var overtimeHours = parseFloat(document.getElementById('overtimeHours').value);
var doubleTimeThreshold = parseInt(document.getElementById('doubleTimeThreshold').value);
var valid = true;
if (!validateInput('hourlyRate', 'hourlyRateError', 0)) valid = false;
if (!validateInput('regularHours', 'regularHoursError', 0)) valid = false;
if (!validateInput('overtimeHours', 'overtimeHoursError', 0)) valid = false;
if (!valid) {
document.getElementById('results-title').textContent = "Please correct the errors above.";
document.getElementById('primary-result').textContent = "–";
document.getElementById('overtimeRate').innerHTML = "";
document.getElementById('doubleTimeRate').innerHTML = "";
document.getElementById('totalPay').innerHTML = "";
document.getElementById('assumptions').innerHTML = "";
return;
}
var standardOvertimeRate = hourlyRate * 1.5;
var doubleTimeRate = hourlyRate * 2.0;
var calculatedOvertimeHours = overtimeHours;
var calculatedDoubleTimeHours = 0;
var calculatedStandardOvertimeHours = 0;
// Simplified logic: Assumes total hours entered are overtime.
// More complex logic would consider daily vs weekly thresholds if inputs were structured differently.
// For this calculator, we assume 'overtimeHours' is the total supplemental hours.
// The doubleTimeThreshold dictates how these are split if they exceed daily limits.
// A more robust calculator would need daily hour inputs.
// For this example, we'll assume 'overtimeHours' are standard unless they push total over 12/day or 8 on 7th day.
// Since we only have total OT hours, we'll simplify:
// If doubleTimeThreshold is 8, and overtimeHours implies >8/day, some might be double.
// If doubleTimeThreshold is 12, OT hours only become double time if >12/day.
// Given the input structure, we'll allocate 'overtimeHours' to standard OT first,
// and then consider if any portion *could* qualify for double time based on the threshold concept.
// A common simplified approach: if total weekly hours > 8/day (standard) or >12/day (double), distribute.
// Given limited input, we'll assume overtimeHours are split:
// Assume hours between 8-12/day (or 8-8 on 7th day) are standard OT.
// Assume hours >12/day (or >8 on 7th day) are double time.
// Since we don't have daily breakdown, we'll use a common interpretation:
// If total hours worked exceed 8 on any given day, the hours over 8 are time-and-a-half.
// If total hours worked exceed 12 on any given day, the hours over 12 are double time.
// Without daily inputs, we simplify: Assume the 'overtimeHours' entered are split.
// Let's assume a standard 5-day week for calculation simplicity if no specific daily breakdown is provided.
// If total hours per day averaged over 5 days is X:
// If X > 8, then X-8 hours are standard OT.
// If X > 12, then X-12 hours are double OT.
// Given we only have TOTAL overtime hours, we make a pragmatic split:
// A portion of overtimeHours could be standard, a portion double.
// Let's re-evaluate the goal: Calculate overtime pay in CALIFORNIA.
// CA has daily OT (over 8 hrs) AND weekly OT (over 40 hrs).
// It also has double time (over 12 hrs/day OR over 8 hrs on 7th consecutive day).
// The current inputs (hourlyRate, regularHours, overtimeHours) are insufficient for precise daily/7th-day calculations.
// HOWEVER, we can use the `overtimeHours` input to *represent* the total hours that exceeded the regular 40-hour threshold.
// Then, we need to decide how `overtimeHours` are categorized.
// The `doubleTimeThreshold` selection implies a daily limit.
// Let's assume that if `overtimeHours` are entered, *some* of them might qualify for double time.
// A common scenario is that someone works, say, 10 hours one day, and 10 hours another day.
// Total hours: 40 (regular) + 10 (OT) + 10 (OT) = 60.
// Daily breakdown: Day 1: 8 + 2 OT. Day 2: 8 + 2 OT. Total OT = 4.
// If threshold is 8: 4 hours standard OT.
// If threshold is 12: all 4 hours are standard OT.
// Given the simplification of inputs, we will apply a common interpretation:
// Assume `overtimeHours` are primarily standard overtime (1.5x).
// If the `doubleTimeThreshold` is set to 8 (meaning any day over 8 triggers double time if it ALSO exceeds 12 in a day, OR if it's the 7th consecutive day),
// we need a way to allocate `overtimeHours`.
// Let's make a simplifying assumption for this calculator's input structure:
// Assume that any hours entered into `overtimeHours` that would push a *hypothetical* daily total over the `doubleTimeThreshold` will be considered double time.
// Since we don't have daily inputs, this is a limitation.
// Let's implement a common approach: if `overtimeHours` are entered, and the threshold is 8, we'll assume *some* portion might be double time.
// A more realistic calculator would ask for Daily Hours.
// Pragmatic approach for THIS calculator:
// Calculate total hours worked: regularHours + overtimeHours.
// If total hours > 40:
// Hours between 40 and 48 (or 40 + (8 – standard_daily_overtime_hours if applicable)) = standard OT
// Hours above 48 (or 40 + (12 – standard_daily_overtime_hours if applicable)) = double time
// This is still tricky without daily input.
// Let's simplify drastically based on typical user input for such a calculator:
// User enters regular hours (assume 8 in a day are time-and-a-half. Hours > 12 in a day are double time.
// If `doubleTimeThreshold` = 12: Assume hours > 12 in a day are double time.
// Since we don't have daily inputs, we infer:
// If `overtimeHours` are entered:
// If `doubleTimeThreshold` is 8, assume that *up to 4* of those overtime hours *might* be double time if daily hours exceeded 12.
// And hours exceeding 8 on the 7th day would also be double time.
// A COMMON interpretation for simplified calculators without daily inputs:
// If threshold is 8: assume OT hours are split: first 4 hrs of OT = 1.5x, next 4 hrs = 2x, then 1.5x again (7th day rule). This gets complicated.
// Let's use the MOST standard interpretation of CA OT:
// Regular Pay = up to 8 hours/day, up to 40 hours/week.
// Time-and-a-Half (1.5x) = Over 8 hours/day, OR over 40 hours/week (whichever applies first).
// Double Time (2.0x) = Over 12 hours/day, OR over 8 hours on the 7th consecutive day.
// Given current inputs, we cannot perfectly distinguish daily vs weekly vs 7th day.
// We MUST make an assumption or simplify.
// Let's assume `overtimeHours` represents hours that *qualify* for overtime beyond the base 40.
// We'll use the `doubleTimeThreshold` to decide how these are split.
var totalHoursWorked = regularHours + overtimeHours;
var totalRegularPay = regularHours * hourlyRate;
var totalOvertimePay = 0;
// Simplified Logic: Assume `overtimeHours` are the hours beyond the regular 40.
// We need to decide how many of these are standard OT vs Double OT.
// The `doubleTimeThreshold` input is key here.
// If the threshold is 8 (standard daily OT rate applies after 8 hrs):
// Assume first 4 hours of `overtimeHours` are standard OT (1.5x).
// Assume any additional `overtimeHours` are double time (2x).
// This is an approximation because it doesn't account for the 7th day rule or specific daily distributions.
if (doubleTimeThreshold == 8) {
calculatedStandardOvertimeHours = Math.min(overtimeHours, 4); // Up to 4 hours as standard OT
calculatedDoubleTimeHours = Math.max(0, overtimeHours – 4); // Any hours beyond that are double time
} else { // If threshold is 12 (or some other custom interpretation for double time)
// Assume all `overtimeHours` are standard OT (1.5x) unless specific conditions met.
// For simplicity here, if threshold is 12, we'll assume all entered overtime hours are 1.5x.
// This is a simplification: double time could still apply after 8 hrs on the 7th day.
calculatedStandardOvertimeHours = overtimeHours;
calculatedDoubleTimeHours = 0;
}
// Ensure we don't calculate more hours than physically possible for a week (e.g., 168 hours)
var maxPossibleHours = 168;
if (totalHoursWorked > maxPossibleHours) {
totalHoursWorked = maxPossibleHours;
// Re-calculate based on max possible hours
regularHours = Math.min(regularHours, 40); // Cap regular hours at 40 for simplicity
overtimeHours = totalHoursWorked – regularHours;
if (doubleTimeThreshold == 8) {
calculatedStandardOvertimeHours = Math.min(overtimeHours, 4);
calculatedDoubleTimeHours = Math.max(0, overtimeHours – 4);
} else {
calculatedStandardOvertimeHours = overtimeHours;
calculatedDoubleTimeHours = 0;
}
}
totalOvertimePay = (calculatedStandardOvertimeHours * standardOvertimeRate) + (calculatedDoubleTimeHours * doubleTimeRate);
var totalPay = totalRegularPay + totalOvertimePay;
document.getElementById('primary-result').textContent = "$" + totalPay.toFixed(2);
document.getElementById('overtimeRate').innerHTML = "Overtime Rate (1.5x): $" + standardOvertimeRate.toFixed(2) + "/hour";
document.getElementById('doubleTimeRate').innerHTML = "Double Time Rate (2.0x): $" + doubleTimeRate.toFixed(2) + "/hour";
document.getElementById('totalPay').innerHTML = "Total Weekly Pay: $" + totalPay.toFixed(2);
var assumptionsText = "Based on a regular rate of $" + hourlyRate.toFixed(2) + "/hr. ";
assumptionsText += "Standard overtime calculated at 1.5x rate. ";
assumptionsText += "Double time calculated at 2.0x rate. ";
assumptionsText += "Overtime hours allocation based on daily threshold of " + doubleTimeThreshold + " hours/day. ";
assumptionsText += "Assumes " + regularHours.toFixed(2) + " regular hours and " + overtimeHours.toFixed(2) + " total overtime hours.";
document.getElementById('assumptions').innerHTML = assumptionsText;
updateCharts(hourlyRate, regularHours, calculatedStandardOvertimeHours, calculatedDoubleTimeHours, standardOvertimeRate, doubleTimeRate, totalRegularPay, totalOvertimePay, totalPay);
}
function resetCalculator() {
document.getElementById('hourlyRate').value = "25.00";
document.getElementById('regularHours').value = "40";
document.getElementById('overtimeHours').value = "5";
document.getElementById('doubleTimeThreshold').value = "8";
document.getElementById('hourlyRateError').textContent = ";
document.getElementById('hourlyRateError').classList.remove('visible');
document.getElementById('hourlyRate').style.borderColor = 'var(–border-color)';
document.getElementById('regularHoursError').textContent = ";
document.getElementById('regularHoursError').classList.remove('visible');
document.getElementById('regularHours').style.borderColor = 'var(–border-color)';
document.getElementById('overtimeHoursError').textContent = ";
document.getElementById('overtimeHoursError').classList.remove('visible');
document.getElementById('overtimeHours').style.borderColor = 'var(–border-color)';
document.getElementById('results-title').textContent = "Your Overtime Pay Details";
document.getElementById('primary-result').textContent = "–";
document.getElementById('overtimeRate').innerHTML = "";
document.getElementById('doubleTimeRate').innerHTML = "";
document.getElementById('totalPay').innerHTML = "";
document.getElementById('assumptions').innerHTML = "";
document.getElementById('copyMessage').style.display = 'none';
// Reset charts
if (window.overtimeChartInstance) {
window.overtimeChartInstance.destroy();
}
if (window.weeklyPayChartInstance) {
window.weeklyPayChartInstance.destroy();
}
document.getElementById('overtimeChart').getContext('2d').clearRect(0, 0, 1000, 500); // Clear canvas
document.getElementById('weeklyPayChart').getContext('2d').clearRect(0, 0, 1000, 500);
document.querySelector('.chart-container:nth-of-type(2) .chart-legend').innerHTML = ";
document.querySelector('.chart-container:nth-of-type(3) .chart-legend').innerHTML = ";
}
function copyResults() {
var primaryResult = document.getElementById('primary-result').textContent;
var overtimeRate = document.getElementById('overtimeRate').innerText.replace('Overtime Rate (1.5x): ', ");
var doubleTimeRate = document.getElementById('doubleTimeRate').innerText.replace('Double Time Rate (2.0x): ', ");
var totalPay = document.getElementById('totalPay').innerText.replace('Total Weekly Pay: ', ");
var assumptions = document.getElementById('assumptions').innerText.replace('Key Assumptions', ");
var resultsText = "— California Overtime Pay Calculation —\n\n";
resultsText += "Total Pay: " + primaryResult + "\n";
resultsText += "Overtime Rate (1.5x): " + overtimeRate + "/hour\n";
resultsText += "Double Time Rate (2.0x): " + doubleTimeRate + "/hour\n";
resultsText += "Total Weekly Pay: " + totalPay + "\n\n";
resultsText += "Assumptions:\n" + assumptions;
navigator.clipboard.writeText(resultsText).then(function() {
var message = document.getElementById('copyMessage');
message.style.display = 'block';
setTimeout(function() {
message.style.display = 'none';
}, 3000);
}).catch(function(err) {
console.error('Could not copy text: ', err);
});
}
function toggleAnswer(element) {
var answer = element.nextElementSibling;
if (answer.style.display === "block") {
answer.style.display = "none";
} else {
answer.style.display = "block";
}
}
function updateCharts(hourlyRate, regularHours, stdOTHours, doubleOTHours, stdOTRate, doubleTRate, regPay, otPay, totalPay) {
var ctx1 = document.getElementById('overtimeChart').getContext('2d');
var ctx2 = document.getElementById('weeklyPayChart').getContext('2d');
// Destroy previous chart instances if they exist
if (window.overtimeChartInstance) {
window.overtimeChartInstance.destroy();
}
if (window.weeklyPayChartInstance) {
window.weeklyPayChartInstance.destroy();
}
// Overtime Pay Distribution Chart
window.overtimeChartInstance = new Chart(ctx1, {
type: 'pie',
data: {
labels: ['Standard Overtime Pay', 'Double Time Pay'],
datasets: [{
data: [stdOTHours * stdOTRate, doubleOTHours * doubleTRate],
backgroundColor: [
'rgba(54, 162, 235, 0.8)', // Blue for standard OT
'rgba(255, 99, 132, 0.8)' // Red for double time
],
borderColor: '#fff',
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
title: {
display: true,
text: 'Distribution of Overtime Pay Earned',
font: { size: 16 }
},
legend: {
position: 'bottom',
},
tooltip: {
callbacks: {
label: function(context) {
var label = context.label || ";
if (label) {
label += ': ';
}
if (context.parsed !== null) {
label += '$' + context.parsed.toFixed(2);
}
return label;
}
}
}
}
}
});
document.querySelector('.chart-container:nth-of-type(2) .chart-legend').innerHTML = `
Standard OT Pay: $${(stdOTHours * stdOTRate).toFixed(2)}Double Time Pay: $${(doubleOTHours * doubleTRate).toFixed(2)}
`;
// Weekly Pay Breakdown Chart
window.weeklyPayChartInstance = new Chart(ctx2, {
type: 'bar',
data: {
labels: ['Regular Pay', 'Overtime Pay', 'Double Time Pay'],
datasets: [{
label: 'Amount ($)',
data: [regPay, stdOTHours * stdOTRate, doubleOTHours * doubleTRate],
backgroundColor: [
'rgba(75, 192, 192, 0.8)', // Green for regular
'rgba(54, 162, 235, 0.8)', // Blue for standard OT
'rgba(255, 99, 132, 0.8)' // Red for double time
],
borderColor: '#fff',
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
title: {
display: true,
text: 'Breakdown of Total Weekly Pay',
font: { size: 16 }
},
legend: {
display: false // Legend is redundant with bar labels
},
tooltip: {
callbacks: {
label: function(context) {
var label = context.dataset.label || ";
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
label += '$' + context.parsed.y.toFixed(2);
}
return label;
}
}
}
},
scales: {
y: {
beginAtZero: true,
ticks: {
callback: function(value) {
return '$' + value.toFixed(2);
}
}
}
}
}
});
document.querySelector('.chart-container:nth-of-type(3) .chart-legend').innerHTML = `
Regular Pay: $${regPay.toFixed(2)}Standard OT Pay: $${(stdOTHours * stdOTRate).toFixed(2)}Double Time Pay: $${(doubleOTHours * doubleTRate).toFixed(2)}