1+ /* global Plotly:false Tabs:false */
2+
13var plotlist = document . getElementById ( 'plot-list' ) ;
24var anchor = document . getElementById ( 'embedded-graph' ) ;
35var image = document . getElementById ( 'embedded-image' ) ;
@@ -11,7 +13,7 @@ anchor.style.width = '1000px';
1113
1214function plotButtons ( plots , figDir ) {
1315
14- Object . keys ( plots ) . forEach ( function ( plotname ) {
16+ Object . keys ( plots ) . forEach ( function ( plotname ) {
1517
1618 var button = document . createElement ( 'button' ) ;
1719
@@ -23,7 +25,7 @@ function plotButtons(plots, figDir) {
2325
2426 plotlist . appendChild ( button ) ;
2527
26- button . addEventListener ( 'click' , function ( ) {
28+ button . addEventListener ( 'click' , function ( ) {
2729
2830 var myImage = new Image ( ) ;
2931 myImage . src = figDir + plotname + '.png' ;
@@ -55,7 +57,7 @@ function plotButtons(plots, figDir) {
5557
5658 plotlist . appendChild ( snapshot ) ;
5759
58- snapshot . addEventListener ( 'click' , function ( ) {
60+ snapshot . addEventListener ( 'click' , function ( ) {
5961
6062 /*
6163 * Grab the currently loaded plot and make an image - replacing the plot.
@@ -67,7 +69,7 @@ function plotButtons(plots, figDir) {
6769
6870 if ( ! layout || ! data ) return ;
6971
70- Plotly . Plots . getSubplotIds ( gd . _fullLayout , 'gl3d' ) . forEach ( function ( key ) {
72+ Plotly . Plots . getSubplotIds ( gd . _fullLayout , 'gl3d' ) . forEach ( function ( key ) {
7173 var scene = gd . _fullLayout [ key ] . _scene ;
7274 scene . destroy ( ) ;
7375 } ) ;
@@ -80,23 +82,23 @@ function plotButtons(plots, figDir) {
8082 /*
8183 * Replot with staticPlot
8284 */
83- Plotly . plot ( gd , data , layout , { staticPlot : true , plotGlPixelRatio : 2 } ) . then ( function ( ) {
84- Plotly . Plots . getSubplotIds ( gd . _fullLayout , 'gl3d' ) . forEach ( function ( key ) {
85- var scene = gd . _fullLayout [ key ] . _scene ;
86- var dataURL = scene . toImage ( ) ;
87-
88- var myImage = new Image ( ) ;
89- myImage . src = dataURL ;
90-
91- myImage . onload = function ( ) {
92- myImage . height = scene . container . clientHeight ;
93- myImage . width = scene . container . clientWidth ;
94- } ;
95-
96- image . innerHTML = '' ;
97- image . appendChild ( myImage ) ;
98- } ) ;
99- } )
85+ Plotly . plot ( gd , data , layout , { staticPlot : true , plotGlPixelRatio : 2 } ) . then ( function ( ) {
86+ Plotly . Plots . getSubplotIds ( gd . _fullLayout , 'gl3d' ) . forEach ( function ( key ) {
87+ var scene = gd . _fullLayout [ key ] . _scene ;
88+ var dataURL = scene . toImage ( ) ;
89+
90+ var myImage = new Image ( ) ;
91+ myImage . src = dataURL ;
92+
93+ myImage . onload = function ( ) {
94+ myImage . height = scene . container . clientHeight ;
95+ myImage . width = scene . container . clientWidth ;
96+ } ;
97+
98+ image . innerHTML = '' ;
99+ image . appendChild ( myImage ) ;
100+ } ) ;
101+ } ) ;
100102 } ) ;
101103
102104 var pummelButton = document . createElement ( 'button' ) ;
@@ -112,17 +114,17 @@ function plotButtons(plots, figDir) {
112114 var mock = require ( '@mocks/gl3d_marker-color.json' ) ;
113115 var statusDiv = document . getElementById ( 'status-info' ) ;
114116
115- pummelButton . addEventListener ( 'click' , function ( ) {
116- setInterval ( function ( ) {
117+ pummelButton . addEventListener ( 'click' , function ( ) {
118+ setInterval ( function ( ) {
117119 var plotDiv = document . createElement ( 'div' ) ;
118120 window . plotDiv = plotDiv ;
119121
120122 plotDiv . id = 'div' + i ;
121123 document . body . appendChild ( plotDiv ) ;
122124
123- Plotly . plot ( plotDiv , mock . data , mock . layout , { staticPlot : true } ) . then ( function ( ) {
125+ Plotly . plot ( plotDiv , mock . data , mock . layout , { staticPlot : true } ) . then ( function ( ) {
124126
125- Plotly . Plots . getSubplotIds ( plotDiv . _fullLayout , 'gl3d' ) . forEach ( function ( key ) {
127+ Plotly . Plots . getSubplotIds ( plotDiv . _fullLayout , 'gl3d' ) . forEach ( function ( key ) {
126128 var scene = plotDiv . _fullLayout [ key ] . _scene ;
127129 scene . destroy ( ) ;
128130 i ++ ;
@@ -144,7 +146,7 @@ function plotButtons(plots, figDir) {
144146 scrapeButton . style . background = 'blue' ;
145147 plotlist . appendChild ( scrapeButton ) ;
146148
147- scrapeButton . addEventListener ( 'click' , function ( ) {
149+ scrapeButton . addEventListener ( 'click' , function ( ) {
148150 Plotly . Snapshot . toSVG ( Tabs . get ( ) ) ;
149151 return ;
150152 } ) ;
0 commit comments