Skip to content

Outside tooltip on bar charts scroll offset not calculated correctly #18635

Description

@runfaj

Actual behaviour

Here's a fiddle I was able to reproduce with https://jsfiddle.net/runfaj/wx2cabpv/1/. Essentially in certain scroll situations, it seems like inverted charts don't calculate the horizontal scroll offset correctly. In this fiddle, if you size the preview pane to about 700 px, so the tiles on the far right need to be scrolled to, then you hover, you'll see the tooltips no longer line up on the points.
image

If you shrink that area so the scroll increased, the problem is exacerbated to where the tooltips are completely out of view.
image

I added a couple examples the the far right and far bottom and it seems there's no issues with non-inverted charts or vertical positioning.

Upon digging in the code, it appears the defaultPositioner in the tooltip is calculated quite differently than what is provided for the getPosition function that is available for the tooltip.positioner. You'll see if you define a positioner in this same fiddle:

positioner(boxWidth, boxHeight, point) {
  const pos = this.getPosition(boxWidth, boxHeight, point);
  return pos;
},

Then the tooltips don't even calculate against the chart container's offset anymore, so the tooltips go haywire on all the tiles.

Since it doesn't appear that the defaultPositioner is working and it also appears to be a completely private method, I don't see any way to fix this issue.

Expected behaviour

Tooltips should always align to the top of the point for columns or to the right of the point for bars (at least in this example). This would be a fix for the defaultPositioner.

Also, it would be helpful potentially to also update the tooltip.positioner call:

  • so the provided point receives the same inputs that the defaultPositioner has available (like the anchorX/Y).
  • update so getPosition matches the same offsetting behavior as the defaultPositioner.

Product version

highcharts 10.3.3

Affected browser(s)

mostly tested in chrome

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions