22
33var Lib = require ( '@src/lib' ) ;
44
5- var plotlist = document . getElementById ( 'plot-list' ) ;
5+ var plotList = document . getElementById ( 'plot-list' ) ;
66var anchor = document . getElementById ( 'embedded-graph' ) ;
77var image = document . getElementById ( 'embedded-image' ) ;
88
@@ -14,31 +14,30 @@ anchor.style.height = '600px';
1414anchor . style . width = '1000px' ;
1515
1616function plotButtons ( plots , figDir ) {
17-
1817 Object . keys ( plots ) . forEach ( function ( plotname ) {
19-
2018 var button = document . createElement ( 'button' ) ;
2119
2220 button . style . cssFloat = 'left' ;
2321 button . style . width = '100px' ;
2422 button . style . height = '40px' ;
25-
2623 button . innerHTML = plotname ;
2724
28- plotlist . appendChild ( button ) ;
25+ plotList . appendChild ( button ) ;
2926
3027 button . addEventListener ( 'click' , function ( ) {
31-
3228 var myImage = new Image ( ) ;
3329 myImage . src = figDir + plotname + '.png' ;
3430
3531 image . innerHTML = '' ;
3632 image . appendChild ( myImage ) ;
3733
38-
39- anchor . innerHTML = '' ;
34+ var currentGraphDiv = Tabs . getGraph ( ) ;
35+ if ( currentGraphDiv ) Plotly . purge ( currentGraphDiv ) ;
4036
4137 gd = document . createElement ( 'div' ) ;
38+ gd . id = 'graph' ;
39+
40+ anchor . innerHTML = '' ;
4241 anchor . appendChild ( gd ) ;
4342
4443 var plot = plots [ plotname ] ;
@@ -58,7 +57,7 @@ function plotButtons(plots, figDir) {
5857 snapshot . innerHTML = 'snapshot' ;
5958 snapshot . style . background = 'blue' ;
6059
61- plotlist . appendChild ( snapshot ) ;
60+ plotList . appendChild ( snapshot ) ;
6261
6362 snapshot . addEventListener ( 'click' , function ( ) {
6463
@@ -111,7 +110,7 @@ function plotButtons(plots, figDir) {
111110 pummelButton . style . marginLeft = '25px' ;
112111 pummelButton . innerHTML = 'pummel3d' ;
113112 pummelButton . style . background = 'blue' ;
114- plotlist . appendChild ( pummelButton ) ;
113+ plotList . appendChild ( pummelButton ) ;
115114
116115 var i = 0 ;
117116 var mock = require ( '@mocks/gl3d_marker-color.json' ) ;
@@ -147,7 +146,7 @@ function plotButtons(plots, figDir) {
147146 scrapeButton . style . marginLeft = '25px' ;
148147 scrapeButton . innerHTML = 'scrape SVG' ;
149148 scrapeButton . style . background = 'blue' ;
150- plotlist . appendChild ( scrapeButton ) ;
149+ plotList . appendChild ( scrapeButton ) ;
151150
152151 scrapeButton . addEventListener ( 'click' , function ( ) {
153152 Plotly . Snapshot . toSVG ( Tabs . get ( ) ) ;
0 commit comments