@@ -2876,23 +2876,25 @@ function sortAxisCategoriesByValue(axList, gd) {
2876
2876
2877
2877
// Collect values across traces
2878
2878
for ( j = 0 ; j < ax . _traceIndices . length ; j ++ ) {
2879
- // Keep track of traces affected by this function
2880
2879
var traceIndex = ax . _traceIndices [ j ] ;
2881
- sortByValue . push ( traceIndex ) ;
2882
-
2883
2880
var fullData = gd . _fullData [ traceIndex ] ;
2881
+
2882
+ // Skip over invisible traces
2884
2883
if ( fullData . visible !== true ) continue ;
2885
2884
2885
+ // Keep track of traces affected by this function
2886
+ sortByValue . push ( traceIndex ) ;
2887
+
2886
2888
var type = fullData . type ;
2887
2889
if ( type === 'histogram' ) delete fullData . _autoBinFinished ;
2888
2890
2889
2891
var cd = gd . calcdata [ traceIndex ] ;
2890
2892
for ( k = 0 ; k < cd . length ; k ++ ) {
2891
2893
var cdi = cd [ k ] ;
2892
- var cat , catIndex , value , orientation ;
2894
+ var cat , catIndex , value ;
2893
2895
2894
2896
// Collect values across dimensions
2895
- if ( fullData . type === 'splom' ) {
2897
+ if ( type === 'splom' ) {
2896
2898
// Find which dimension the current axis is representing
2897
2899
var currentDimensionIndex = cdi . trace [ ax . _id . charAt ( 0 ) + 'axes' ] . indexOf ( ax . _id ) ;
2898
2900
@@ -2908,7 +2910,7 @@ function sortAxisCategoriesByValue(axList, gd) {
2908
2910
categoriesValue [ catIndex ] [ 1 ] . push ( dimension . values [ l ] ) ;
2909
2911
}
2910
2912
}
2911
- } else if ( fullData . type === 'scattergl' ) {
2913
+ } else if ( type === 'scattergl' ) {
2912
2914
// TODO: FIXME sorting scattergl breaks
2913
2915
for ( l = 0 ; l < cdi . t . x . length ; l ++ ) {
2914
2916
if ( ax . _id . charAt ( 0 ) === 'x' ) {
@@ -2928,30 +2930,35 @@ function sortAxisCategoriesByValue(axList, gd) {
2928
2930
if ( ax . _id . charAt ( 0 ) === 'x' ) {
2929
2931
cat = cdi . p + 1 ? cdi . p : cdi . x ;
2930
2932
value = cdi . s || cdi . v || cdi . y ;
2931
- // orientation = 'h';
2932
2933
} else if ( ax . _id . charAt ( 0 ) === 'y' ) {
2933
2934
cat = cdi . p + 1 ? cdi . p : cdi . y ;
2934
2935
value = cdi . s || cdi . v || cdi . x ;
2935
- // orientation = 'v';
2936
2936
}
2937
- orientation = fullData . orientation || 'v' ;
2938
2937
2939
2938
var twoDim = false ;
2940
2939
if ( cdi . hasOwnProperty ( 'z' ) ) {
2941
2940
value = cdi . z ;
2942
2941
twoDim = true ;
2943
2942
}
2944
2943
2944
+ if ( fullData . orientation === 'h' ) {
2945
+ cat = cdi . p + 1 ? cdi . p : cdi . x ;
2946
+ value = cdi . s || cdi . v || cdi . y ;
2947
+ }
2948
+
2945
2949
if ( twoDim ) {
2946
2950
for ( l = 0 ; l < value . length ; l ++ ) {
2947
2951
for ( o = 0 ; o < value [ l ] . length ; o ++ ) {
2948
- catIndex = orientation === 'v ' ? o : l ;
2952
+ catIndex = ax . _id . charAt ( 0 ) === 'y ' ? l : o ;
2949
2953
if ( catIndex > categoriesValue . length - 1 ) continue ;
2950
2954
categoriesValue [ catIndex ] [ 1 ] . push ( value [ l ] [ o ] ) ;
2951
2955
}
2952
2956
}
2953
2957
} else {
2954
- categoriesValue [ cat ] [ 1 ] . push ( value ) ;
2958
+ if ( ! Array . isArray ( value ) ) value = [ value ] ;
2959
+ for ( l = 0 ; l < value . length ; l ++ ) {
2960
+ categoriesValue [ cat ] [ 1 ] . push ( value [ l ] ) ;
2961
+ }
2955
2962
}
2956
2963
}
2957
2964
}
0 commit comments