plotly / plotly/plotly.js

[BUG]: `shape.pattern` for bar trace causes color and pattern to be applied to wrong traces in unified hover tooltip

Open
#8,008 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good for agent P3 size: 1
Dominant language
JavaScript
Stars
18.3k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
28

Description

Description

When shape.pattern is provided as an array to a bar trace, the first bar's pattern (and color!) are incorrectly applied to both bars in the hovermode: 'x unified' hover tooltip.

Expected: Swatch in hover tooltip should match color and pattern of bar which is being hovered over.

Actual: Swatch in hover tooltip matches color and pattern of first bar in trace, even when hovering over the second bar.

When shape.pattern is not provided, each hover tooltip correctly shows the color of the bar that's being hovered over.

Screenshots/Video
Image
Steps to reproduce

Codepen: https://codepen.io/emilykl-code/pen/azJvXPy

Code:

var fig = {
  "data": [
    {
      "marker": {
        "color": ["red", "purple"],
        "pattern": {"shape": ["/", ""]}
      },
      "textposition": "outside",
      "x": ["A", "B"],
      "y": [1, 2],
      "type": "bar"
    }
  ],
  "layout": {
    "hovermode": "x unified",
    "title": {
      "text": "Hover over 'B' to see wrong color and pattern"
    }}
};
Plotly.newPlot("div1", fig.data, fig.layout);
Notes

First reported in plotly.py by https://github.com/plotly/plotly.py/issues/4882

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CodePen reproduction and the Plotly.newPlot configuration using hovermode: 'x unified', marker.color, and marker.pattern. Trace how the unified hover tooltip chooses each bar's swatch, then verify that hovering over A and B shows the matching color and pattern for each bar.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.