(model: MarkModel)
| 831 | } |
| 832 | |
| 833 | async add_mark(model: MarkModel) { |
| 834 | model.state_change.then(() => { |
| 835 | model.on('data_updated redraw_legend', this.update_legend, this); |
| 836 | }); |
| 837 | |
| 838 | const dummy_node = this.fig_marks |
| 839 | .node() |
| 840 | .appendChild(document.createElementNS(d3.namespaces.svg, 'g')); |
| 841 | |
| 842 | // @ts-ignore: We should use the type argument: this.create_child_view<Mark> |
| 843 | const view: Mark = await this.create_child_view(model, { |
| 844 | clip_id: this.clip_id, |
| 845 | }); |
| 846 | |
| 847 | this.dummyNodes[view.cid] = dummy_node; |
| 848 | |
| 849 | view.on( |
| 850 | 'mark_padding_updated', |
| 851 | () => { |
| 852 | this.mark_padding_updated(view); |
| 853 | }, |
| 854 | this |
| 855 | ); |
| 856 | view.on( |
| 857 | 'mark_scales_updated', |
| 858 | () => { |
| 859 | this.mark_scales_updated(view); |
| 860 | }, |
| 861 | this |
| 862 | ); |
| 863 | |
| 864 | let child_x_scale = |
| 865 | view.model.getScales()[view.model.get_key_for_dimension('x')]; |
| 866 | let child_y_scale = |
| 867 | view.model.getScales()[view.model.get_key_for_dimension('y')]; |
| 868 | if (child_x_scale === undefined) { |
| 869 | child_x_scale = this.scale_x.model; |
| 870 | } |
| 871 | if (child_y_scale === undefined) { |
| 872 | child_y_scale = this.scale_y.model; |
| 873 | } |
| 874 | this.update_padding_dict( |
| 875 | this.x_pad_dict, |
| 876 | view, |
| 877 | child_x_scale, |
| 878 | view.xPadding |
| 879 | ); |
| 880 | this.update_padding_dict( |
| 881 | this.y_pad_dict, |
| 882 | view, |
| 883 | child_y_scale, |
| 884 | view.yPadding |
| 885 | ); |
| 886 | |
| 887 | // If the marks list changes before replace_dummy_nodes is called, we are not DOM |
| 888 | // attached, and view.remove() in Figure.remove_mark will not remove this view from the DOM |
| 889 | // but a later call to Figure.replace_dummy_nodes will attach it to the DOM again, leading |
| 890 | // to a 'ghost' mark, originally reported in https://github.com/spacetelescope/jdaviz/issues/270 |
nothing calls this directly
no test coverage detected