Add the interaction for the specified type. If a figure is passed using the key-word argument `figure` it is used. Else the context figure is used. If a list of marks are passed using the key-word argument `marks` it is used. Else the latest mark that is passed is used as the only m
(int_type, **kwargs)
| 1043 | |
| 1044 | |
| 1045 | def _add_interaction(int_type, **kwargs): |
| 1046 | """Add the interaction for the specified type. |
| 1047 | |
| 1048 | If a figure is passed using the key-word argument `figure` it is used. Else |
| 1049 | the context figure is used. |
| 1050 | If a list of marks are passed using the key-word argument `marks` it |
| 1051 | is used. Else the latest mark that is passed is used as the only mark |
| 1052 | associated with the selector. |
| 1053 | |
| 1054 | Parameters |
| 1055 | ---------- |
| 1056 | int_type: type |
| 1057 | The type of interaction to be added. |
| 1058 | """ |
| 1059 | |
| 1060 | fig = kwargs.pop('figure', current_figure()) |
| 1061 | marks = kwargs.pop('marks', [_context['last_mark']]) |
| 1062 | |
| 1063 | for name, traitlet in int_type.class_traits().items(): |
| 1064 | dimension = traitlet.get_metadata('dimension') |
| 1065 | if dimension is not None: |
| 1066 | # only scales have this attribute in interactions |
| 1067 | kwargs[name] = _get_context_scale(dimension) |
| 1068 | kwargs['marks'] = marks |
| 1069 | interaction = int_type(**kwargs) |
| 1070 | if fig.interaction is not None: |
| 1071 | fig.interaction.close() |
| 1072 | fig.interaction = interaction |
| 1073 | return interaction |
| 1074 | |
| 1075 | |
| 1076 | def _get_context_scale(dimension): |
no test coverage detected
searching dependent graphs…