|
33 | 33 | 'ErrorZ': {'object_name': 'error_z', 'base_type': dict},
|
34 | 34 | 'Figure': {'object_name': 'figure', 'base_type': dict},
|
35 | 35 | 'Font': {'object_name': 'font', 'base_type': dict},
|
36 |
| - 'Frames': {'object_name': 'frames', 'base_type': dict}, |
| 36 | + 'Frames': {'object_name': 'frames', 'base_type': list}, |
37 | 37 | 'Heatmap': {'object_name': 'heatmap', 'base_type': dict},
|
38 | 38 | 'Histogram': {'object_name': 'histogram', 'base_type': dict},
|
39 | 39 | 'Histogram2d': {'object_name': 'histogram2d', 'base_type': dict},
|
@@ -136,6 +136,27 @@ def get_attributes_dicts(object_name, parent_object_names=()):
|
136 | 136 | # We should also one or more paths where attributes are defined.
|
137 | 137 | attribute_paths = list(object_dict['attribute_paths']) # shallow copy
|
138 | 138 |
|
| 139 | + # Map frame 'data' and 'layout' to previously-defined figure attributes. |
| 140 | + # Examples of parent_object_names changes: |
| 141 | + # ['figure', 'frames'] --> ['figure', 'frames'] |
| 142 | + # ['figure', 'frames', FRAME_NAME] --> ['figure'] |
| 143 | + # ['figure', 'frames', FRAME_NAME, 'data'] --> ['figure', 'data'] |
| 144 | + # ['figure', 'frames', FRAME_NAME, 'layout'] --> ['figure', 'layout'] |
| 145 | + # ['figure', 'frames', FRAME_NAME, 'foo'] --> |
| 146 | + # ['figure', 'frames', FRAME_NAME, 'foo'] |
| 147 | + # [FRAME_NAME, 'layout'] --> ['figure', 'layout'] |
| 148 | + if FRAME_NAME in parent_object_names: |
| 149 | + len_parent_object_names = len(parent_object_names) |
| 150 | + index = parent_object_names.index(FRAME_NAME) |
| 151 | + if len_parent_object_names == index + 1: |
| 152 | + if object_name in ('data', 'layout'): |
| 153 | + parent_object_names = ['figure', object_name] |
| 154 | + elif len_parent_object_names > index + 1: |
| 155 | + if parent_object_names[index + 1] in ('data', 'layout'): |
| 156 | + parent_object_names = ( |
| 157 | + ['figure'] + list(parent_object_names)[index + 1:] |
| 158 | + ) |
| 159 | + |
139 | 160 | # If we have parent_names, some of these attribute paths may be invalid.
|
140 | 161 | for parent_object_name in reversed(parent_object_names):
|
141 | 162 | if parent_object_name in ARRAYS:
|
@@ -410,8 +431,11 @@ def _patch_objects():
|
410 | 431 | 'attribute_paths': layout_attribute_paths,
|
411 | 432 | 'additional_attributes': {}}
|
412 | 433 |
|
413 |
| - figure_attributes = {'layout': {'role': 'object'}, |
414 |
| - 'data': {'role': 'object', '_isLinkedToArray': True}} |
| 434 | + figure_attributes = { |
| 435 | + 'layout': {'role': 'object'}, |
| 436 | + 'data': {'role': 'object', '_isLinkedToArray': True}, |
| 437 | + 'frames': {'role': 'object', '_isLinkedToArray': True} |
| 438 | + } |
415 | 439 | OBJECTS['figure'] = {'meta_paths': [],
|
416 | 440 | 'attribute_paths': [],
|
417 | 441 | 'additional_attributes': figure_attributes}
|
@@ -479,6 +503,8 @@ def _get_classes():
|
479 | 503 | # The ordering here is important.
|
480 | 504 | GRAPH_REFERENCE = get_graph_reference()
|
481 | 505 |
|
| 506 | +FRAME_NAME = list(GRAPH_REFERENCE['frames']['items'].keys())[0] |
| 507 | + |
482 | 508 | # See http://blog.labix.org/2008/06/27/watch-out-for-listdictkeys-in-python-3
|
483 | 509 | TRACE_NAMES = list(GRAPH_REFERENCE['traces'].keys())
|
484 | 510 |
|
|
0 commit comments