@@ -171,15 +171,13 @@ function fileReader(fname) {
171171 undoStack = [ ] ; redoStack = [ ] ; swapperIsOn = false ;
172172
173173 if ( figurecontainer . data . length > 1 ) { // delete extra traces
174+ Plotly . deleteTraces ( figurecontainer , Plotly . d3 . range ( 1 , figurecontainer . data . length ) )
174175 if ( currentEditable != 0 ) {
175- let tmp = clone ( iniPointsD )
176- delete tmp . x ; delete tmp . y // iniPointsD x/y is not in update format
177- Plotly . update ( figurecontainer , tmp , clone ( layout ) )
176+ Plotly . update ( figurecontainer , { ... clone ( iniPointsD ) , x :[ [ 1 ] ] , y :[ [ 1 ] ] } , clone ( layout ) )
178177 $ ( `.scatterlayer .trace:first-of-type .points path` ) . css ( { 'pointer-events' :'all' } )
179178 points = figurecontainer . querySelector ( ".scatterlayer .trace:first-of-type .points" ) . getElementsByTagName ( "path" ) ;
180179 currentEditable = 0
181180 }
182- Plotly . deleteTraces ( figurecontainer , Plotly . d3 . range ( 1 , figurecontainer . data . length ) )
183181 }
184182
185183
@@ -229,12 +227,9 @@ function addNewFileDialog() {
229227
230228
231229function addNewFile ( fname ) {
232- // let dat = parseData(fs.readFileSync(fname, "utf8"))
233- // if(dat==undefined) return
234230 dat = fileOpener ( fname )
235231 if ( fullData [ 0 ] . length != dat . length ) alertElec ( "Trying to open a file with different grid.\nThis is not supported for 3D data." , 1 , "Can't add the file!!!" )
236- // return
237- // }
232+
238233
239234 let dirname = path . dirname ( fname ) ;
240235 let filename = path . basename ( fname , path . extname ( fname ) ) ;
@@ -253,6 +248,20 @@ function addNewFile(fname) {
253248 makeRows ( )
254249}
255250
251+ function addTrace ( ) {
252+ let ind = fullData . length - 1
253+ let thisTrace = {
254+ ... clone ( iniPointsD ) ,
255+ x : fullData [ ind ] [ th_in ] [ fullDataCols [ ind ] . y ] ,
256+ y : fullData [ ind ] [ th_in ] [ fullDataCols [ ind ] . z ] ,
257+ name : legendNames [ ind ]
258+ }
259+
260+ delete thisTrace . marker . color
261+ delete thisTrace . line . color
262+
263+ Plotly . addTraces ( figurecontainer , thisTrace ) ;
264+ }
256265
257266
258267var cRange = false , cRangeY = [ NaN , NaN ] ; //hidden feature
@@ -483,20 +492,6 @@ function changeEditable2(ind){ // used for deleting trace below the currentedita
483492
484493
485494
486- function addTrace ( ) {
487- let ind = fullData . length - 1
488- let thisTrace = {
489- ... iniPointsD ,
490- x : fullData [ ind ] [ th_in ] [ fullDataCols [ ind ] . y ] ,
491- y : fullData [ ind ] [ th_in ] [ fullDataCols [ ind ] . z ] ,
492- name : legendNames [ ind ]
493- }
494- delete thisTrace . marker . color
495- delete thisTrace . line . color
496- Plotly . addTraces ( figurecontainer , thisTrace ) ;
497- }
498-
499-
500495var swapperIsOn = false
501496function openSwapper ( ) {
502497 if ( fileNames . length != 1 ) alertElec ( "Can't use this feature when multiple files are open." , 0 , "Operation Unavailable" )
0 commit comments