@@ -888,18 +888,47 @@ var FigureView = widgets.DOMWidgetView.extend({
888
888
// Most cartesian plots
889
889
var pointObjects = data [ "points" ] ;
890
890
var numPoints = pointObjects . length ;
891
+
892
+ var hasNestedPointObjects = true ;
893
+ for ( let i = 0 ; i < numPoints ; i ++ ) {
894
+ hasNestedPointObjects = ( hasNestedPointObjects && pointObjects [ i ] . hasOwnProperty ( "pointNumbers" ) ) ;
895
+ if ( ! hasNestedPointObjects ) break ;
896
+ }
897
+ var numPointNumbers = numPoints ;
898
+ if ( hasNestedPointObjects ) {
899
+ numPointNumbers = 0 ;
900
+ for ( let i = 0 ; i < numPoints ; i ++ ) {
901
+ numPointNumbers += pointObjects [ i ] [ "pointNumbers" ] . length ;
902
+ }
903
+ }
891
904
pointsObject = {
892
- trace_indexes : new Array ( numPoints ) ,
893
- point_indexes : new Array ( numPoints ) ,
894
- xs : new Array ( numPoints ) ,
895
- ys : new Array ( numPoints ) ,
905
+ trace_indexes : new Array ( numPointNumbers ) ,
906
+ point_indexes : new Array ( numPointNumbers ) ,
907
+ xs : new Array ( numPointNumbers ) ,
908
+ ys : new Array ( numPointNumbers ) ,
896
909
} ;
897
910
898
- for ( var p = 0 ; p < numPoints ; p ++ ) {
899
- pointsObject [ "trace_indexes" ] [ p ] = pointObjects [ p ] [ "curveNumber" ] ;
900
- pointsObject [ "point_indexes" ] [ p ] = pointObjects [ p ] [ "pointNumber" ] ;
901
- pointsObject [ "xs" ] [ p ] = pointObjects [ p ] [ "x" ] ;
902
- pointsObject [ "ys" ] [ p ] = pointObjects [ p ] [ "y" ] ;
911
+ if ( hasNestedPointObjects ) {
912
+ var flatPointIndex = 0 ;
913
+ for ( var p = 0 ; p < numPoints ; p ++ ) {
914
+ for ( let i = 0 ; i < pointObjects [ p ] [ "pointNumbers" ] . length ; i ++ , flatPointIndex ++ ) {
915
+ pointsObject [ "point_indexes" ] [ flatPointIndex ] = pointObjects [ p ] [ "pointNumbers" ] [ i ]
916
+ // also add xs, ys and traces so that the array doesn't get truncated later
917
+ pointsObject [ "xs" ] [ flatPointIndex ] = pointObjects [ p ] [ "x" ] ;
918
+ pointsObject [ "ys" ] [ flatPointIndex ] = pointObjects [ p ] [ "y" ] ;
919
+ pointsObject [ "trace_indexes" ] [ flatPointIndex ] = pointObjects [ p ] [ "curveNumber" ] ;
920
+ }
921
+ }
922
+ pointsObject [ "point_indexes" ] . sort ( function ( a , b ) {
923
+ return a - b ;
924
+ } ) ;
925
+ } else {
926
+ for ( var p = 0 ; p < numPoints ; p ++ ) {
927
+ pointsObject [ "trace_indexes" ] [ p ] = pointObjects [ p ] [ "curveNumber" ] ;
928
+ pointsObject [ "point_indexes" ] [ p ] = pointObjects [ p ] [ "pointNumber" ] ;
929
+ pointsObject [ "xs" ] [ p ] = pointObjects [ p ] [ "x" ] ;
930
+ pointsObject [ "ys" ] [ p ] = pointObjects [ p ] [ "y" ] ;
931
+ }
903
932
}
904
933
905
934
// Add z if present
0 commit comments