xanderdeseyn / react-native-responsive-linechart

A customizable and responsive line or area chart for react-native
https://react-native-responsive-linechart.surge.sh
MIT License
202 stars 46 forks source link

Any way for native tooltip to overflow chart container? #37

Closed rwhitten577 closed 3 years ago

rwhitten577 commented 3 years ago

Hi there, thanks for this library. Works great for me so far, but I'm having trouble getting the tooltips at the end of the x or y axis to overflow and they are getting cut off. Is there any way to do this with the native Tooltip component? Thanks!

IMG_442D4D9589E4-1

xanderdeseyn commented 3 years ago

Hi, unfortunately SVG does not allow overflow outside of the parent container. I'll have to think about some clever way to move the tooltip component out of the chart svg. I'll look into it this week!

xanderdeseyn commented 3 years ago

I've fixed it so it works as long as you don't define a custom viewBox (scrolling chart actually takes advantage of this non overflow property, so tooltips will still be cut off there). Check out v5.3.0 👍

Don't forget to set a padding on the component, so the tooltip can overflow into the padding!

rwhitten577 commented 3 years ago

Awesome, thanks for your help!

davidruisinger commented 3 years ago

@N1ghtly any chance the scatter could overflow as well? I have a round scatter for selection only which is currently cut of with the chart:

Bildschirmfoto 2020-12-20 um 10 46 17
xanderdeseyn commented 3 years ago

@flavordaaave ah yes, good catch, I will fix that tomorrow.

xanderdeseyn commented 3 years ago

@flavordaaave Fixed in v5.3.2

D-Navadiya commented 3 years ago

Having the same issue, it's still not working for me on android. Am I missing something?

Screenshot_1614672539 Screenshot_1614672641

xanderdeseyn commented 3 years ago

You have to supply enough padding for the tooltip to overflow "into" (on component)

D-Navadiya commented 3 years ago

@N1ghtly , thanks for the reply.

Okay, so if there is a long tooltip text then I will have to give it a lot of padding, right?

and if I do give it a big padding, it will result in smaller chart, no?

I am sorry if I am not getting it right.

xanderdeseyn commented 3 years ago

That's correct.

D-Navadiya commented 3 years ago

Okay, understood,

do you think that it is possible to implement some positioning logic (using dx,dy & position prop)?

if you think it's worth, let me know, I will try and have a PR ready.

Thanks :)

xanderdeseyn commented 3 years ago

Definitely possible, the supplied Tooltip component is quite simple & "dumb" at the moment haha :)

D-Navadiya commented 3 years ago

Haha, nice one, I'll see what I can do,

Thank you so much :)

faizantariq1 commented 2 years ago

HI @rwhitten577 how did you apply dates on the scrollable chart?

rwhitten577 commented 2 years ago

@faizantariq1 convert your data values to a Unix timestamp, then use the label formatter function to convert it back to a date string in the format you want, e.g. formatter: (v: number) => moment(v).format("MMM DD")

https://react-native-responsive-linechart.surge.sh/docs/horizontalaxis#horizontalaxis-default-theme

faizantariq1 commented 2 years ago

@rwhitten577 thankx, i'm doing the same. but want to use the infinite scroll so using the view port with width(which is not adjusting correctly), so when i removed the viewport it's working fine. giving a very short value in viewport