From 0a09a734bf86726a76d01424af01ae7d3165944d Mon Sep 17 00:00:00 2001 From: stan-donarise Date: Thu, 27 Feb 2025 16:43:41 +0300 Subject: [PATCH 1/3] don't show error if there is no data --- plot/README.md | 4 ++++ plot/plot.view.tree | 2 +- plot/plot.view.ts | 44 ++++++++++++++++++++++---------------------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/plot/README.md b/plot/README.md index fdcf122..03cbedd 100644 --- a/plot/README.md +++ b/plot/README.md @@ -45,6 +45,10 @@ Second request URL to get JSON for comparison (matrix, cube and discovery plots) Multiple request URLs to get JSON for comparison (matrix and cube plots) +**`jsons( next?: any[] ) : any[]`** + +JSON plot datasets + **`notify( msg: string ) : void`** Called inside the component for display notification diff --git a/plot/plot.view.tree b/plot/plot.view.tree index bedc5b9..ab333df 100644 --- a/plot/plot.view.tree +++ b/plot/plot.view.tree @@ -8,7 +8,7 @@ $mpds_visavis_plot $mol_view json_request? null json_cmp_request? null multi_requests? /string - jsons / + jsons? / plot_raw null show_setup false notify? null diff --git a/plot/plot.view.ts b/plot/plot.view.ts index 4b18e81..9a97a02 100644 --- a/plot/plot.view.ts +++ b/plot/plot.view.ts @@ -2,6 +2,11 @@ namespace $.$$ { export class $mpds_visavis_plot extends $.$mpds_visavis_plot { + sub( next?: readonly ( any )[] ): readonly ( any )[] { + if( this.jsons().length == 0 ) return [] + return next ?? super.sub() + } + @ $mol_action static fetch_plot_json( request: RequestInfo | null ){ if ( request == null ) return null @@ -13,7 +18,7 @@ namespace $.$$ { requests() { if( this.json_cmp_request() ) return [ this.json_request()!, this.json_cmp_request()! ] if( this.multi_requests().length > 0 ) return this.multi_requests() - return [ this.json_request() ] + return this.json_request() ? [ this.json_request() ] : [] } @ $mol_mem_key @@ -22,26 +27,9 @@ namespace $.$$ { } @ $mol_mem - jsons_fetched() { + jsons( next?: any[] ) { const requests = this.requests() - return requests.map( req => this.json_fetched( req ) ) - } - - jsons_cached?: any[] | null - @ $mol_mem - jsons() { - try { - const jsons = this.jsons_fetched() - this.jsons_cached = jsons - return jsons - - } catch( error ) { - if( !this.$.$mol_promise_like( error ) && this.jsons_cached ) { - console.error( error ) - return this.jsons_cached - } - throw error - } + return next ?? requests.map( req => this.json_fetched( req ) ) } error_visible() { @@ -50,7 +38,7 @@ namespace $.$$ { error_message(): string { try { - this.jsons_fetched() + $mpds_visavis_plot_raw_from_jsons( this.jsons() ) return '' } catch( error: any ) { @@ -74,13 +62,25 @@ namespace $.$$ { return fixels.size > 1 } + plot_raw_cached?: $mpds_visavis_plot_raw @ $mol_mem plot_raw() { if( this.inconsistent_projection() ) { this.notify( 'Error: inconsistent datasets projection' ) } - return $mpds_visavis_plot_raw_from_jsons( this.jsons() ) + try { + const plot_raw = $mpds_visavis_plot_raw_from_jsons( this.jsons() ) + this.plot_raw_cached = plot_raw + return plot_raw + + } catch( error ) { + if( !this.$.$mol_promise_like( error ) && this.plot_raw_cached ) { + console.error( error ) + return this.plot_raw_cached + } + throw error + } } @ $mol_mem From 98f22ee717ee6866cf62e90205e33cfeb3d433fc Mon Sep 17 00:00:00 2001 From: stan-donarise Date: Thu, 27 Feb 2025 17:33:55 +0300 Subject: [PATCH 2/3] plot_raw_visible added --- plot/plot.view.tree | 23 ++++++++++++----------- plot/plot.view.ts | 19 ++++++++++++++----- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/plot/plot.view.tree b/plot/plot.view.tree index ab333df..12a45e4 100644 --- a/plot/plot.view.tree +++ b/plot/plot.view.tree @@ -10,6 +10,7 @@ $mpds_visavis_plot $mol_view multi_requests? /string jsons? / plot_raw null + plot_raw_visible null show_setup false notify? null show_demo_warn? false @@ -25,7 +26,7 @@ $mpds_visavis_plot $mol_view sub / <= error_message \ plots * matrix <= Matrix $mpds_visavis_plot_matrix - plot_raw <= plot_raw + plot_raw <= plot_raw_visible show_setup <= show_setup nonformers_checked? <=> nonformers_checked? false fixel_checked? <=> matrix_fixel_checked? true @@ -35,7 +36,7 @@ $mpds_visavis_plot $mol_view y_sort? => matrix_y_sort? matrix_click? <=> matrix_click? null plot3d <= Cube $mpds_visavis_plot_cube - plot_raw <= plot_raw + plot_raw <= plot_raw_visible show_setup <= show_setup show_fixel? <= show_fixel? true nonformers_checked? <=> nonformers_checked? @@ -48,33 +49,33 @@ $mpds_visavis_plot $mol_view z_sort? => z_sort? cube_click? <=> cube_click? null pd <= Phase $mpds_visavis_plot_phase - plot_raw <= plot_raw + plot_raw <= plot_raw_visible phase_click? <=> phase_click? null data_demo => phase_data_demo bar <= Bar $mpds_visavis_plot_bar - plot_raw <= plot_raw + plot_raw <= plot_raw_visible bar_click? <=> bar_click? null discovery <= Discovery $mpds_visavis_plot_discovery - plot_raw <= plot_raw + plot_raw <= plot_raw_visible show_setup <= show_setup elementals_on? => discovery_elementals_on? discovery_click? <=> discovery_click? null eigenplot <= Eigen $mpds_visavis_plot_eigen - plot_raw <= plot_raw + plot_raw <= plot_raw_visible pie <= Pie $mpds_visavis_plot_pie - plot_raw <= plot_raw + plot_raw <= plot_raw_visible pie_click? <=> pie_click? null scatter <= Scatter $mpds_visavis_plot_scatter - plot_raw <= plot_raw + plot_raw <= plot_raw_visible notify? <=> notify? customscatter <= Customscatter $mpds_visavis_plot_customscatter - plot_raw <= plot_raw + plot_raw <= plot_raw_visible nplots_changed? <=> nplots_changed? null legend_click? <=> legend_click? null heatmap <= Heatmap $mpds_visavis_plot_heatmap - plot_raw <= plot_raw + plot_raw <= plot_raw_visible graph <= Graph $mpds_visavis_plot_graph - plot_raw <= plot_raw + plot_raw <= plot_raw_visible graph_rel? => graph_rel? graph_click? <=> graph_click? null notify? <=> notify? diff --git a/plot/plot.view.ts b/plot/plot.view.ts index 9a97a02..9b5a36c 100644 --- a/plot/plot.view.ts +++ b/plot/plot.view.ts @@ -2,8 +2,9 @@ namespace $.$$ { export class $mpds_visavis_plot extends $.$mpds_visavis_plot { + @ $mol_mem sub( next?: readonly ( any )[] ): readonly ( any )[] { - if( this.jsons().length == 0 ) return [] + if( !this.plot_raw_visible() ) return [] return next ?? super.sub() } @@ -38,7 +39,7 @@ namespace $.$$ { error_message(): string { try { - $mpds_visavis_plot_raw_from_jsons( this.jsons() ) + this.plot_raw() return '' } catch( error: any ) { @@ -62,15 +63,23 @@ namespace $.$$ { return fixels.size > 1 } - plot_raw_cached?: $mpds_visavis_plot_raw @ $mol_mem plot_raw() { + if( this.jsons().length == 0 ) return null + return $mpds_visavis_plot_raw_from_jsons( this.jsons() ) + } + + plot_raw_cached?: $mpds_visavis_plot_raw + @ $mol_mem + plot_raw_visible() { + if( this.jsons().length == 0 ) return null + if( this.inconsistent_projection() ) { this.notify( 'Error: inconsistent datasets projection' ) } try { - const plot_raw = $mpds_visavis_plot_raw_from_jsons( this.jsons() ) + const plot_raw = this.plot_raw()! this.plot_raw_cached = plot_raw return plot_raw @@ -85,7 +94,7 @@ namespace $.$$ { @ $mol_mem plot_type(): ReturnType< $mpds_visavis_plot_raw['type'] > { - return this.plot_raw()?.type()! + return this.plot_raw_visible()?.type()! } @ $mol_mem From 57b3f176837b599bb143cbba88a35177aa1b8d61 Mon Sep 17 00:00:00 2001 From: stan-donarise Date: Thu, 27 Feb 2025 17:38:57 +0300 Subject: [PATCH 3/3] Update plot.view.ts --- plot/plot.view.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/plot/plot.view.ts b/plot/plot.view.ts index 9b5a36c..b8508e8 100644 --- a/plot/plot.view.ts +++ b/plot/plot.view.ts @@ -72,8 +72,6 @@ namespace $.$$ { plot_raw_cached?: $mpds_visavis_plot_raw @ $mol_mem plot_raw_visible() { - if( this.jsons().length == 0 ) return null - if( this.inconsistent_projection() ) { this.notify( 'Error: inconsistent datasets projection' ) }