Unit 11.02: Filters, and the state the reader is now in
A filter means two readers can be looking at different charts and neither knows it.
The default state is what almost everyone sees
A two-series chart with filter buttons, and what the default shows.
The code reports the filters and the default.
import plotly.graph_objects as go
fig = go.Figure()
for region in ("North", "South"):
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[100, 108, 115], name=region))
fig.update_layout(updatemenus=[{
"buttons": [
{"label": "All regions", "method": "update",
"args": [{"visible": [True, True]}]},
{"label": "North only", "method": "update",
"args": [{"visible": [True, False]}]},
]}])
buttons = fig.layout.updatemenus[0].buttons
print(f"traces : {len(fig.data)}")
print(f"filters : {[b.label for b in buttons]}")
print(f"default : {buttons[0].label} <- what a first-time reader sees")
print("""
Two readers looking at the same dashboard can now be looking at different
charts, and neither knows it. Two consequences.
The default state must be the one that carries the main finding. And the
chart title should reflect the filter, or a screenshot taken from a filtered
view is unlabelled and will circulate as the whole picture.
""")
Most readers never touch a control, so the default state is the chart for practical purposes. It has to be the one carrying the main finding.
The second consequence is screenshots. A filtered view screenshotted and pasted into an email carries no indication of the filter, and will circulate as though it were the whole picture - so the title should reflect the current filter.
The mistake this prevents
The mistake is setting the default to "all" because it seems neutral. Neutral is not a property a default can have - it is the view most people will see, so it should be the view you would have chosen for a static chart.
Takeaway
Set the default to the view carrying your finding, and put the filter state in the title. Screenshots travel without their controls.
