Skip to content

Commit 6d48a3b

Browse files
committed
Fix bug by which tickvals forever expands
The algo has to set the tickvals property back to original value after spoofing it. This does that.
1 parent e7a2ffa commit 6d48a3b

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

src/plots/cartesian/axes.js

+24-22
Original file line numberDiff line numberDiff line change
@@ -944,33 +944,35 @@ axes.calcTicks = function calcTicks(ax, opts) {
944944
axes.prepTicks(mockAx, opts);
945945
}
946946

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
949957
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
951965
if(major) {
952-
vals = Lib.nestedProperty(ax, "tickvals")
966+
tickVals = [];
967+
ticksOut = arrayTicks(ax);
953968
} else {
954-
vals = Lib.nestedProperty(ax.minor, "tickvals")
969+
minorTickVals = [];
970+
minorTicks = arrayTicks(ax);
955971
}
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-
}
962972

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;
974976
}
975977

976978
// fill tickVals based on overlaying axis

0 commit comments

Comments
 (0)