Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to plot child or parent time in pages/edges #121

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions tsqc/pages/edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@
from ..plot_helpers import hover_points


def make_edges_panel(log_y, tsm):
def make_edges_panel(log_y, node_type, tsm):
edges_df = tsm.edges_df
if node_type == "Child node":
time_column = "child_time"
y_label = "time of child node"
else:
time_column = "parent_time"
y_label = "time of parent node"

if log_y:
edges_df["log_parent_time"] = np.log10(1 + edges_df["parent_time"])
edges_df["log_parent_time_right"] = edges_df["log_parent_time"]
y_dim_left = "log_parent_time"
y_dim_right = "log_parent_time_right"
log_time_column = f"log_{time_column}"
edges_df[log_time_column] = np.log10(1 + edges_df[time_column])
y_dim_left = log_time_column
y_dim_right = log_time_column + "_right"
y_label = f"log ( {y_label} )"
else:
edges_df["parent_time_right"] = edges_df["parent_time"]
y_dim_left = "parent_time"
y_dim_right = "parent_time_right"
y_dim_left = time_column
y_dim_right = time_column + "_right"
y_label = y_label

edges_df[y_dim_right] = edges_df[y_dim_left]

lines = hv.Segments(edges_df, kdims=["left", y_dim_left, "right", y_dim_right])
range_stream = hv.streams.RangeXY(source=lines)
Expand All @@ -41,19 +51,25 @@ def make_edges_panel(log_y, tsm):
width=config.PLOT_WIDTH,
height=config.PLOT_HEIGHT,
xlabel="Position",
ylabel="Time (parent node)",
ylabel=y_label,
)
)
return pn.Column(main)


def page(tsm):
hv.extension("bokeh")

log_y_checkbox = pn.widgets.Checkbox(name="Log y-axis", value=False)
plot_options = pn.Column(
pn.pane.Markdown("### Plot Options"),
log_y_checkbox,
node_type_radio = pn.widgets.RadioBoxGroup(
options=["Parent node", "Child node"], value="Parent node", inline=True
)
# using a markdown widget to display radiobox title
# (https://github.com/holoviz/panel/issues/1313):
radio_title = pn.pane.Markdown("Plot time of:")
options_box = pn.WidgetBox(
"### Plot options", log_y_checkbox, radio_title, node_type_radio
)
edges_panel = pn.bind(
make_edges_panel, log_y=log_y_checkbox, node_type=node_type_radio, tsm=tsm
)
edges_panel = pn.bind(make_edges_panel, log_y=log_y_checkbox, tsm=tsm)
return pn.Column(plot_options, edges_panel)
return pn.Column(options_box, edges_panel)
Loading