Skip to content

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

Closed
@ayjayt

Description

@ayjayt

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions