Skip to content

Commit

Permalink
validate 'use_visavis_type' of multi jsons
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-donarise committed Nov 30, 2023
1 parent 5372901 commit de0dd4d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
10 changes: 6 additions & 4 deletions plot/cube/cube.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace $.$$ {
const d3 = $mpds_visavis_lib_plotly.d3

const $mpds_visavis_plot_cube_json = $mol_data_record({
use_visavis_type: $mol_data_const( 'plot3d' ),
payload: $mol_data_record({
tcube: $mol_data_optional( $mol_data_boolean ),
points: $mol_data_record({
Expand Down Expand Up @@ -143,14 +144,15 @@ namespace $.$$ {
this.nonformers_checked( false )

return this.multi_jsons().map( (json: any, index: number) => {
const json_valid = $mpds_visavis_plot_cube_json( json )
return {
...this.scatter3d_common(),
text: json.payload.points.labels,
text: json_valid.payload.points.labels,
marker: this.marker( index ),
...this.convert_to_axes(
json.payload.points.x,
json.payload.points.y,
json.payload.points.z,
json_valid.payload.points.x,
json_valid.payload.points.y,
json_valid.payload.points.z,
this.x_sort() as Prop_name,
this.y_sort() as Prop_name,
this.z_sort() as Prop_name,
Expand Down
3 changes: 2 additions & 1 deletion plot/discovery/discovery.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace $.$$ {
type Element_prop = keyof ReturnType<typeof $mpds_visavis_elements_list.prop_names>

export const $mpds_visavis_plot_discovery_json = $mol_data_record({
use_visavis_type: $mol_data_const( 'discovery' ),
payload: Payload,
answerto: $mol_data_string,
})
Expand Down Expand Up @@ -211,7 +212,7 @@ namespace $.$$ {
data() {

const json = this.json()
const json_cmp = this.json_cmp()
const json_cmp = this.json_cmp() ? $mpds_visavis_plot_discovery_json( this.json_cmp() ) : null

const elementals_on = this.elementals_on()

Expand Down
7 changes: 5 additions & 2 deletions plot/matrix/matrix.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace $.$$ {
})

const $mpds_visavis_plot_matrix_json = $mol_data_record({
use_visavis_type: $mol_data_const( 'matrix' ),
answerto: $mol_data_optional( $mol_data_string ),
payload: $mol_data_record({
nodes: $mol_data_array( $mpds_visavis_plot_matrix_json_node ),
Expand Down Expand Up @@ -81,10 +82,12 @@ namespace $.$$ {

const jsons = this.multi_jsons()!

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

for (let i = 1; i < jsons.length; i++) {
const json = jsons[i]
const json = $mpds_visavis_plot_matrix_json( jsons[i] )
json.payload.links.forEach( ( item: any ) => {
item.cmp = i
json_master.payload.links.push( item )
Expand Down
1 change: 1 addition & 0 deletions plot/plot.view.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[mpds_visavis_plot][mol_view_error]:not([mol_view_error="Promise"]),
[mpds_visavis_plot_matrix_plot][mol_view_error]:not([mol_view_error="Promise"]),
[mpds_visavis_plot_matrix_root][mol_view_error]:not([mol_view_error="Promise"]),
[mpds_visavis_plot_graph_root][mol_view_error]:not([mol_view_error="Promise"]),
[mpds_visavis_plotly][mol_view_error]:not([mol_view_error="Promise"]) {
Expand Down
7 changes: 5 additions & 2 deletions plot/plot.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ namespace $.$$ {

@ $mol_mem
plot_raw() {
return this.json() ?
$mpds_visavis_plot_raw_from_json( this.json() ) : null
return this.multi_jsons()
? $mpds_visavis_plot_raw_from_json( this.multi_jsons()![0] )
: this.json()
? $mpds_visavis_plot_raw_from_json( this.json() )
: null
}

@ $mol_mem
Expand Down

0 comments on commit de0dd4d

Please sign in to comment.