Skip to content

Commit

Permalink
updated day plot
Browse files Browse the repository at this point in the history
  • Loading branch information
cehbrecht committed Aug 2, 2024
1 parent 6f54fba commit fca2477
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions rook/dashboard/plots/day.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,35 @@

from .base import PlotView

# Constant to represent days of the week
DAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]


class DayPlot(PlotView):
def data(self):
pdf = pd.DataFrame()

# Convert the 'time_start' column to day of the week and map it to the DAYS constant
pdf["day"] = self.df["time_start"].dt.dayofweek
pdf["day"] = pdf["day"].apply(lambda x: DAYS[x])

# Create a dictionary with the sorted day names and their corresponding counts
day_counts = pdf["day"].value_counts().sort_index()
data_ = dict(days=day_counts.index, counts=day_counts.values)
return data_

def plot(self):
# Create a Bokeh figure for plotting
plot = figure(
title="Requests per weekday",
tools="",
title="Requests per Weekday",
tools="", # No interactive tools
toolbar_location=None,
x_range=DAYS,
x_range=DAYS, # Set x-axis range to days of the week
sizing_mode="scale_width",
plot_height=100,
)

# Create a vertical bar chart
plot.vbar(
x="days",
top="counts",
Expand All @@ -34,9 +41,11 @@ def plot(self):
color="blue",
alpha=0.5,
)

# Set the y-axis to start from 0
plot.y_range.start = 0
# plot.x_range.range_padding = 0.1
plot.xgrid.grid_line_color = None
plot.axis.minor_tick_line_color = None
plot.outline_line_color = None
plot.xgrid.grid_line_color = None # Remove grid lines on x-axis
plot.axis.minor_tick_line_color = None # Remove minor ticks
plot.outline_line_color = None # Remove the outline around the plot

return plot

0 comments on commit fca2477

Please sign in to comment.