May 2018
Beginner to intermediate
452 pages
11h 26m
English
In the Application class, create a new method for showing our chart:
def show_growth_chart(self):
data = self.data_model.get_growth_by_lab()
max_x = max([x['day'] for x in data])
max_y = max([x['avg_height'] for x in data])
The first order of business is to fetch data from our get_growth_by_lab() method and calculate the maximum values for the x and y axes. We've done this by using list comprehensions to extract values into lists and calling the built-in max() function on it.
Next, we'll build a widget to hold our LineChartView object:
popup = tk.Toplevel()
chart = v.LineChartView(popup, 600, 300, 'day',
'centimeters', max_x, max_y)
chart.pack(fill='both', expand=1)
We're using the Toplevel widget in this case, ...