* The perform_render method is called by processLuminoMessage * after the widget's DOM element has been attached to the notebook * output cell. This happens after the initialize of the * FigureModel, and it won't happen at all if the Python FigureWidget * is never displayed in a notebook
()
| 834 | * is never displayed in a notebook output cell |
| 835 | */ |
| 836 | perform_render() { |
| 837 | var that = this; |
| 838 | |
| 839 | // Wire up message property callbacks |
| 840 | // ---------------------------------- |
| 841 | // Python -> JS event properties |
| 842 | this.model.on("change:_py2js_addTraces", () => this.do_addTraces()); |
| 843 | this.model.on("change:_py2js_deleteTraces", () => this.do_deleteTraces()); |
| 844 | this.model.on("change:_py2js_moveTraces", () => this.do_moveTraces()); |
| 845 | this.model.on("change:_py2js_restyle", () => this.do_restyle()); |
| 846 | this.model.on("change:_py2js_relayout", () => this.do_relayout()); |
| 847 | this.model.on("change:_py2js_update", () => this.do_update()); |
| 848 | this.model.on("change:_py2js_animate", () => this.do_animate()); |
| 849 | |
| 850 | // MathJax v2 configuration |
| 851 | // --------------------- |
| 852 | (window as any)?.MathJax?.Hub?.Config?.({ SVG: { font: "STIX-Web" } }); |
| 853 | |
| 854 | // Get message ids |
| 855 | // --------------------- |
| 856 | var layout_edit_id = this.model.get("_last_layout_edit_id"); |
| 857 | var trace_edit_id = this.model.get("_last_trace_edit_id"); |
| 858 | |
| 859 | // Set view UID |
| 860 | // ------------ |
| 861 | this.viewID = randstr(); |
| 862 | |
| 863 | // Initialize Plotly.js figure |
| 864 | // --------------------------- |
| 865 | // We must clone the model's data and layout properties so that |
| 866 | // the model is not directly mutated by the Plotly.js library. |
| 867 | var initialTraces = _.cloneDeep(this.model.get("_widget_data")); |
| 868 | var initialLayout = _.cloneDeep(this.model.get("_widget_layout")); |
| 869 | if (!initialLayout.height) { |
| 870 | initialLayout.height = 360; |
| 871 | } |
| 872 | var config = this.model.get("_config"); |
| 873 | config.editSelection = false; |
| 874 | |
| 875 | Plotly.newPlot(that.el, initialTraces, initialLayout, config).then( |
| 876 | function () { |
| 877 | // ### Send trace deltas ### |
| 878 | // We create an array of deltas corresponding to the new |
| 879 | // traces. |
| 880 | that._sendTraceDeltas(trace_edit_id); |
| 881 | |
| 882 | // ### Send layout delta ### |
| 883 | that._sendLayoutDelta(layout_edit_id); |
| 884 | |
| 885 | // Wire up plotly event callbacks |
| 886 | (<Plotly.PlotlyHTMLElement>that.el).on("plotly_restyle", function (update: any) { |
| 887 | that.handle_plotly_restyle(update); |
| 888 | }); |
| 889 | (<Plotly.PlotlyHTMLElement>that.el).on("plotly_relayout", function (update: any) { |
| 890 | that.handle_plotly_relayout(update); |
| 891 | }); |
| 892 | (<Plotly.PlotlyHTMLElement>that.el).on("plotly_update", function (update: any) { |
| 893 | that.handle_plotly_update(update); |
no test coverage detected