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

[MISC] Add checkbox #8

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
36 changes: 34 additions & 2 deletions scripts/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from bokeh.layouts import column, row
from bokeh.models import (
AdaptiveTicker,
CheckboxGroup,
ColumnDataSource,
CustomJS,
CustomJSTickFormatter,
Div,
Expand Down Expand Up @@ -133,8 +135,12 @@ def create_plot(interactive=False):
toolbar_location="left",
tools="",
)

source = ColumnDataSource(time_data)
original = ColumnDataSource(time_data)

renderers1 = p1.hbar_stack(
stackers=time_structure[1:], y=time_structure[0], height=0.4, source=(time_data), color=Set2_6
stackers=time_structure[1:], y=time_structure[0], height=0.4, source=source, color=Set2_6
)
legend_items = []
for r in renderers1:
Expand Down Expand Up @@ -198,6 +204,32 @@ def create_plot(interactive=False):
)
p1.js_on_event(events.DoubleTap, toggle_legend_js)

chkbxgrp = CheckboxGroup(labels=time_structure[1:], active=list(range(len(time_structure[1:]))))
callback = CustomJS(
args={"source": source, "original": original},
code="""
var active_values = cb_obj.active.map(x => cb_obj.labels[x]);
var number_of_entries = cb_obj.labels.length;

for (var i = 0; i < number_of_entries; i++)
{
var value = cb_obj.labels[i];
if (active_values.indexOf(value) >= 0)
{
source.data[value] = original.data[value];
}
else
{
delete source.data[value];
}
}

source.change.emit();
console.log("callback completed");
""",
)
chkbxgrp.js_on_change("active", callback)

p2 = figure(
y_range=convert_list_to_string(size_data[size_structure[0]]),
x_range=(0, max_result_size),
Expand Down Expand Up @@ -250,7 +282,7 @@ def create_plot(interactive=False):
p2.yaxis.minor_tick_line_color = None
p2.yaxis.major_label_standoff = 15
p2.sizing_mode = "scale_both"
both_plots = row(p1, p2)
both_plots = row(chkbxgrp, p1, p2)
both_plots.sizing_mode = "scale_both"
vercel_logo = """
<svg width="209" height="40" viewBox="0 0 209 40" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down