Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show custom data on Tooltip from both axis #38

Closed
sukhcha-in opened this issue Jul 8, 2019 · 9 comments
Closed

Show custom data on Tooltip from both axis #38

sukhcha-in opened this issue Jul 8, 2019 · 9 comments

Comments

@sukhcha-in
Copy link

Hello, Can we pass custom data to Tooltip?
For example i want to show 5 Jul: ₹200 on tooltip instead of 200.0
Like i also want to grab some data from horizontal axis to show date and also the price from vertical axis.

To achieve this i think i have to pass all of my hotizontal axis values and then onLongPress i have to get data from it.
If i add all of my Date data to horizontal axis, it gets overlapped.
Like this:
Demo
Can you please add option to set how many values developer wants to show on chart, so that remaining values remain hidden instead of overlapping? Same thing on vertical axis will be a PlusPlus.

@imaNNeo
Copy link
Owner

imaNNeo commented Jul 8, 2019

Hi,
Does it help you?

If yes, check the source code,
I didn't get your next question.

@sukhcha-in
Copy link
Author

Thank you i have figured out both things.

@enricobenedos
Copy link

enricobenedos commented Sep 6, 2019

Hi guys, if you want I can create a new issue but I think we can reuse this one.
I have a problem with the tooltip values. I'm trying to change the numeric value mantaining the beautiful standard text color.
This is my chart:
image
It is perfect, I need only to apply this formula to the two double values: (value*5)/100.
I've tried to do that using the TouchTooltipData class but I don't understand how to mantain the two original colors.
Can anyone please help me?

@imaNNeo
Copy link
Owner

imaNNeo commented Sep 6, 2019

Hi @enricobenedos, do you want to change the opacity of the tooltip texts color?

@enricobenedos
Copy link

Hi, I need to know how to change the tooltip value. For example from 2.5 to 25, but maintaining the text style.

@imaNNeo
Copy link
Owner

imaNNeo commented Sep 7, 2019

Ok, got it, check this sample, we changed the text of tooltip, (this is a bar chart, but the tooltip is the same in the line chart)
@enricobenedos

@enricobenedos
Copy link

I already tried this. It works but in this way I will lose the inherited text style. In my case 3.025 --> blue and 2.5 --> green

@imaNNeo
Copy link
Owner

imaNNeo commented Sep 10, 2019

I know, but you can set any TextStyle with a custom color that you want in the TooltipItem,
I use the line color for showing related text, you can do it by yourself.
Does it make sense?

@enricobenedos
Copy link

It make sense! My problem was the colors, now finally I understood how to retrieve the colors calling touchedSpot.getColor()

lineTouchData: LineTouchData(touchTooltipData:
                                      TouchTooltipData(
                                          getTooltipItems: (touchedSpots) {
                                    return touchedSpots.map((touchedSpot) {
                                      return TooltipItem(
                                          touchedSpot.spot.y.toString(),
                                          TextStyle(
                                              color: touchedSpot.getColor(),
                                              fontWeight: FontWeight.bold));
                                    }).toList();
                                  })),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants