示例#1
0
    "Number of total used AS's", "Number of AS's per policy",
    "Percentage of AS's per policy"
]
plot_type_radio_button = RadioButtonGroup(labels=LABELS_PLOT_TYPE, active=0)
plot_type_radio_button.on_change(
    "active", OnChangePlotTypeRadioButton)  # Change the selected type of plot.

# 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").