(args, constructor, fig)
| 850 | |
| 851 | |
| 852 | def configure_animation_controls(args, constructor, fig): |
| 853 | def frame_args(duration): |
| 854 | return { |
| 855 | "frame": {"duration": duration, "redraw": constructor != go.Scatter}, |
| 856 | "mode": "immediate", |
| 857 | "fromcurrent": True, |
| 858 | "transition": {"duration": duration, "easing": "linear"}, |
| 859 | } |
| 860 | |
| 861 | if "animation_frame" in args and args["animation_frame"] and len(fig.frames) > 1: |
| 862 | fig.layout.updatemenus = [ |
| 863 | { |
| 864 | "buttons": [ |
| 865 | { |
| 866 | "args": [None, frame_args(500)], |
| 867 | "label": "▶", |
| 868 | "method": "animate", |
| 869 | }, |
| 870 | { |
| 871 | "args": [[None], frame_args(0)], |
| 872 | "label": "◼", |
| 873 | "method": "animate", |
| 874 | }, |
| 875 | ], |
| 876 | "direction": "left", |
| 877 | "pad": {"r": 10, "t": 70}, |
| 878 | "showactive": False, |
| 879 | "type": "buttons", |
| 880 | "x": 0.1, |
| 881 | "xanchor": "right", |
| 882 | "y": 0, |
| 883 | "yanchor": "top", |
| 884 | } |
| 885 | ] |
| 886 | fig.layout.sliders = [ |
| 887 | { |
| 888 | "active": 0, |
| 889 | "yanchor": "top", |
| 890 | "xanchor": "left", |
| 891 | "currentvalue": { |
| 892 | "prefix": get_label(args, args["animation_frame"]) + "=" |
| 893 | }, |
| 894 | "pad": {"b": 10, "t": 60}, |
| 895 | "len": 0.9, |
| 896 | "x": 0.1, |
| 897 | "y": 0, |
| 898 | "steps": [ |
| 899 | { |
| 900 | "args": [[f.name], frame_args(0)], |
| 901 | "label": f.name, |
| 902 | "method": "animate", |
| 903 | } |
| 904 | for f in fig.frames |
| 905 | ], |
| 906 | } |
| 907 | ] |
| 908 | |
| 909 |
no test coverage detected