Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Possible to implement an alarm?

Is it possible to implement an alarm if a attribute exceeds a certain value?

Here’s an approach that works in version 3

import plotly.graph_objs as go

fig = go.Figure(data=[go.Scatter(y=[2, 1, 4], marker={'size': 20})])
scatt =[0]

def alarm(scatt, size):
    if (size > 30):
        raise ValueError('size is > 30')
scatt.on_change(alarm, 'marker.size')
scatt.marker.size = 30  # No error
scatt.marker.size = 31  # Error

Note: the on_change functions are only called if the trace belongs to a Figure.

Hope that helps!