toga-chart icon indicating copy to clipboard operation
toga-chart copied to clipboard

Future-proof Chart against changing Toga Widget initialization

Open HalfWhitt opened this issue 1 year ago • 4 comments

Updates Chart to play nice with the restructured Widget initialization in https://github.com/beeware/toga/pull/2942, while staying backwards compatibile with Toga 0.4.8.

I realize that PR may or may not change significantly before merging; this is for its current form as of https://github.com/beeware/toga/pull/2942/commits/c4db37f5a5c82bf1a4ba7ea51351803e803239fd, and I can amend as needed.

PR Checklist:

  • [x] All new features have been tested
  • [x] All new features have been documented
  • [x] I have read the CONTRIBUTING.md file
  • [x] I will abide by the code of conduct

HalfWhitt avatar Nov 20 '24 04:11 HalfWhitt

So this works with updated Toga now, but a Matplotlib change is an issue.

Looks like we're calling an internal method, _get_text_path_transform, which no longer exists:

https://github.com/beeware/toga-chart/blob/0d6bf0359680f86ca68f1ee861e1d831d578bca1/src/toga_chart/chart.py#L195-L202

I've not yet looked into it enough to know the best way to adapt.

(Strangely, even when I remove that call, I start seeing weird layout breaks from resizing, like in #191, but without any console errors. May or may not be caused by this same spot in the code, one way or another.)

HalfWhitt avatar Mar 14 '25 03:03 HalfWhitt

So this works with updated Toga now, but a Matplotlib change is an issue.

Looks like we're calling an internal method, _get_text_path_transform, which no longer exists:

Looking at the PR that removed the method - the naive approach would seem to be _draw_text_as_path - the only complication is working out how to get a graphic context.

On a semi-related notes - I seem to recall hitting an issue with a matplotlib update a few months back that would cause issues when the chart is on option container and isn't visible. At the time, the "fix" was to pin an older version of matplotlib, but if we're updating the version, it might be worth checking this as well.

freakboy3742 avatar Mar 14 '25 03:03 freakboy3742

Speaking of updating versions and matplotlib, shouldn't toga-chart declare a dependency on matplotlib, I imagine?

HalfWhitt avatar Mar 14 '25 13:03 HalfWhitt

Speaking of updating versions and matplotlib, shouldn't toga-chart declare a dependency on matplotlib, I imagine?

Um... yes it should... how has that gone unnoticed?!

Looking through my archives, my demo projects using toga-chart have always declared the dependency on matplotlib, so it's always worked.

freakboy3742 avatar Mar 16 '25 22:03 freakboy3742

Thanks for handling this, Russ!

(I've been rather preoccupied the last couple of weeks, but I do still exist.) 😉

HalfWhitt avatar Apr 22 '25 11:04 HalfWhitt

Thanks for handling this, Russ!

No problem at all - I hit some issues updating some presentations for PyConUS, which forced the issue.

freakboy3742 avatar Apr 22 '25 21:04 freakboy3742