Giter VIP home page Giter VIP logo

Comments (7)

KamilKubik avatar KamilKubik commented on July 21, 2024 1

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.

ppotaczek avatar ppotaczek commented on July 21, 2024

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.

GowthamTG avatar GowthamTG commented on July 21, 2024

@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.

ppotaczek avatar ppotaczek commented on July 21, 2024

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.

Satyam7Jha avatar Satyam7Jha commented on July 21, 2024

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

element created by tooltip's formetter() function.

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.

Satyam7Jha avatar Satyam7Jha commented on July 21, 2024

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.

Satyam7Jha avatar Satyam7Jha commented on July 21, 2024

Thanks

from highcharts-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.