Wrong ```Tooltip``` positioning
- Dominant language
- TypeScript
- Stars
- 1.1k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
I have a problem with `````` component. When I go with the mouse over a node, tooltip appears in the canvas, but it has wrong position. It is not set relative to the node, but only relative to one of the dimension.
You can see better from the attached images.
In the photos i set a blue border on ```#graphin-container``` ```


With this configuration:
The tooltip is placed down of the upper side of the container. The `left` css property of the tooltip is correctly update, as you can see from figure 1 and 2. What didn't get update is ```top``` property. The tooltip didn't get set relative to the node but relative to the container border.
In figure 3 you can see the positioning with respect to following configuration
```
```

Tooltip ```top``` css property is correctly set, but here, ```left``` css property of the tooltip it's not update, and the tooltip instead of being positioned relative to the node is positioned relative to the left side of the graph container.
**To Reproduce**
Unfortunately I didn't manage to reproduce this issue in a codesandbox.
**Expected behavior**
I would expect the tooltip being relative to the hovered node.
**Desktop (please complete the following information):**
- Browser chrome, firefox
Graphin version is the latest:
- "@ant-design/icons": "^4.3.0",
- "@antv/graphin": "^2.0.7",
- "@antv/graphin-components": "^2.0.7",
- "@antv/graphin-icons": "^1.0.0",
**Additional context**
I saw this warning appear in the console after the first mounting of the ``````. This is shown with ```placement={"bottom"}``` configuration. `top` is exactly the property that cause the bug, have you any ideas on what can affect this? I suspect solving this warning the bug would be solved.
```
Warning: `NaN` is an invalid value for the `top` css style property.
in div (created by Tooltip)
in Tooltip (at VisualGraph.jsx:92)
in div (created by Graphin)
in div (created by Graphin)
in Graphin (at VisualGraph.jsx:81)
in VisualGraph (at PatternsAndClassesScreen.jsx:42)
in div (created by GridColumn)
in GridColumn (at PatternsAndClassesScreen.jsx:34)
in div (created by Grid)
in Grid (at PatternsAndClassesScreen.jsx:33)
in div (at ODPReactorContainer.jsx:4)
in ODPReactorContainer (at PatternsAndClassesScreen.jsx:29)
in PatternsAndClassesScreen (at WithFilterPatternAndClassesScreen.jsx:13)
in div (at FilteringShowingJustOneKeyConceptPerView.jsx:90)
in FilteringShowingJustOneKeyConceptPerView (at WithFilterPatternAndClassesScreen.jsx:12)
in div (at FilteringResource.jsx:17)
in FilteringResource (at WithFilterPatternAndClassesScreen.jsx:11)
in WithFilterPatternAndClassesScreen (at PatternsAndClassesPage.jsx:28)
in LayoutCtxProvider (at PatternsAndClassesPage.jsx:27)
in FilterCtxProvider (at PatternsAndClassesPage.jsx:23)
in AlertCtxProvider (at PatternsAndClassesPage.jsx:22)
in HelpCtxProvider (at PatternsAndClassesPage.jsx:21)
in KGCtxProvider (at PatternsAndClassesPage.jsx:20)
in PatternsAndClassesPage (at SwitchContainer.jsx:23)
in div (at KnowledgeGraphSchemaPreprocessing.jsx:15)
in KnowledgeGraphSchemaPreprocessing (at SwitchContainer.jsx:22)
in div (at KnowledgeGraphSchemaFetching.jsx:22)
in KnowledgeGraphSchemaFetching (at SwitchContainer.jsx:21)
in SparqlCtxProvider (at SwitchContainer.jsx:20)
in Route (at SwitchContainer.jsx:19)
in Switch (at SwitchContainer.jsx:18)
in SwitchContainer (at ODPReactorGraphRoot.jsx:11)
in Router (created by BrowserRouter)
in BrowserRouter (at ODPReactorGraphRoot.jsx:10)
in ODPReactorGraphRoot (at App.js:6)
in div (at App.js:5)
in App (at src/index.js:9)
in StrictMode (at src/index.js:8)
```
Here the code i use to create the graphin graph:
```
export default function CustomGraph({ visualGraph = [] }) {
// graphRef for mix React virtual DOM and graphin imperative operation on DOM
const graphRef = useRef(null);
const [showTooltip, setShowTooltip] = useState(
true
);
const defaultLayout = {
type: "graphin-force",
preset: {
type: "concentric",
},
animation: false,
preventOverlap: true,
defSpringLen: (_edge, source, target) => {
// const nodeSize = 30;
// const Sdegree = sorgente.dati.layout.laurea;
// const Tdegree = target.dati.layout.laurea;
// const minDegree = Math.min(Sdegree, Tdegree);
// console.log(minDegree < 3 ? nodeSize * 5 : minDegree * nodeSize);
return 280;
// return minDegree < 3 ? nodeSize * 5 : minDegree * nodeSize ;
},
};
const nodeStateStyles = {
status: {
hover: {
label: {
visible: false,
},
},
},
};
return (
{showTooltip && (
{(model) => {
if (model.data.type === "Class") {
return (
Entity:
{model.data.label}
Description:{" "}
{model.data.description}
Relevance:{" "}
{model.data.scaledCentralityScore.toFixed(
2
)}
Double click to view entities...
);
}
if (model.data.type === "Pattern") {
return (
View:
{model.data.label}
Description:{" "}
{model.data.tooltipInfo}
Occurences:{" "}
{model.data.occurences}
Double click to view entities...
);
}
}}
)}
{
setShowTooltip(data.checked);
}}
label={Enable node explanations}
/>
);
}
```
Contributor guide
Assessment
This issue has not been assessed yet.