Skip to content

Commit

Permalink
Fix bug by which tickvals forever expands
Browse files Browse the repository at this point in the history
The algo has to set the tickvals property back to original value after
spoofing it. This does that.
  • Loading branch information
ayjayt committed Dec 26, 2023
1 parent e7a2ffa commit 6d48a3b
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -944,33 +944,35 @@ axes.calcTicks = function calcTicks(ax, opts) {
axes.prepTicks(mockAx, opts);
}

console.log("mode:" + mockAx.tickmode)
if (mockAx.tickmode === 'proportional') { // TODO: if we look at autorange, can we get rid of buffer
// tickmode 'proportional' is just 'array' but with a pre-calc step
// original comment:
// now that we've figured out the auto values for formatting
// in case we're missing some ticktext, we can break out for array ticks
if (mockAx.tickmode === 'array' || mockAx.tickmode === 'proportional') {

// Mapping proportions to array:
var valsProp
var proportionalVals
var mappedVals
var distance = maxRange - minRange;
var vals = []
if (mockAx.tickmode === 'proportional') {
valsProp = major ? Lib.nestedProperty(ax, "tickvals") : Lib.nestedProperty(ax.minor, "tickvals")
proportionalVals = valsProp.get()
mappedVals = proportionalVals.map(function(v) { return minRange+(distance*v) })
valsProp.set(mappedVals)
}
// Original
if(major) {
vals = Lib.nestedProperty(ax, "tickvals")
tickVals = [];
ticksOut = arrayTicks(ax);
} else {
vals = Lib.nestedProperty(ax.minor, "tickvals")
minorTickVals = [];
minorTicks = arrayTicks(ax);
}
var mappedVals = vals.get().map(function(x) { return minRange+(distance*x) })
vals.set(mappedVals)
// TODO: What happens if range reversed
// TODO: Needs to be recalculated on auto
// TODO: Disappears on double click
}

// now that we've figured out the auto values for formatting
// in case we're missing some ticktext, we can break out for array ticks
if(mockAx.tickmode === 'array' || mockAx.tickmode === 'proportional') {
if(major) {
tickVals = [];
ticksOut = arrayTicks(ax);
} else {
minorTickVals = [];
minorTicks = arrayTicks(ax);
}
continue;
// Reset tickvals back to proportional
if (mockAx.tickmode === 'proportional') valsProp.set(proportionalVals)
continue;
}

// fill tickVals based on overlaying axis
Expand Down

0 comments on commit 6d48a3b

Please sign in to comment.