Exemplo n.º 1
0
 def show_pie(self, line):
     # Draw Pies
     try:
         if len(self._std.get_gender()) == 0 or len(
                 self._std.get_bmi()) == 0:
             raise ValueError("No data to display.")
         # Draw gender
         if line.upper() == Data.GENDER.name:
             View.plot_pie(self._std.get_gender(), "Gender Distribution")
         # Draw BMI
         if line.upper() == Data.BMI.name:
             View.plot_pie(self._std.get_bmi(), "Body Mass Index (BMI)")
     except ValueError as e:
         View.info(e)
     except Exception as e:
         View.error(e)
Exemplo n.º 2
0
 def show_pie(self, line):
     """
     Draw pie chart
     :param line: String
     :return: None
     :Author: Zhiming Liu
     """
     # Draw Pies
     try:
         if self._std.get_gender().total_count == 0 \
                 or len(self._std.get_bmi()) == 0:
             raise ValueError("No data to display.")
         # Draw gender
         if line.upper() == Data.GENDER.name:
             View.plot_pie(self._std.get_gender().formatted_data,
                           "Gender Distribution", "People")
         # Draw BMI
         if line.upper() == Data.BMI.name:
             View.plot_pie(self._std.get_bmi(), "Body Mass Index (BMI)",
                           "People")
     except ValueError as e:
         View.info(e)
     except Exception as e:
         View.error(e)