Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
riteshahlawat committed Apr 26, 2020
1 parent dae86cd commit 46334a4
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var legendIndicator = document.getElementById("legend-indicator");
var results = document.getElementById("results");
var boundingImage = document.getElementById("result-bounding-image");
var streetImage = document.getElementById("result-street-image");
var costYearlySavingsChart;

var costYearlySavings = document.getElementById('chart-cost-yearly-vs-savings-yearly').getContext('2d');

Expand Down Expand Up @@ -74,24 +75,32 @@ function yesClick() {
document.getElementById("savings").innerHTML = `${Math.trunc(yearlySavingsAfterSP*25)}`;
document.getElementById("consumption").innerHTML = `${Math.trunc(kWh)}`;

var costYearlySavingsChart = new Chart(costYearlySavings, {
type: 'doughnut',
data: {
labels: ["Yearly Energy Cost (CAD)", "Yearly Energy Savings (CAD)"],
datasets: [{
label: "Yearly Energy Costs Vs Savings",
data: [Math.trunc(yearlyCosts), Math.trunc(yearlySavingsAfterSP)],
backgroundColor: [
'rgba(39,117,242, 0.75)',
'rgba(242,215,39, 0.75)'
],
borderWidth: 1
}]
},
options: {

}
})
if (costYearlySavingsChart == null) {
costYearlySavingsChart = new Chart(costYearlySavings, {
type: 'doughnut',
data: {
labels: ["Yearly Energy Cost (CAD)", "Yearly Energy Savings (CAD)"],
datasets: [{
label: "Yearly Energy Costs Vs Savings",
data: [Math.trunc(yearlyCosts), Math.trunc(yearlySavingsAfterSP)],
backgroundColor: [
'rgba(39,117,242, 0.75)',
'rgba(242,215,39, 0.75)'
],
borderWidth: 1
}]
},
options: {

}
});
} else {
costYearlySavingsChart.data.datasets.forEach((dataset, i) => {
dataset.data = [Math.trunc(yearlyCosts), Math.trunc(yearlySavingsAfterSP)];
});
costYearlySavingsChart.update();
}


infoWindow.close();
boundingImage.style.display = "inline";
Expand Down

0 comments on commit 46334a4

Please sign in to comment.