Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Setting 'array' tickmode on minor and major ticks causes 'ticksOut' to contain a duplicate of itself. #6828

Closed
ayjayt opened this issue Dec 27, 2023 · 1 comment
Labels
bug something broken

Comments

@ayjayt
Copy link
Contributor

ayjayt commented Dec 27, 2023

In cartesian/axes.js: calcTicks() we open a loop:

// calc major first
for(var major = 1; major >= (hasMinor ? 0 : 1); major--) {
var isMinor = !major;

Where we eventually grab ticks using tickArray():

// 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') {
if(major) {
tickVals = [];
ticksOut = arrayTicks(ax);
} else {
minorTickVals = [];
minorTicks = arrayTicks(ax);
}
continue;
}

The problem is that arrayTicks(ax) always returns major AND minor ticks- So minorTicks and ticksOut will both contain all ticks. This is not the case were tickmode to be any other setting!

After we acquire the ticks, several hundred lines are dedicated to doing properties and checks dependent on whether we're major or minor- relevant lines concern setting major/minor ID and adjusting dates. This is where possible visual errors could be found, in these edge cases.

At the end, we concatenate minorTicks onto ticksOut right before return:

}
ticksOut = ticksOut.concat(minorTicks);

So we contain two sets of major ticks, two sets of minor ticks, each set the same. You can console.log() it to see.

This doesn't always propogate to the DOM: Since draw functions have to account for axes referring to the same items, they create a set stashed = {} and ensure not to redraw the same item twice. This would catch most errors.

I wanted to produce visual effects on edge cases, but date setting with arrays seems to be entirely wonky:

image

graph = Tabs.getGraph(); var update = {
    title: 'Mock: date_axes_period_breaks_automargin!',
    'xaxis.tickmode': 'array',
    'xaxis.tickvals': ["2015-4", "2015-5", "2015-6", "2015-7", "2015-8", "2015-9", "2015-10", "2015-11", "2015-12", "2016-1", "2016-2", "2016-3", "2016-4", "2016-5", "2016-6", "2016-7", "2016-8", "2016-9", "2016-10", "2016-11", "2016-12", "2017-1"],
    'xaxis.gridwidth': '2',
    'xaxis.ticklabelmode': "period",
};
Plotly.relayout(graph, update)

Pull request incoming.

ayjayt added a commit to geopozo/plotly.js that referenced this issue Dec 28, 2023
@archmoj archmoj added the bug something broken label Jan 2, 2024
@ayjayt
Copy link
Contributor Author

ayjayt commented Jan 12, 2024

Fixed!

@ayjayt ayjayt closed this as completed Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

2 participants