Comments (7)
Hello There!
As @ppotaczek mentioned, rendering JSX inside the chart elements is a complex topic, and it's not a Highcharts built-in feature. The main problem with dynamic content is that you must provide its proper dimensions to the rendering element, but in general, you can get them once you render an element to the DOM. I updated your example with a potential solution you can refer to: https://codesandbox.io/p/sandbox/highcharts-custom-tooltip-forked-8mq7x5?file=%2Findex.tsx.
The above fixes the described problem, but nevertheless has some performance drawbacks. Note that it's based on the Highcharts tooltip instance, which I find the trickiest solution to implement. I'd recommend basing your solution on the custom instance instead. An example is provided above by @ppotaczek, but also, please refer to this one: https://codesandbox.io/p/sandbox/highcharts-react-demo-fork-forked-ltr9dp?file=%2Fdemo.jsx.
Kind Regards!
from highcharts-react.
Hi @Satyam7Jha,
Thank you for contacting us!
Using React Portals to render custom content in Highcharts tooltip is really tricky, because you need to predict dimensions tooltip's dimensions. I've simplified your logic, so I hope you will be able to adapt the below example to your needs.
Live demo: https://codesandbox.io/p/sandbox/highcharts-react-demo-forked-pp2lwk
As an alternative, you may consider creating your own tooltip from a scrach rather than relying on an existing one.
Best regards!
from highcharts-react.
@ppotaczek How do we create our own tooltip in Highcharts
please do share if there is an example implantation of this custom tooltip
from highcharts-react.
Hi @GowthamTG,
It's a very simple idea, you just need to place your chart and custom tooltip in a relative container and position the tooltip based on a hovered point.
Live example: https://codesandbox.io/p/sandbox/highcharts-react-demo-forked-99z6vf?file=%2Fdemo.jsx%3A13%2C9
Best regards!
from highcharts-react.
Hii @ppotaczek
In this implementation :https://codesandbox.io/p/sandbox/highcharts-custom-tooltip-forked-w46pmz?file=%2Findex.tsx
custom tooltip injected via react portal into
Everything works great until I dynamicaly change size of tooltip content . Highchart tooltip simply does not change size to fit new content.
Case 1: here i first selcted 0th index toolitp which is smaller compare to 1st index toolitp.0th index tooltip is good but 1st index tooltip not able to resize.
Screen.Recording.2023-12-24.at.12.55.25.AM.mov
Case 2: here iam selecting 1th index toolitp which is bigger compare to 0st index toolitp. same issue tooltip stuck to larger size.
Screen.Recording.2023-12-24.at.12.55.53.AM.mov
Could you please help with this.Thanks
from highcharts-react.
Here Custom tooltip injected via react portal into element created by tooltip's formetter() function.Everything works great until I dynamicaly change height of tooltip content . Highchart tooltip simply does not aligned after height is changed.
Expected behaviour
Tooltip should be aligned properly
Actual behaviour
it is only aligned when we hover second time on toolitp
Live demo with steps to reproduce
https://codesandbox.io/p/sandbox/highcharts-custom-tooltip-forked-5sv74k?file=%2Findex.tsx%3A28%2C39
Screen.Recording.2023-12-27.at.12.13.13.AM.mov
Affected browser(s)
All
from highcharts-react.
Thanks
from highcharts-react.
Related Issues (20)
- Vector Plot Availability HOT 2
- Capturing Drawing Values from Technical Analysis with Annotations Chart in React HOT 6
- unable to use highchart with react 18 HOT 6
- Stock chart indicator customization HOT 1
- Question: draw an ellipse on ScatterChart HOT 2
- parliament(item) chart HOT 3
- Wrong Gantt Behaviour On Having Multiple Ids in Series Data. HOT 3
- Donut Chart invisible until after HMR HOT 3
- Rendering simple chart with React Testing Library fails (computes NaN values) HOT 2
- Runtime error when chart tries to update while hovering over a series HOT 4
- Usage in React, Grid lines not visible HOT 2
- Tooltip is going under axis-component HOT 8
- Chart values and options doesn't trigger re-render HOT 2
- Zones rendering issue after updating to [email protected] HOT 5
- Issue whille integrating packedbubble in react-highcharts HOT 15
- TypeError: Cannot read properties of undefined (reading 'length') HOT 1
- Plotbands added via API are not added to plotOptions HOT 2
- Next.js 14.1.0 Cannot read properties of undefined (reading 'document') HOT 2
- Add a react ref to each point HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from highcharts-react.