Convert figure to a dictionary Note: the dictionary includes the properties explicitly set by the user, it does not include default values of unspecified properties Returns ------- dict
(self)
| 3291 | # Exports |
| 3292 | # ------- |
| 3293 | def to_dict(self): |
| 3294 | """ |
| 3295 | Convert figure to a dictionary |
| 3296 | |
| 3297 | Note: the dictionary includes the properties explicitly set by the |
| 3298 | user, it does not include default values of unspecified properties |
| 3299 | |
| 3300 | Returns |
| 3301 | ------- |
| 3302 | dict |
| 3303 | """ |
| 3304 | # Handle data |
| 3305 | # ----------- |
| 3306 | data = deepcopy(self._data) |
| 3307 | |
| 3308 | # Handle layout |
| 3309 | # ------------- |
| 3310 | layout = deepcopy(self._layout) |
| 3311 | |
| 3312 | # Handle frames |
| 3313 | # ------------- |
| 3314 | # Frame key is only added if there are any frames |
| 3315 | res = {"data": data, "layout": layout} |
| 3316 | frames = deepcopy([frame._props for frame in self._frame_objs]) |
| 3317 | |
| 3318 | if frames: |
| 3319 | res["frames"] = frames |
| 3320 | |
| 3321 | # Add base64 conversion before sending to the front-end |
| 3322 | convert_to_base64(res) |
| 3323 | |
| 3324 | return res |
| 3325 | |
| 3326 | def to_plotly_json(self): |
| 3327 | """ |