changed colors

This commit is contained in:
Ben Varick 2023-11-21 11:24:27 -06:00
parent 22d6a2b7ed
commit 1a44fc8ee4
Signed by: ben
SSH Key Fingerprint: SHA256:jWnpFDAcacYM5aPFpYRqlsamlDyKNpSj3jj+k4ojtUo

View File

@ -23,6 +23,8 @@ power_threshhold <- 10
# ---- set variables # ---- set variables
entities <- data.frame(name = c("washing machine", "dryer"), entity_id = c("washing_machine_power", "dryer_power")) entities <- data.frame(name = c("washing machine", "dryer"), entity_id = c("washing_machine_power", "dryer_power"))
colors <- data.frame(value = c("off", "on"), color = c("#bcbcbc", "#b45f06"))
# Define a function to calculate the time difference # Define a function to calculate the time difference
calculateTimeAgo <- function(eventTime) { calculateTimeAgo <- function(eventTime) {
current <- Sys.time() # Get the current time current <- Sys.time() # Get the current time
@ -85,6 +87,7 @@ update_data <- function(){
fill = status)) + fill = status)) +
scale_y_discrete(breaks = entities$entity_id, labels = entities$name) + scale_y_discrete(breaks = entities$entity_id, labels = entities$name) +
scale_x_datetime(breaks = seq(round_date(max(values$end_time), "4 hours") - hours(24), round_date(max(values$end_time), "4 hours"), by = "4 hours"), date_labels = '%I:%M %p', date_minor_breaks = "1 hours") + scale_x_datetime(breaks = seq(round_date(max(values$end_time), "4 hours") - hours(24), round_date(max(values$end_time), "4 hours"), by = "4 hours"), date_labels = '%I:%M %p', date_minor_breaks = "1 hours") +
scale_fill_manual(values = colors$color) +
theme(axis.text.x = element_text(angle = 30, vjust = 0.5)) + theme(axis.text.x = element_text(angle = 30, vjust = 0.5)) +
labs(title = "Last 24 hours", labs(title = "Last 24 hours",
x = NULL, x = NULL,
@ -99,6 +102,7 @@ update_data <- function(){
fill = status)) + fill = status)) +
scale_y_discrete(breaks = entities$entity_id, labels = entities$name) + scale_y_discrete(breaks = entities$entity_id, labels = entities$name) +
scale_x_datetime(date_breaks = "1 day", date_labels = '%A', date_minor_breaks = "4 hours") + scale_x_datetime(date_breaks = "1 day", date_labels = '%A', date_minor_breaks = "4 hours") +
scale_fill_manual(values = colors$color) +
theme(axis.text.x = element_text(angle = 30, vjust = 0.5)) + theme(axis.text.x = element_text(angle = 30, vjust = 0.5)) +
labs(title = "The past week", labs(title = "The past week",
x = NULL, x = NULL,
@ -118,6 +122,7 @@ update_data <- function(){
facet_grid(name ~ .) + facet_grid(name ~ .) +
scale_y_datetime(date_breaks = "4 hours", date_labels = '%I:%M %p', minor_breaks = "2 hours", expand = expansion(mult = 0)) + scale_y_datetime(date_breaks = "4 hours", date_labels = '%I:%M %p', minor_breaks = "2 hours", expand = expansion(mult = 0)) +
scale_x_datetime(date_breaks = "1 day", date_labels = '%A', minor_breaks = NULL) + scale_x_datetime(date_breaks = "1 day", date_labels = '%A', minor_breaks = NULL) +
scale_fill_manual(values = colors$color) +
theme(axis.text.x = element_text(angle = 30, vjust = 0.5)) + theme(axis.text.x = element_text(angle = 30, vjust = 0.5)) +
labs(title = "The past week", labs(title = "The past week",
x = "Day", x = "Day",