Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Update tab-statistics.page.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
u18004874 committed Oct 26, 2023
1 parent 8a1e298 commit dc67e35
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app/WhereIsThePower/src/app/tab-statistics/tab-statistics.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,23 @@ export class TabStatisticsPage implements OnInit {

processDoughnutChart(data: any) {
// Get today's day name (e.g., "Mon", "Tue", etc.)

const today = new Date().toLocaleDateString('en-US', { weekday: 'short' });
//const today = "Wed";

//console.log("WEDNESDAY", data.result.perDayTimes["Wed"]);
// Get the on and off values for today's day from the data
const todayOnValue = data.result.perDayTimes[today]?.on || 0;
const todayOffValue = data.result.perDayTimes[today]?.off || 0;
let uptimeToday = 24;
let downtimeToday = 0;
if (data.result.perDayTimes[today] != undefined) {
const todayOnValue = data.result.perDayTimes[today]?.on || 0;
const todayOffValue = data.result.perDayTimes[today]?.off || 0;

// Convert total uptime and downtime to hours
uptimeToday = Math.floor(todayOnValue / 60);
downtimeToday = Math.floor(todayOffValue / 60);
}

// Convert total uptime and downtime to hours
const uptimeToday = Math.floor(todayOnValue / 60);
const downtimeToday = Math.floor(todayOffValue / 60);

// Data for Doughnut Chart (Uptime/Downtime for Today)
const doughnutData = {
Expand Down

0 comments on commit dc67e35

Please sign in to comment.