beeware / toga-chart

A matplotlib charting widget for Toga.
BSD 3-Clause "New" or "Revised" License
26 stars 11 forks source link

Rename `Chart._resize` to `Chart.redraw` #19

Closed saroad2 closed 2 years ago

saroad2 commented 2 years ago

The Problem

At the moment, Chart does not allow to redraw the figure manually. However, it is done automatically on resize, using a protected method.

I renamed this protected method to redraw so one could call it manually when needed

Why not simply use Chart.draw?

This reason is that Chart.draw excepts a figure parameter, but that figure might not have the size of the chart. Chart._resize does not except a figure, but it creates a figure that is suitable for the chart size.

Alternative approach

There is an alternative approach that was not taken in this PR: We can add a method named Chart.create_figure() that builds a figure with the right width and height, like it does in the _resize method. Now, one could create a suitable figure and use it in Chart.draw manually.

I think the first solution (which is implemented in this PR) is better.

PR Checklist:

saroad2 commented 2 years ago

This fix seems to cause an infinite loop. I try to understand why