Skip to content

Commit

Permalink
Merge pull request #120 from savitakartik/log_edges_104
Browse files Browse the repository at this point in the history
added option to log time axis in pages/edges
  • Loading branch information
jeromekelleher authored Jan 28, 2024
2 parents eb23f19 + 795aa3a commit bbae5d1
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions tsqc/pages/edges.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
import bokeh.models as bkm
import holoviews as hv
import holoviews.operation.datashader as hd
import numpy as np
import panel as pn

from .. import config
from ..plot_helpers import filter_points
from ..plot_helpers import hover_points


def page(tsm):
hv.extension("bokeh")
def make_edges_panel(log_y, tsm):
edges_df = tsm.edges_df
edges_df["parent_time_right"] = edges_df["parent_time"]
lines = hv.Segments(
edges_df, kdims=["left", "parent_time", "right", "parent_time_right"]
)
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"
else:
edges_df["parent_time_right"] = edges_df["parent_time"]
y_dim_left = "parent_time"
y_dim_right = "parent_time_right"

lines = hv.Segments(edges_df, kdims=["left", y_dim_left, "right", y_dim_right])
range_stream = hv.streams.RangeXY(source=lines)
streams = [range_stream]
filtered = lines.apply(filter_points, streams=streams)
Expand All @@ -34,8 +41,19 @@ def page(tsm):
width=config.PLOT_WIDTH,
height=config.PLOT_HEIGHT,
xlabel="Position",
ylabel="Time",
ylabel="Time (parent node)",
)
)

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,
)
edges_panel = pn.bind(make_edges_panel, log_y=log_y_checkbox, tsm=tsm)
return pn.Column(plot_options, edges_panel)

0 comments on commit bbae5d1

Please sign in to comment.