c3js / c3js/c3

Not Getting Position of X, Y for tooltip

Open
#1,514 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.3k
Forks
1.4k
Avg merge
6d 16h
Merged PRs (30d)
1

Description

I want to integrate new tooltip format, but the issue is that i don't found x, y position value of current focus block.
## Following is the Screen shot of my tooltip issue

![screen shot 2015-12-26 at 10 23 28 am](https://cloud.githubusercontent.com/assets/8954405/12005159/f583f3f4-abba-11e5-9117-31c55e81e97f.png)
## Following is the code for position

``` javascript
position: function (data, width, height, element) {
console.log(document.getElementsByClassName('c3-tooltip-container'));
var chartOffsetX = document.querySelector('#chart' + chartId).getBoundingClientRect().left,
graphOffsetX = document.querySelector('#chart' + chartId + " g.c3-axis-y").getBoundingClientRect().right,
tooltipWidth = document.getElementById('tooltip').clientWidth,
tooltipHeight = document.getElementById('tooltip').clientHeight;
x = parseInt(element.getAttribute('cx')) + graphOffsetX - chartOffsetX - Math.floor(tooltipWidth / 2);
y = parseInt(element.getAttribute('cy')) - parseInt(tooltipHeight);
y = y - height - 14;
return {top: y, left: x}
}
```

Contributor guide

Open the contributing guide

Research direction

Start with the tooltip position callback shown in the issue and inspect the data, width, height, and element arguments, along with the SVG element offsets it reads. Done means the position callback can obtain the focused block’s x and y values for the requested tooltip format.

Written by the indexing model from the issue text.

Assessment

Tech stack
d3, javascript
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.