Products sold by the time of day
The bakery would like a view of how many products are sold at different times of the day.
A figure, fig, has been set up and preloaded, including a HoverTool to display the time of day, item name, and the number of items sold.
You will need to modify add a title to the legend so stakeholders understand its meaning, move the legend to avoid obstructing the view of observations and change the legend to hide observations upon clicking.
Deze oefening maakt deel uit van de cursus
Interactive Data Visualization with Bokeh
Oefeninstructies
- Add a title to the legend called
"Time of Day". - Move the legend to the top left corner.
- Make the legend interactive, hiding observations by their legend label upon click.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
fig = figure(x_axis_label="Count of Products Sold", y_axis_label="Sales", title="Bakery Product Sales", tooltips=TOOLTIPS)
fig.circle(x="count", y="sales", source=morning, line_color="red", size=12, fill_alpha=0.4, legend_label="Morning")
fig.circle(x="count", y="sales", source=afternoon, fill_color="purple", size=10, fill_alpha=0.6, legend_label="Afternoon")
fig.circle(x="count", y="sales", source=evening, fill_color="yellow", size=8, fill_alpha=0.6, legend_label="Evening")
# Add legend title
fig.____.____ = "____"
# Move the legend
fig.____.____ = "____"
# Make the legend interactive
fig.____.____ = "____"
fig.yaxis[0].formatter = NumeralTickFormatter(format="$0.00")
output_file("Sales_by_time_of_day")
show(fig)