Skip to content

Commit

Permalink
Update array display
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed May 25, 2024
1 parent 83e912c commit e2ed256
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions example/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ function appendStructuralMetadata( structuralMetadata, triangle, barycoord, inde

function appendRows( data, info ) {

const maxPropertyName = Math.max( ...Object.values( data ).flatMap( v => Object.keys( v ) ).map( n => n.length ) );
for ( const i in data ) {

structuralMetadataEl.innerText += `\n${ info[ i ].name || info[ i ].className }\n`;
Expand All @@ -152,13 +153,15 @@ function appendStructuralMetadata( structuralMetadata, triangle, barycoord, inde
let field = properties[ propertyName ];
if ( field && field.toArray ) {

field = field.toArray().map( n => parseFloat( n.toFixed( 3 ) ) );
field = field.toArray();

}

if ( field && field.join ) {

field = field.join( ', ' );
field = '\n' + field
.map( n => n.toFixed ? parseFloat( n.toFixed( 3 ) ) : n )
.map( ( v, i ) => ` [${ i }] ${ v }` ).join( '\n' );

}

Expand All @@ -168,7 +171,7 @@ function appendStructuralMetadata( structuralMetadata, triangle, barycoord, inde

}

structuralMetadataEl.innerText += ` ${ propertyName.padEnd( 20 ) } : ${ field }\n`;
structuralMetadataEl.innerText += ` ${ propertyName.padEnd( maxPropertyName + 1 ) } : ${ field }\n`;

}

Expand Down

0 comments on commit e2ed256

Please sign in to comment.