@@ -944,33 +944,35 @@ axes.calcTicks = function calcTicks(ax, opts) {
944
944
axes . prepTicks ( mockAx , opts ) ;
945
945
}
946
946
947
- console . log ( "mode:" + mockAx . tickmode )
948
- if ( mockAx . tickmode === 'proportional' ) { // TODO: if we look at autorange, can we get rid of buffer
947
+ // tickmode 'proportional' is just 'array' but with a pre-calc step
948
+ // original comment:
949
+ // now that we've figured out the auto values for formatting
950
+ // in case we're missing some ticktext, we can break out for array ticks
951
+ if ( mockAx . tickmode === 'array' || mockAx . tickmode === 'proportional' ) {
952
+
953
+ // Mapping proportions to array:
954
+ var valsProp
955
+ var proportionalVals
956
+ var mappedVals
949
957
var distance = maxRange - minRange ;
950
- var vals = [ ]
958
+ if ( mockAx . tickmode === 'proportional' ) {
959
+ valsProp = major ? Lib . nestedProperty ( ax , "tickvals" ) : Lib . nestedProperty ( ax . minor , "tickvals" )
960
+ proportionalVals = valsProp . get ( )
961
+ mappedVals = proportionalVals . map ( function ( v ) { return minRange + ( distance * v ) } )
962
+ valsProp . set ( mappedVals )
963
+ }
964
+ // Original
951
965
if ( major ) {
952
- vals = Lib . nestedProperty ( ax , "tickvals" )
966
+ tickVals = [ ] ;
967
+ ticksOut = arrayTicks ( ax ) ;
953
968
} else {
954
- vals = Lib . nestedProperty ( ax . minor , "tickvals" )
969
+ minorTickVals = [ ] ;
970
+ minorTicks = arrayTicks ( ax ) ;
955
971
}
956
- var mappedVals = vals . get ( ) . map ( function ( x ) { return minRange + ( distance * x ) } )
957
- vals . set ( mappedVals )
958
- // TODO: What happens if range reversed
959
- // TODO: Needs to be recalculated on auto
960
- // TODO: Disappears on double click
961
- }
962
972
963
- // now that we've figured out the auto values for formatting
964
- // in case we're missing some ticktext, we can break out for array ticks
965
- if ( mockAx . tickmode === 'array' || mockAx . tickmode === 'proportional' ) {
966
- if ( major ) {
967
- tickVals = [ ] ;
968
- ticksOut = arrayTicks ( ax ) ;
969
- } else {
970
- minorTickVals = [ ] ;
971
- minorTicks = arrayTicks ( ax ) ;
972
- }
973
- continue ;
973
+ // Reset tickvals back to proportional
974
+ if ( mockAx . tickmode === 'proportional' ) valsProp . set ( proportionalVals )
975
+ continue ;
974
976
}
975
977
976
978
// fill tickVals based on overlaying axis
0 commit comments