Skip to content

rangemode is ignored if there is no data #4137

Closed

Activity

  1. etpinard commented on Aug 19, 2019

    @etpinard
    Contributor

    related: #3487

  2. added
    bug
    on Aug 19, 2019
  3. etpinard commented on Sep 6, 2019

    @etpinard
    Contributor

    Here's a bit more info on the topic.

    Traces with data arrays with length=0 are considered as if they were visible:false. These visible:false traces skip the calc step, so they don't get their _extremes stashes filled and getAutorange exits early. This means that even though axis autorange gets coerced to true, we end up plotting the dflt range:

    if(ax.type === 'date') dflt = Lib.dfltRange(ax.calendar);
    else if(axLetter === 'y') dflt = constants.DFLTRANGEY;
    else dflt = opts.dfltRange || constants.DFLTRANGEX;

    // last resort axis ranges for x and y axes if we have no data
    DFLTRANGEX: [-1, 6],
    DFLTRANGEY: [-1, 4],

    So, I'm thinking we could easily add something like:

            if(ax.rangemode === 'tozero' || ax.rangemode === 'nonnegative') {
                dflt[0] = 0;
            }

    to ax.cleanRange so that the range dflt would be [0, 6] for x-axes and [0, 4] for y-axes when rangemode is set to 'tozero' or 'nonnegative'.

    That said, maybe instead we implement #400 and have users solve this problem by setting xaxis.range or yaxis.range to [0].

  4. alexcjohnson commented on Sep 6, 2019

    @alexcjohnson
    Collaborator

    dflt[0] = 0;

    sounds right to me. this is somewhat independent of #400 for eg. entirely negative axes with tozero or reversed ranges.

  5. self-assigned this
    on Sep 6, 2019
  6. added a commit that references this issue on Sep 6, 2019
    06ee3c0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions