- Width set automaticaly by plotly does not work corectly in all
situations.
Change-Id: Ib4a2475f6889e8858d3c3cd9c7886a9725df5d0e
Signed-off-by: Tibor Frank <tifrank@cisco.com>
import plotly.graph_objects as go
import pandas as pd
import plotly.graph_objects as go
import pandas as pd
+from ..utils.constants import Constants as C
-def select_data(data: pd.DataFrame, itm:str) -> pd.DataFrame:
+
+def select_data(data: pd.DataFrame, itm: str) -> pd.DataFrame:
"""Select the data for graphs from the provided data frame.
:param data: Data frame with data for graphs.
"""Select the data for graphs from the provided data frame.
:param data: Data frame with data for graphs.
-def graph_statistics(df: pd.DataFrame, job:str, layout: dict) -> tuple:
+def graph_statistics(df: pd.DataFrame, job: str, layout: dict) -> tuple:
"""Generate graphs:
1. Passed / failed tests,
2. Job durations
"""Generate graphs:
1. Passed / failed tests,
2. Job durations
hover = list()
for _, row in data.iterrows():
hover = list()
for _, row in data.iterrows():
- d_type = "trex" if row["dut_type"] == "none" else row["dut_type"]
hover_itm = (
f"date: {row['start_time'].strftime('%Y-%m-%d %H:%M:%S')}<br>"
f"duration: "
hover_itm = (
f"date: {row['start_time'].strftime('%Y-%m-%d %H:%M:%S')}<br>"
f"duration: "
f"{((int(row['duration']) % 3600) // 60):02d}<br>"
f"passed: {row['passed']}<br>"
f"failed: {row['failed']}<br>"
f"{((int(row['duration']) % 3600) // 60):02d}<br>"
f"passed: {row['passed']}<br>"
f"failed: {row['failed']}<br>"
- f"{d_type}-ref: {row['dut_version']}<br>"
+ f"{row['dut_type']}-ref: {row['dut_version']}<br>"
f"csit-ref: {row['job']}/{row['build']}<br>"
f"hosts: {', '.join(row['hosts'])}"
)
f"csit-ref: {row['job']}/{row['build']}<br>"
f"hosts: {', '.join(row['hosts'])}"
)
data=go.Scatter(
x=data["start_time"],
y=data["duration"],
data=go.Scatter(
x=data["start_time"],
y=data["duration"],
fig_duration.update_layout(layout_duration)
# Passed / failed:
fig_duration.update_layout(layout_duration)
# Passed / failed:
+ bar_width = C.STATS_BAR_WIDTH_WEEKLY \
+ if "weekly" in job else C.STATS_BAR_WIDTH_DAILY
fig_passed = go.Figure(
data=[
go.Bar(
x=data["start_time"],
y=data["passed"],
fig_passed = go.Figure(
data=[
go.Bar(
x=data["start_time"],
y=data["passed"],
+ hoverinfo="text",
+ width=bar_width
),
go.Bar(
x=data["start_time"],
y=data["failed"],
),
go.Bar(
x=data["start_time"],
y=data["failed"],
+ hoverinfo="text",
+ width=bar_width
# Default name of downloaded file with selected data.
STATS_DOWNLOAD_FILE_NAME = "stats.csv"
# Default name of downloaded file with selected data.
STATS_DOWNLOAD_FILE_NAME = "stats.csv"
+ # The width of the bar in the graph in miliseconds.
+ STATS_BAR_WIDTH_DAILY = 1000 * 3600 * 15
+ STATS_BAR_WIDTH_WEEKLY = 1000 * 3600 * 24
+
############################################################################
# Trending.
############################################################################
# Trending.