app/search_page.py
def view_statistic_graph(self):
        """Show diagram representing dependency between
        fighter's age and amount of fights that he fought."""

        ######### check if any fighter has been selected
        selected_option = self.fighters_list.curselection()
        if not selected_option:
            messagebox.showerror(
                title="Graph",
                message="You have to choose a fighter in order to do that!"
            )
            return


        ######### get his name from db & grab his info
        person = self.fighters_list.get(selected_option)
        person_in_base = f"{person.split()[1]} {person.split()[2]}"

        for fighter in DatabaseManager().return_fighter_names():
            if person_in_base in fighter[0]:
                person_in_base = fighter[0]
                break

        fighter_info = DatabaseManager(
            ).return_fighter_info(fighter_name=person_in_base)
        fighter_career_history = DatabaseManager(
            ).return_fighter_career_history(fighter_name=person_in_base)


        ######### create x and y coordinates for graph
        born_in_year = int(fighter_info[7].split('-')[0])
        age_and_amount_of_fights = dict()

        for amount_of_fights, fight in enumerate(reversed(fighter_career_history)):
            amount_of_fights += 1

            fight_in_year = int(fight[4].split('/')[2])
            age_at_this_fight = fight_in_year - born_in_year

            # dict = age at actual fight (key) : amount of fights (value)
            age_and_amount_of_fights[age_at_this_fight] = amount_of_fights


        ######### create and adjust graph
        style_based_on_actual_theme = utilities.colors_dict(
            theme=self.themes_list.get(), file='SEARCH_PAGE')['graph']
        plt.style.use(style_based_on_actual_theme)

        plt.figure(figsize=(9, 5))
        plt.plot(
            age_and_amount_of_fights.keys(),            # age
            age_and_amount_of_fights.values(),          # amount of fights
            color='#0077ff', marker='s', markersize=7,
        )
        plt.title(
            label=person_in_base, y=1.04,
            font='Arial', fontsize='20', fontweight='bold',
        )
        plt.xlabel("Age", fontsize='14')
        plt.ylabel("Amount Of Fights", fontsize='14', labelpad=17)
        plt.tick_params(labelsize=13)
        plt.show()
Show diagram representing dependency between
        fighter's age and amount of fights that he fought.
Show diagram representing dependency between
fighter's age and amount of fights that he fought.
Show diagram representing dependency between fighter ' s age and amount of fights that he fought .
def view_statistic_graph(self):
        selected_option = self.fighters_list.curselection()
        if not selected_option:
            messagebox.showerror(
                title="Graph",
                message="You have to choose a fighter in order to do that!"
            )
            return
        person = self.fighters_list.get(selected_option)
        person_in_base = f"{person.split()[1]} {person.split()[2]}"
        for fighter in DatabaseManager().return_fighter_names():
            if person_in_base in fighter[0]:
                person_in_base = fighter[0]
                break
        fighter_info = DatabaseManager(
            ).return_fighter_info(fighter_name=person_in_base)
        fighter_career_history = DatabaseManager(
            ).return_fighter_career_history(fighter_name=person_in_base)
        born_in_year = int(fighter_info[7].split('-')[0])
        age_and_amount_of_fights = dict()
        for amount_of_fights, fight in enumerate(reversed(fighter_career_history)):
            amount_of_fights += 1
            fight_in_year = int(fight[4].split('/')[2])
            age_at_this_fight = fight_in_year - born_in_year
            age_and_amount_of_fights[age_at_this_fight] = amount_of_fights
        style_based_on_actual_theme = utilities.colors_dict(
            theme=self.themes_list.get(), file='SEARCH_PAGE')['graph']
        plt.style.use(style_based_on_actual_theme)
        plt.figure(figsize=(9, 5))
        plt.plot(
            age_and_amount_of_fights.keys(),            
            age_and_amount_of_fights.values(),          
            color='#0077ff', marker='s', markersize=7,
        )
        plt.title(
            label=person_in_base, y=1.04,
            font='Arial', fontsize='20', fontweight='bold',
        )
        plt.xlabel("Age", fontsize='14')
        plt.ylabel("Amount Of Fights", fontsize='14', labelpad=17)
        plt.tick_params(labelsize=13)
        plt.show()
def view_statistic_graph ( self ) : selected_option = self . fighters_list . curselection ( ) if not selected_option : messagebox . showerror ( title = "Graph" , message = "You have to choose a fighter in order to do that!" ) return person = self . fighters_list . get ( selected_option ) person_in_base = f"{person.split()[1]} {person.split()[2]}" for fighter in DatabaseManager ( ) . return_fighter_names ( ) : if person_in_base in fighter [ 0 ] : person_in_base = fighter [ 0 ] break fighter_info = DatabaseManager ( ) . return_fighter_info ( fighter_name = person_in_base ) fighter_career_history = DatabaseManager ( ) . return_fighter_career_history ( fighter_name = person_in_base ) born_in_year = int ( fighter_info [ 7 ] . split ( '-' ) [ 0 ] ) age_and_amount_of_fights = dict ( ) for amount_of_fights , fight in enumerate ( reversed ( fighter_career_history ) ) : amount_of_fights += 1 fight_in_year = int ( fight [ 4 ] . split ( '/' ) [ 2 ] ) age_at_this_fight = fight_in_year - born_in_year age_and_amount_of_fights [ age_at_this_fight ] = amount_of_fights style_based_on_actual_theme = utilities . colors_dict ( theme = self . themes_list . get ( ) , file = 'SEARCH_PAGE' ) [ 'graph' ] plt . style . use ( style_based_on_actual_theme ) plt . figure ( figsize = ( 9 , 5 ) ) plt . plot ( age_and_amount_of_fights . keys ( ) , age_and_amount_of_fights . values ( ) , color = '#0077ff' , marker = 's' , markersize = 7 , ) plt . title ( label = person_in_base , y = 1.04 , font = 'Arial' , fontsize = '20' , fontweight = 'bold' , ) plt . xlabel ( "Age" , fontsize = '14' ) plt . ylabel ( "Amount Of Fights" , fontsize = '14' , labelpad = 17 ) plt . tick_params ( labelsize = 13 ) plt . show ( )
Show diagram representing dependency between
fighter's age and amount of fights that he fought.
Show diagram representing dependency between fighter ' s age and amount of fights that he fought .
"""Show diagram representing dependency between
        fighter's age and amount of fights that he fought.""" ######### check if any fighter has been selected ######### get his name from db & grab his info ######### create x and y coordinates for graph # dict = age at actual fight (key) : amount of fights (value) ######### create and adjust graph # age # amount of fights
self