File tree 3 files changed +51
-2
lines changed
Filter options
3 files changed +51
-2
lines changed
Original file line number Diff line number Diff line change @@ -503,6 +503,8 @@ function getTraceAttributes(type) {
503
503
504
504
var out = {
505
505
meta : _module . meta || { } ,
506
+ categories : _module . categories || { } ,
507
+ type : type ,
506
508
attributes : formatAttributes ( attributes ) ,
507
509
} ;
508
510
Original file line number Diff line number Diff line change @@ -2868,7 +2868,6 @@ function sortAxisCategoriesByValue(axList, gd) {
2868
2868
// Order by value
2869
2869
var match = ax . categoryorder . match ( sortAxisCategoriesByValueRegex ) ;
2870
2870
if ( match ) {
2871
- console . log ( ax . _categories ) ;
2872
2871
// Store values associated with each category
2873
2872
var categoriesValue = [ ] ;
2874
2873
for ( j = 0 ; j < ax . _categories . length ; j ++ ) {
@@ -2911,7 +2910,9 @@ function sortAxisCategoriesByValue(axList, gd) {
2911
2910
if ( twoDim ) {
2912
2911
for ( l = 0 ; l < value . length ; l ++ ) {
2913
2912
for ( o = 0 ; o < value [ l ] . length ; o ++ ) {
2914
- categoriesValue [ orientation === 'h' ? o : l ] [ 1 ] . push ( value [ l ] [ o ] ) ;
2913
+ var catIndex = orientation === 'h' ? o : l ;
2914
+ if ( catIndex > categoriesValue . length - 1 ) continue ;
2915
+ categoriesValue [ catIndex ] [ 1 ] . push ( value [ l ] [ o ] ) ;
2915
2916
}
2916
2917
}
2917
2918
} else {
Original file line number Diff line number Diff line change @@ -869,6 +869,52 @@ describe('calculated data and points', function() {
869
869
'b' : 1
870
870
} ) ;
871
871
} ) ;
872
+
873
+ it ( 'should order categories per value per axis' , function ( ) {
874
+ var schema = Plotly . PlotSchema . get ( ) ;
875
+ var traces = Object . keys ( schema . traces ) ;
876
+ var tracesSchema = [ ] ;
877
+ var i ;
878
+ for ( i = 0 ; i < traces . length ; i ++ ) {
879
+ tracesSchema . push ( schema . traces [ traces [ i ] ] ) ;
880
+ }
881
+ var cartesianTraces = tracesSchema . filter ( function ( t ) {
882
+ return t . categories . length && t . categories . indexOf ( 'cartesian' ) !== - 1 ;
883
+ } ) ;
884
+
885
+ var cartesianTraceNames = cartesianTraces . map ( function ( t ) {
886
+ return t . type ;
887
+ } ) ;
888
+
889
+ for ( i = 0 ; i < cartesianTraceNames . length ; i ++ ) {
890
+ var type = cartesianTraceNames [ i ] ;
891
+ if ( type === 'scattergl' ) continue ;
892
+ if ( type === 'carpet' ) continue ;
893
+ if ( type === 'contourcarpet' ) continue ;
894
+
895
+ Plotly . newPlot ( gd , {
896
+ data : [ {
897
+ type : type ,
898
+ x : [ 'a' , 'b' , 'c' , 'a' ] ,
899
+ a : [ 'a' , 'b' , 'c' , 'a' ] ,
900
+ b : [ 7 , 3 , 2 , 7 ] ,
901
+ y : [ 7 , 3 , 2 , 7 ] ,
902
+ z : [ 7 , 3 , 2 , 7 ] ,
903
+ // For OHLC
904
+ open : [ 7 , 3 , 2 , 7 ] ,
905
+ close : [ 7 , 3 , 2 , 7 ] ,
906
+ high : [ 7 , 3 , 2 , 7 ] ,
907
+ low : [ 7 , 3 , 2 , 7 ]
908
+ } ] ,
909
+ layout : {
910
+ xaxis : {
911
+ type : 'category' ,
912
+ categoryorder : 'value ascending'
913
+ }
914
+ }
915
+ } ) ;
916
+ }
917
+ } ) ;
872
918
} ) ;
873
919
874
920
describe ( 'customdata' , function ( ) {
You can’t perform that action at this time.
0 commit comments