File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
lib/matplotlib/backends/web_backend Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!-- Within the kernel, we don't know the address of the matplotlib
2
+ websocket server, so we have to get in client-side and fetch our
3
+ resources that way. -->
4
+ < script >
5
+ // We can't proceed until these Javascript files are fetched, so
6
+ // we fetch them synchronously
7
+ $ . ajaxSetup ( { async : false } ) ;
8
+ $ . getScript ( "http://" + window . location . hostname + ":{{ port }}{{prefix}}/_static/mpl.js" ) ;
9
+ $ . getScript ( "http://" + window . location . hostname + ":{{ port }}{{prefix}}/mpl_interface.js" ) ;
10
+ $ . ajaxSetup ( { async : true } ) ;
11
+
12
+ function init_figure { { fig_id } } ( e ) {
13
+ $ ( 'div.output' ) . off ( 'resize' ) ;
14
+
15
+ var output_div = $ ( e . target ) . find ( 'div.output_subarea' ) ;
16
+
17
+ var fig = new figure (
18
+ { { repr ( str ( fig_id ) ) } } ,
19
+ "ws://" + window . location . hostname + ":{{ port }}{{ prefix}}/" ,
20
+ output_div ) ;
21
+
22
+ // Fetch the first image
23
+ fig . context . drawImage ( fig . imageObj , 0 , 0 ) ;
24
+
25
+ fig . focus_on_mouseover = true ;
26
+ }
27
+
28
+ // We can't initialize the figure contents until our content
29
+ // has been added to the DOM. This is a bit of hack to get an
30
+ // event for that.
31
+ $ ( 'div.output' ) . resize ( init_figure { { fig_id } } ) ;
32
+ </ script >
You can’t perform that action at this time.
0 commit comments