-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
John Khachian
committed
Nov 1, 2023
1 parent
26d0cfb
commit 2c358bf
Showing
4 changed files
with
122 additions
and
21 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
function renderDonut(before, after){ | ||
var options = { | ||
chart: { | ||
type: "bar", | ||
stacked: true, | ||
height: "500px", | ||
}, | ||
// colors: ["green", "orange", "red"], | ||
series: [ | ||
{ | ||
name: "Profit", | ||
data: [before.profit, after.profit] | ||
}, | ||
{ | ||
name: "Shrinkage", | ||
data: [before.shrinkage, after.shrinkage] | ||
}, | ||
{ | ||
name: "Cost of Goods Sold", | ||
data: [before.cogs, after.cogs] | ||
} | ||
], | ||
plotOptions: { | ||
bar: { | ||
dataLabels: { | ||
total: { | ||
enabled: true, | ||
offsetX: 0, | ||
style: { | ||
fontSize: "13px", | ||
fontWeight: 900 | ||
} | ||
} | ||
} | ||
}, | ||
}, | ||
stroke: { | ||
width: 1, | ||
colors: ["#fff"] | ||
}, | ||
xaxis: { | ||
categories: ["Before", "After"], | ||
}, | ||
legend: { | ||
position: "top", | ||
horizontalAlign: "center", | ||
} | ||
}; | ||
|
||
var chart = new ApexCharts(document.querySelector("#chart"), options); | ||
|
||
chart.render(); | ||
} | ||
|
||
function formatNumber(x) { | ||
let y = parseInt(x); | ||
return y.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | ||
} | ||
|
||
function calculateSavings(){ | ||
const revenue = document.getElementById("revenue-input").value; | ||
let cogs = document.getElementById("cogs-input").value; | ||
const shrinkagePercentage = document.getElementById("shrinkage-input").value/100; | ||
const necessaryCogs = cogs * (1 - (shrinkagePercentage-0.085)); | ||
console.log() | ||
|
||
|
||
|
||
let savings = (cogs-necessaryCogs) * 12; | ||
document.getElementById("savings-output").innerHTML = `$${formatNumber(savings)}`; | ||
document.getElementById("current-cogs").innerHTML = `$${formatNumber(cogs)}`; | ||
document.getElementById("current-profit").innerHTML = `$${formatNumber(revenue - cogs)}`; | ||
document.getElementById("ayoda-cogs").innerHTML = `$${formatNumber(necessaryCogs)}`; | ||
document.getElementById("ayoda-profit").innerHTML = `$${formatNumber(revenue - necessaryCogs)}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters