From fca2477e606fc14680e1540716fd9de8f6a8427a Mon Sep 17 00:00:00 2001 From: Pingu Carsti <ehbrecht@dkrz.de> Date: Fri, 2 Aug 2024 15:44:40 +0200 Subject: [PATCH] updated day plot --- rook/dashboard/plots/day.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/rook/dashboard/plots/day.py b/rook/dashboard/plots/day.py index 67684813..5894a88a 100644 --- a/rook/dashboard/plots/day.py +++ b/rook/dashboard/plots/day.py @@ -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", @@ -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