Absolutely! Below is a single .html file for an animated Return on Investment (ROI) calculator tailored for an "AI Tools Academy" audience (small businesses & individuals). It features:
- Input fields for investment, expected monthly savings, and months.
- Animated calculation of ROI.
- Dynamic chart (using Chart.js) showing cumulative savings vs. investment.
- Modern, clean design (responsive, mobile-friendly).
- No external dependencies except CDN for Chart.js.
To use:
Copy and save as roi-calculator.html, then open in your browser.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AI Tools Academy ROI Calculator</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Chart.js CDN -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body {
font-family: 'Segoe UI', Arial, sans-serif;
background: #f6f8fa;
margin: 0;
padding: 0;
color: #222;
}
.container {
max-width: 480px;
margin: 40px auto;
background: #fff;
border-radius: 16px;
box-shadow: 0 4px 24px rgba(0,0,0,0.07);
padding: 32px 24px 24px 24px;
}
h1 {
text-align: center;
color: #1a73e8;
margin-bottom: 8px;
}
h2 {
text-align: center;
font-size: 1.1em;
color: #555;
margin-bottom: 24px;
font-weight: 400;
}
label {
display: block;
margin-bottom: 6px;
font-weight: 500;
}
input[type="number"] {
width: 100%;
padding: 10px;
margin-bottom: 18px;
border: 1px solid #d0d7de;
border-radius: 6px;
font-size: 1em;
background: #f9fafb;
transition: border 0.2s;
}
input[type="number"]:focus {
border: 1.5px solid #1a73e8;
outline: none;
}
button {
width: 100%;
padding: 12px;
background: #1a73e8;
color: #fff;
border: none;
border-radius: 6px;
font-size: 1.1em;
font-weight: 600;
cursor: pointer;
margin-bottom: 18px;
transition: background 0.2s;
}
button:hover {
background: #1761c7;
}
.result {
text-align: center;
margin-bottom: 18px;
font-size: 1.2em;
min-height: 32px;
}
.roi-value {
font-size: 2em;
color: #1a73e8;
font-weight: bold;
display: inline-block;
margin-top: 6px;
transition: color 0.3s;
}
canvas {
margin: 0 auto;
display: block;
max-width: 100%;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(26,115,232,0.04);
}
@media (max-width: 600px) {
.container {
padding: 18px 6px 12px 6px;
}
h1 {
font-size: 1.3em;
}
}
</style>
</head>
<body>
<div class="container">
<h1>AI Tools Academy ROI Calculator</h1>
<h2>Estimate your Return on Investment from AI tools</h2>
<form id="roiForm" autocomplete="off">
<label for="investment">Initial Investment ($)</label>
<input type="number" id="investment" min="0" step="0.01" value="500" required>
<label for="savings">Expected Monthly Savings ($)</label>
<input type="number" id="savings" min="0" step="0.01" value="150" required>
<label for="months">Months to Calculate</label>
<input type="number" id="months" min="1" max="60" value="12" required>
<button type="submit">Calculate ROI</button>
</form>
<div class="result" id="result">
<span>ROI: </span>
<span class="roi-value" id="roiValue">0%</span>
</div>
<canvas id="roiChart" height="220"></canvas>
</div>
<script>
// Animate number (for ROI)
function animateValue(id, start, end, duration, suffix = "%") {
const obj = document.getElementById(id);
let startTimestamp = null;
const step = (timestamp) => {
if (!startTimestamp) startTimestamp = timestamp;
const progress = Math.min((timestamp - startTimestamp) / duration, 1);
const value = start + (end - start) * progress;
obj.textContent = value.toFixed(1) + suffix;
if (progress < 1) {
window.requestAnimationFrame(step);
}
};
window.requestAnimationFrame(step);
}
// Chart.js setup
let chart;
function renderChart(labels, investmentData, savingsData) {
const ctx = document.getElementById('roiChart').getContext('2d');
if (chart) chart.destroy();
chart = new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [
{
label: 'Cumulative Savings',
data: savingsData,
borderColor: '#1a73e8',
backgroundColor: 'rgba(26,115,232,0.08)',
fill: true,
tension: 0.25,
pointRadius: 2,
borderWidth: 2,
},
{
label: 'Investment',
data: investmentData,
borderColor: '#e8711a',
backgroundColor: 'rgba(232,113,26,0.08)',
fill: false,
borderDash: [6, 6],
pointRadius: 0,
borderWidth: 2,
}
]
},
options: {
responsive: true,
plugins: {
legend: { display: true, position: 'bottom' },
tooltip: { mode: 'index', intersect: false }
},
scales: {
x: { title: { display: true, text: 'Month' } },
y: { title: { display: true, text: 'USD ($)' }, beginAtZero: true }
}
}
});
}
// Main calculation
document.getElementById('roiForm').addEventListener('submit', function(e) {
e.preventDefault();
const investment = parseFloat(document.getElementById('investment').value) || 0;
const savings = parseFloat(document.getElementById('savings').value) || 0;
const months = parseInt(document.getElementById('months').value) || 1;
// ROI = (Total Savings - Investment) / Investment * 100
const totalSavings = savings * months;
const roi = investment === 0 ? 0 : ((totalSavings - investment) / investment) * 100;
// Animate ROI value
animateValue('roiValue', 0, roi, 900);
// Prepare chart data
const labels = [];
const investmentData = [];
const savingsData = [];
for (let i = 1; i <= months; i++) {
labels.push(i.toString());
investmentData.push(investment);
savingsData.push(savings * i);
}
renderChart(labels, investmentData, savingsData);
});
// Initial chart on load
window.addEventListener('DOMContentLoaded', () => {
document.getElementById('roiForm').dispatchEvent(new Event('submit'));
});
</script>
</body>
</html>
Features:
- Animated ROI: The ROI percentage animates smoothly on calculation.
- Interactive Chart: See how cumulative savings stack up against your investment over time.
- Mobile-friendly: Works well on phones and desktops.
- No backend needed: All in one file.
Let me know if you want to customize the formula, add more fields, or tweak the design!