Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Constrain the rectangle shape

I’m making an annotation tool for time series data. When a user click on the plot, a rectangular shape will be created.

How could the rectangle shapes be constrained that y0=0 and y1=1? And also, what would be the best way to add text at the middle of the rectangle?

You can try listening to relayout as in

add an arrow-less (showarrow: false) annotation.