◐ Shell
clean mode source ↗

Increase axis autorange when bars have outside text labels by emilykl · Pull Request #7675 · plotly/plotly.js

Adds a step during bar calc to add extra padding to axis range if bar has outside text labels.

Note: The first commit in this PR is just formatting changes. Use this diff to skip the first commit and see only the meaningful changes.

This is a stopgap fix for the fact that text labels are not taken into account during autorange calculations (see #2000).

Unfortunately, as discussed in that issue, modifying autorange to account for text labels is a significant amount of work, so I've opted for a more limited fix to address the issue identified in #2001.

{
    "data": [
        {
            "type": "bar",
            "orientation": "v",
            "x": ["A", "B", "C"],
            "y": [100, 250, -95],
            "base": [100, 100, 100],
            "texttemplate": "%{y}<br>units",
            "textposition": "outside",
        },
    ],
    "layout": {
    }
}

Verify that it looks like the "before" picture on master and the "after" picture on this branch.

You can also load the hist_stacked mock in the devtools as another test case.