title_button_mode = PreText(text="Choose display mode ",
                            style={
                                'font-size': '12pt',
                                'color': 'black',
                                'font-family': 'sans-serif'
                            })

# Slider for the date
date_slider = Slider(title="Date " + hospital_dates_str[0],
                     start=0,
                     end=len(hospital_dates_str) - 1,
                     value=0,
                     step=1,
                     show_value=False)
date_slider.on_change('value', slider_update)
date_slider.visible = False  # Initially the slider is not visible

# Button to animate the slider
button_animation = Button(label='► Play', width=60)
button_animation.on_click(animate)
button_animation.visible = False  # Initially the slider is not visible

# Set up layouts and add to document
inputs = widgetbox(title_button_choice, button_choice, title_button_mode,
                   button_mode, date_slider, button_animation)
layout = row(p, inputs)

# Handle rendering in HTML
curdoc().add_root(layout)
curdoc().title = title
Пример #2
0
# Choose the policie.
LABELS_POLICIES = [
    "Without prepending", "With prepending", "Uniform policy", "Binary policy",
    "Diverse policy", "Mixed policy"
]
policies_radio_button = RadioButtonGroup(labels=LABELS_POLICIES, active=0)
policies_radio_button.on_change(
    "active", OnChangePoliciesRadioButton)  # Change the selected policy.
policies_radio_button.visible = False  # This option will be only shown if the selected type of plot be the number per policy or the percentage per policy.

# Button to create the plot.
update_plot_button = Button(label="Update Plot", button_type="success")
update_plot_button.on_click(
    OnClickUpdatePlotButton)  # Call the function that will generate the plot.

# Initizalizes the plot.
# It is not really necessary to initizalize the plot, but to make the function OnClickUpdatePlotButton() more generic, it will help.
# A button it's initialized as the plot, because if a empty plot is initialize, for some reason the "doc.remove_root(p)" on OnClickUpdatePlotButton() does not remove the plot.
# To make up for it, the button is not visible.
# A empty variable (p = None) can not be passed, because will generate an error when added to the doc.
p = Button(label="Update Plot", button_type="success")
p.visible = False

# Add all the above objects to the document in a column (it will make them stay in the same "level").
# You will see that the list of Dropdowns will be behind the plot, because new plots will be generated "above" this objects. (This need to be fixed).
doc.add_root(
    column(ipv4_ipv6_radio_button,
           row(year_dropdown, month_dropdown,
               day_dropdown), plot_type_radio_button, policies_radio_button,
           update_plot_button, p))