Skip to content

Commit

Permalink
multi comparison (matrix, cube)
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-donarise committed Nov 11, 2023
1 parent 37e9941 commit 7d0bcdc
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 69 deletions.
6 changes: 3 additions & 3 deletions plot/cube/cube.view.tree
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$mpds_visavis_plot_cube $mol_view
plot_raw $mpds_visavis_plot_raw
json_cmp? null
multi_jsons? null
show_setup true
show_fixel? true
heatmap? false
Expand Down Expand Up @@ -42,8 +42,8 @@ $mpds_visavis_plot_cube $mol_view
layout <= layout *
subscribe_events <= subscribe_events null
<= Cmp_legend $mpds_visavis_plot_legend_cmp
first_cmp_label? <= first_cmp_label? \
second_cmp_label? <= second_cmp_label? \
labels <= cmp_labels /
colorset <= colorset
<= Side_right $mol_scroll
sub /
<= Heatmap_legend $mol_list
Expand Down
50 changes: 28 additions & 22 deletions plot/cube/cube.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace $.$$ {
setup() {
return [
... this.show_fixel() ? [ this.Fixel() ] : [],
this.json_cmp() ? this.Diffrence_on() : this.Nonformers(),
this.multi_jsons() ? this.Diffrence_on() : this.Nonformers(),
... this.show_setup() ? [ this.X_order(), this.Y_order(), this.Z_order() ] : [],
]
}
Expand All @@ -35,7 +35,7 @@ namespace $.$$ {
plot_body() {
return [
this.Root(),
... this.json_cmp() ? [ this.Cmp_legend() ] : [],
... this.multi_jsons() ? [ this.Cmp_legend() ] : [],
... this.heatmap() ? [ this.Side_right() ] : [],
]
}
Expand Down Expand Up @@ -135,32 +135,38 @@ namespace $.$$ {
}

@ $mol_mem
data_cmp() {
if (!this.json_cmp() ) return null
multi_dataset(): any[] | null {
if( ! this.multi_jsons() ) return null

this.nonformers_checked( false )
this.first_cmp_label( this.json().answerto )
this.second_cmp_label( this.json_cmp().answerto )
return {
...this.scatter3d_common(),
text: this.json_cmp().payload.points.labels,
marker: this.marker( 1 ),
...this.convert_to_axes(
this.json_cmp().payload.points.x,
this.json_cmp().payload.points.y,
this.json_cmp().payload.points.z,
this.x_sort() as Prop_name,
this.y_sort() as Prop_name,
this.z_sort() as Prop_name,
)
}

return this.multi_jsons().map( (json: any, index: number) => {
return {
...this.scatter3d_common(),
text: json.payload.points.labels,
marker: this.marker( index ),
...this.convert_to_axes(
json.payload.points.x,
json.payload.points.y,
json.payload.points.z,
this.x_sort() as Prop_name,
this.y_sort() as Prop_name,
this.z_sort() as Prop_name,
)
}
} )
}

@ $mol_mem
cmp_labels() {
return this.multi_jsons() ? this.multi_jsons()!.map( (json: any) => json.answerto ) : []
}

@ $mol_mem
data_shown() {
return [
... this.nonformers_checked() ? [this.data_nonformers()] : [],
this.data(),
... this.json_cmp() ? [this.data_cmp()] : [],
... this.nonformers_checked() ? [ this.data_nonformers() ] : [],
... this.multi_dataset() ? this.multi_dataset()! : [ this.data() ],
]
}

Expand Down
42 changes: 18 additions & 24 deletions plot/legend/cmp/cmp.view.css.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
namespace $.$$ {

const Cmp_label: $mol_style_properties = {
color: 'white',
padding: {
left: $mol_gap.space,
right: $mol_gap.space,
}
}

$mol_style_define( $mpds_visavis_plot_legend_cmp, {

lineHeight: '1',

position: 'absolute',
left: 0,
bottom: 0,
width: '100%',
gap: $mol_gap.block,
alignItems: 'center',
justifyContent: 'center',
padding: {
bottom: $mol_gap.space,
},
lineHeight: '1',

First_cmp_label: {
...Cmp_label,
background: {
color: '#3e3f95',
},

gap: $mol_gap.block,
align: {
items: 'center',
},
justify: {
content: 'center',
}

Second_cmp_label: {
...Cmp_label,
background: {
color: '#c00',
},
},
} )

$mol_style_define( $mpds_visavis_plot_legend_cmp_label, {

color: 'white',
padding: {
left: $mol_gap.space,
right: $mol_gap.space,
}

} )

Expand Down
16 changes: 12 additions & 4 deletions plot/legend/cmp/cmp.view.tree
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
$mpds_visavis_plot_legend_cmp $mol_view
sub /
<= First_cmp_label $mol_view
sub / <= first_cmp_label? \
<= Label*0 $mpds_visavis_plot_legend_cmp_label
label <= label* \
background <= background* \
\vs.
<= Second_cmp_label $mol_view
sub / <= second_cmp_label? \
<= Label*1
labels /
colorset /

$mpds_visavis_plot_legend_cmp_label $mol_view
sub / <= label \
style *
^
background <= background \
19 changes: 19 additions & 0 deletions plot/legend/cmp/cmp.view.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace $.$$ {
export class $mpds_visavis_plot_legend_cmp extends $.$mpds_visavis_plot_legend_cmp {

sub(): readonly any[] {
return this.labels().length == 2
? super.sub()
: this.labels().map( ( label, ind ) => this.Label( ind ) )
}

label( index: number ): string {
return this.labels()[ index ] ?? ''
}

background( index: number ): string {
return this.colorset()[ index ] ?? ''
}

}
}
6 changes: 3 additions & 3 deletions plot/matrix/matrix.view.tree
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$mpds_visavis_plot_matrix $mol_view
plot_raw $mpds_visavis_plot_raw
json_cmp? null
multi_jsons? null
json_master null
show_setup true
size 0
Expand Down Expand Up @@ -43,8 +43,8 @@ $mpds_visavis_plot_matrix $mol_view
<= Root $mol_view
render <= draw null
<= Cmp_legend $mpds_visavis_plot_legend_cmp
first_cmp_label? <= first_cmp_label? \
second_cmp_label? <= second_cmp_label? \
labels <= cmp_labels /
colorset <= colorset
<= Side_right $mol_scroll
sub /
<= Heatmap_legend $mol_list
Expand Down
31 changes: 20 additions & 11 deletions plot/matrix/matrix.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace $.$$ {
setup() {
return [
... this.json().payload.fixel ? [ this.Fixel() ] : [],
this.json_cmp() ? this.Diffrence_on() : this.Nonformers(),
this.multi_jsons() ? this.Diffrence_on() : this.Nonformers(),
... this.show_setup() ? [ this.Order() ] : [],
]
}
Expand All @@ -58,7 +58,7 @@ namespace $.$$ {
plot_body() {
return [
this.Root(),
... this.json_cmp() ? [ this.Cmp_legend() ] : [],
... this.multi_jsons() ? [ this.Cmp_legend() ] : [],
... this.heatmap() ? [ this.Side_right() ] : [],
]
}
Expand All @@ -68,19 +68,28 @@ namespace $.$$ {
return $mpds_visavis_plot_matrix_json( this.plot_raw().json() as any )
}

@ $mol_mem
cmp_labels() {
return this.multi_jsons() ? this.multi_jsons()!.map( (json: any) => json.answerto ) : []
}

@ $mol_mem
json_master() {
if ( !this.json_cmp() ) return this.json()

const json_master = JSON.parse(JSON.stringify( this.json() ));
this.json_cmp().payload.links.forEach( (item: any)=> {
item.cmp = 1;
json_master.payload.links.push(item);
});
if ( ! this.multi_jsons() ) return this.json()

const jsons = this.multi_jsons()!

const json_master = JSON.parse( JSON.stringify( jsons[0] ) )

for (let i = 1; i < jsons.length; i++) {
const json = jsons[i]
json.payload.links.forEach( ( item: any ) => {
item.cmp = i
json_master.payload.links.push( item )
} )
}

this.nonformers_checked( false )
this.first_cmp_label( this.json().answerto )
this.second_cmp_label( this.json_cmp().answerto )

return $mpds_visavis_plot_matrix_json( json_master )
}
Expand Down
6 changes: 4 additions & 2 deletions plot/plot.view.tree
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ $mpds_visavis_plot $mol_view
json null
json_cmp_request? null
json_cmp null
multi_requests? /
multi_jsons null
plot_raw null
show_setup false
notify? null
Expand All @@ -19,7 +21,7 @@ $mpds_visavis_plot $mol_view
plots *
matrix <= Matrix $mpds_visavis_plot_matrix
plot_raw <= plot_raw
json_cmp <= json_cmp
multi_jsons <= multi_jsons
show_setup <= show_setup
nonformers_checked? <=> nonformers_checked? false
fixel_checked? <=> matrix_fixel_checked? true
Expand All @@ -30,7 +32,7 @@ $mpds_visavis_plot $mol_view
matrix_click? <=> matrix_click? null
plot3d <= Cube $mpds_visavis_plot_cube
plot_raw <= plot_raw
json_cmp <= json_cmp
multi_jsons <= multi_jsons
show_setup <= show_setup
show_fixel? <= show_fixel? true
nonformers_checked? <=> nonformers_checked?
Expand Down
7 changes: 7 additions & 0 deletions plot/plot.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ namespace $.$$ {
return $mpds_visavis_plot.fetch_plot_json( this.json_cmp_request() )
}

@ $mol_mem
multi_jsons() {
return this.multi_requests().length > 0
? this.multi_requests().map( req => $mpds_visavis_plot.fetch_plot_json( req ) )
: this.json_cmp() ? [ this.json(), this.json_cmp() ] : null
}

@ $mol_mem
json_cmp_request( next?: string | null ) {
if ( next === null && $mol_wire_probe( ()=> this.json_cmp_request() ) === null ) {
Expand Down

0 comments on commit 7d0bcdc

Please sign in to comment.