@@ -43,7 +43,6 @@ const addSeries = () => {
4343 const series = ( seriesNode as HTMLElement ) . querySelector ( 'div' ) ;
4444
4545 series . setAttribute ( 'index' , ( series_counter ++ ) . toString ( ) ) ;
46- series . setAttribute ( 'plot_num' , '1' ) ;
4746
4847 series . querySelector ( '.file-select' )
4948 . addEventListener ( 'change' , ( ) => {
@@ -113,6 +112,16 @@ const addSeries = () => {
113112 updateAxes ( ) ;
114113 }
115114
115+ const plots : Array < number > = [ ] ;
116+ for ( const series of document . querySelectorAll ( '.series' ) as NodeListOf < HTMLElement > ) {
117+ plots . push ( parseInt ( series . getAttribute ( 'plot_num' ) ) ) ;
118+ }
119+ const plot_num = plots . length == 0 ? 1 : Math . max ( ...plots ) + 1 ;
120+ setPlot ( plot_num ) ;
121+ if ( plot_num > 5 ) {
122+ plot_other . value = plot_num . toString ( ) ;
123+ }
124+
116125 plot_1_button . addEventListener ( 'click' , ( ) => {
117126 setPlot ( 1 ) ;
118127 } )
@@ -192,6 +201,7 @@ const addSeries = () => {
192201 updateMarkers ( series ) ;
193202 }
194203
204+ updateAxes ( ) ;
195205 updateAdvanced ( ) ;
196206} ;
197207
@@ -356,57 +366,59 @@ const updateTrace = (series: HTMLElement, update_axes: boolean = true) => {
356366 const x_label = ( series . querySelector ( '.x-select' ) as HTMLSelectElement ) . value ;
357367 const y_label = ( series . querySelector ( '.y-select' ) as HTMLSelectElement ) . value ;
358368
359- if ( file !== '' && x_label !== '' && y_label !== '' ) {
360- if ( first_trace ) {
361- Plotly . relayout ( 'plot' , { title : '' } ) ;
362- }
363- first_trace = false ;
364-
365- const x_scale = parseFloat ( ( series . querySelector ( '.x-transform-scale' ) as HTMLInputElement ) . value ) ;
366- let x_offset = parseFloat ( ( series . querySelector ( '.x-transform-offset' ) as HTMLInputElement ) . value ) ;
367-
368- const y_scale = parseFloat ( ( series . querySelector ( '.y-transform-scale' ) as HTMLInputElement ) . value ) ;
369- const y_offset = parseFloat ( ( series . querySelector ( '.y-transform-offset' ) as HTMLInputElement ) . value ) ;
370-
371- const downsample = series . querySelector ( '.downsample' ) as HTMLInputElement ;
372- const downsample_factor = intMin1 ( parseInt ( downsample . value ) ) ;
373- downsample . value = downsample_factor . toString ( ) ;
374-
375- const trace_data = dfs [ file ] . data ;
376-
377- trace_data . sort ( ( a , b ) => {
378- const ax = a [ x_label ] ;
379- const bx = b [ x_label ] ;
380- return ax < bx ? - 1 :
381- ax > bx ? 1 :
382- 0 ;
383- } )
384-
385- let x_data = [ ] ;
386- let y_data = [ ] ;
387- for ( let i = 0 ; i < trace_data . length ; i += downsample_factor ) {
388- const x = trace_data [ i ] [ x_label ] ;
389- const y = trace_data [ i ] [ y_label ] ;
390- if ( x !== null && y !== null ) {
391- x_data . push ( x ) ;
392- y_data . push ( y ) ;
393- }
394- }
369+ if ( file == '' && x_label == '' && y_label == '' ) {
370+ return ;
371+ }
395372
396- const zero_x = ( series . querySelector ( '.zero-x-checkbox' ) as HTMLInputElement ) . checked ;
373+ if ( first_trace ) {
374+ Plotly . relayout ( 'plot' , { title : '' } ) ;
375+ }
376+ first_trace = false ;
397377
398- const trace = {
399- x : [ transformData ( x_data , x_scale , x_offset , zero_x ) ] ,
400- y : [ transformData ( y_data , y_scale , y_offset , false ) ] ,
401- }
378+ const x_scale = parseFloat ( ( series . querySelector ( '.x-transform-scale' ) as HTMLInputElement ) . value ) ;
379+ let x_offset = parseFloat ( ( series . querySelector ( '.x-transform-offset' ) as HTMLInputElement ) . value ) ;
402380
403- const index = parseInt ( series . getAttribute ( 'index' ) ) ;
404- Plotly . restyle ( 'plot' , trace , index ) ;
381+ const y_scale = parseFloat ( ( series . querySelector ( '.y-transform-scale' ) as HTMLInputElement ) . value ) ;
382+ const y_offset = parseFloat ( ( series . querySelector ( '.y-transform-offset' ) as HTMLInputElement ) . value ) ;
383+
384+ const downsample = series . querySelector ( '.downsample' ) as HTMLInputElement ;
385+ const downsample_factor = intMin1 ( parseInt ( downsample . value ) ) ;
386+ downsample . value = downsample_factor . toString ( ) ;
405387
406- if ( update_axes ) {
407- updateAxes ( ) ;
388+ const trace_data = dfs [ file ] . data ;
389+
390+ trace_data . sort ( ( a , b ) => {
391+ const ax = a [ x_label ] ;
392+ const bx = b [ x_label ] ;
393+ return ax < bx ? - 1 :
394+ ax > bx ? 1 :
395+ 0 ;
396+ } )
397+
398+ let x_data = [ ] ;
399+ let y_data = [ ] ;
400+ for ( let i = 0 ; i < trace_data . length ; i += downsample_factor ) {
401+ const x = trace_data [ i ] [ x_label ] ;
402+ const y = trace_data [ i ] [ y_label ] ;
403+ if ( x !== null && y !== null ) {
404+ x_data . push ( x ) ;
405+ y_data . push ( y ) ;
408406 }
409407 }
408+
409+ const zero_x = ( series . querySelector ( '.zero-x-checkbox' ) as HTMLInputElement ) . checked ;
410+
411+ const trace = {
412+ x : [ transformData ( x_data , x_scale , x_offset , zero_x ) ] ,
413+ y : [ transformData ( y_data , y_scale , y_offset , false ) ] ,
414+ }
415+
416+ const index = parseInt ( series . getAttribute ( 'index' ) ) ;
417+ Plotly . restyle ( 'plot' , trace , index ) ;
418+
419+ if ( update_axes ) {
420+ updateAxes ( ) ;
421+ }
410422} ;
411423
412424const updateMarkers = ( series : HTMLElement ) => {
0 commit comments