MeetzhDing opened a new issue, #16908:
URL: https://github.com/apache/echarts/issues/16908
### What problem does this feature solve?
When custom tooltip with appendWithBody and position callback, we want place
tooltip along with cursor.
We try to get tooltip position with dom.getBoundingClientRect but it will
flash bacause it`s rect is changed with position callback.
eg
```typescript
position: (point, params, dom: HTMLDivElement, rect, size) => {
const { contentSize } = size;
const [contentWidth, contentHeight] = contentSize;
const tooltipDomRect = dom?.getBoundingClientRect?.();
const offsetX = tooltipDomRect?.x + contentWidth + 20 >
window.innerWidth ? -20 - contentSize[0] : 20;
const offsetY = tooltipDomRect?.bottom > window.innerHeight ? -20 -
contentSize[1] : 20;
console.log(tooltipDomRect, contentSize, offsetX, offsetY, rect,
point);
return [point[0] + offsetX, point[1] + offsetY];
},
```
If we have canvas rect info , calculating cursor global position will be
easier using `canvasRect.x + point[0]` and `canvasRect.y + point[1]`.
We can calculate tooltip position by cursor global position and
window.innerWidth/innerHeight.
### What does the proposed API look like?
just like
```ts
position: (point, params, dom: HTMLDivElement, rect, size, canvasRect)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]