From d53c7ef715b1f0390435ad22147ae49a64d2e9cb Mon Sep 17 00:00:00 2001 From: Andrew Seier Date: Thu, 20 Oct 2016 11:01:25 -0700 Subject: [PATCH] Patch `Figure` to allow `frames`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need frames for animations, this is a hack since they don’t exist in the graph reference. --- plotly/graph_objs/graph_objs.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plotly/graph_objs/graph_objs.py b/plotly/graph_objs/graph_objs.py index ad13d368e69..c3684ae9028 100644 --- a/plotly/graph_objs/graph_objs.py +++ b/plotly/graph_objs/graph_objs.py @@ -836,6 +836,20 @@ def __init__(self, *args, **kwargs): _parent_key='data') figure_class.__init__ = __init__ + def __setitem__(self, key, value, **kwargs): + if key == 'frames': + super(PlotlyDict, self).__setitem__(key, value) + else: + super(figure_class, self).__setitem__(key, value, **kwargs) + figure_class.__setitem__ = __setitem__ + + def _get_valid_attributes(self): + super(figure_class, self)._get_valid_attributes() + if 'frames' not in self._valid_attributes: + self._valid_attributes.add('frames') + return self._valid_attributes + figure_class._get_valid_attributes = _get_valid_attributes + def get_data(self, flatten=False): """ Returns the JSON for the plot with non-data elements stripped.