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

touchedSpot.getColor() doesn't exist from v0.4.0 #197

Closed
enricobenedos opened this issue Feb 10, 2020 · 3 comments
Closed

touchedSpot.getColor() doesn't exist from v0.4.0 #197

enricobenedos opened this issue Feb 10, 2020 · 3 comments
Labels
Line Chart question Further information is requested

Comments

@enricobenedos
Copy link

I'm updating the version of my fl_chart reference from 0.3.4 to 0.4.0.
Thanks to a very well written changelog I was able to solve all the issue related to classes renaming. But I'm not able to understand how to refactor the touchedSpot.getColor() line (suggested on #38):
Old working code:

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

New refactored code with no working getColor() :

lineTouchData: LineTouchData(
                                              touchTooltipData:
                                                  LineTouchTooltipData(
                                                      getTooltipItems:
                                                          (touchedSpots) {
                                            return touchedSpots
                                                .map((touchedSpot) {
                                              return LineTooltipItem(
                                                  _deconvertPercValue(
                                                          touchedSpot.y)
                                                      .toStringAsFixed(1),
                                                  TextStyle(
                                                      color: touchedSpot.bar. 
                                                          .getColor(), //not working
                                                      fontWeight:
                                                          FontWeight.bold));
                                            }).toList();
                                          })),
@enricobenedos enricobenedos changed the title touchedSpot.getColor() doesn't exist after v0.4.0 touchedSpot.getColor() doesn't exist from v0.4.0 Feb 10, 2020
@enricobenedos
Copy link
Author

enricobenedos commented Feb 10, 2020

Comparing 3.4.0 with 0.4.0 I see that getColor() was removed and this was the implementation

@override
  Color getColor() {
    return barData.colors[0];
  }

I can guess that now I need to write
color: touchedSpot.bar.colors[0],
Is it correct or I need to make something different?

@imaNNeo
Copy link
Owner

imaNNeo commented Feb 10, 2020

Yes, exactly you are right.
use color: touchedSpot.bar.colors[0]
also, you have the barIndex and spotIndex to do what you want.

@imaNNeo imaNNeo added Line Chart question Further information is requested labels Feb 10, 2020
@imaNNeo
Copy link
Owner

imaNNeo commented Feb 10, 2020

Feel free to close it if you've got the answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Line Chart question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants