Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions plot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 13 additions & 12 deletions plot/plot.view.tree
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ $mpds_visavis_plot $mol_view
json_request? null
json_cmp_request? null
multi_requests? /string
jsons /
jsons? /
plot_raw null
plot_raw_visible null
show_setup false
notify? null
show_demo_warn? false
Expand All @@ -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
Expand All @@ -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?
Expand All @@ -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?
53 changes: 30 additions & 23 deletions plot/plot.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ namespace $.$$ {

export class $mpds_visavis_plot extends $.$mpds_visavis_plot {

@ $mol_mem
sub( next?: readonly ( any )[] ): readonly ( any )[] {
if( !this.plot_raw_visible() ) return []
return next ?? super.sub()
}

@ $mol_action
static fetch_plot_json( request: RequestInfo | null ){
if ( request == null ) return null
Expand All @@ -13,7 +19,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
Expand All @@ -22,26 +28,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() {
Expand All @@ -50,7 +39,7 @@ namespace $.$$ {

error_message(): string {
try {
this.jsons_fetched()
this.plot_raw()
return ''

} catch( error: any ) {
Expand All @@ -76,16 +65,34 @@ namespace $.$$ {

@ $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.inconsistent_projection() ) {
this.notify( 'Error: inconsistent datasets projection' )
}

return $mpds_visavis_plot_raw_from_jsons( this.jsons() )
try {
const plot_raw = this.plot_raw()!
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
plot_type(): ReturnType< $mpds_visavis_plot_raw['type'] > {
return this.plot_raw()?.type()!
return this.plot_raw_visible()?.type()!
}

@ $mol_mem
Expand Down
Loading