Ejemplo n.º 1
0
 def show_bar(self, line):
     # Draw Bars
     try:
         if len(self._std.get_gender()) == 0 or len(
                 self._std.get_gender()) == 0:
             raise ValueError("No data to display.")
         # Draw gender
         if line.upper() == Data.GENDER.name:
             View.plot_bar(self._std.get_gender(), "Gender Distribution")
         # Draw BMI
         if line.upper() == Data.BMI.name:
             View.plot_bar(self._std.get_bmi(), "Body Mass Index (BMI)")
     except ValueError as e:
         View.info(e)
     except Exception as e:
         View.error(e)
Ejemplo n.º 2
0
 def show_bar(self, line):
     """
     Draw bar chart
     :param line: String
     :return: None
     :Author: Zhiming Liu
     """
     # Draw Bars
     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_bar(self._std.get_gender().formatted_data,
                           "Gender Distribution", "numer of people")
         # Draw BMI
         if line.upper() == Data.BMI.name:
             View.plot_bar(self._std.get_bmi(), "Body Mass Index (BMI)",
                           "number of people")
     except ValueError as e:
         View.info(e)
     except Exception as e:
         View.error(e)