예제 #1
0
 def test_legend_names_no_label_field(self):
     ''' Tests if legend names are built from series ID in the dataframe '''
     options_from_yaml = {'chart_options': {'id': 'idx'}}
     dataframe = pd.DataFrame([{'idx': 'A'}, {'idx': 'B'}])
     self.assertEqual(
         BaseChart.get_legend_names(dataframe, options_from_yaml), {
             'A': 'A',
             'B': 'B'
         })
예제 #2
0
 def test_legend_names(self):
     ''' Tests if legend names are built from series ID in the dataframe, with
         a mirror legend name specified '''
     options_from_yaml = {
         'chart_options': {
             'legend_field': 'lgnd',
             'id': 'idx'
         }
     }
     dataframe = pd.DataFrame([{
         'idx': 'A',
         'lgnd': 'A_lbl'
     }, {
         'idx': 'B',
         'lgnd': 'B_lbl'
     }])
     self.assertEqual(
         BaseChart.get_legend_names(dataframe, options_from_yaml), {
             'A': 'A_lbl',
             'B': 'B_lbl'
         })
예제 #3
0
 def test_legend_names_no_id_field(self):
     ''' Tests if no legend names are returned when no ID field is given '''
     options_from_yaml = {'chart_options': {'legend_field': 'lgnd'}}
     dataframe = pd.DataFrame([{'idx': 'A'}, {'idx': 'B'}])
     self.assertEqual(
         BaseChart.get_legend_names(dataframe, options_from_yaml), {})
예제 #4
0
 def test_legend_names_empty_dataframe(self):
     ''' Tests if no legend names are returned when the dataframe is empty '''
     options_from_yaml = {'chart_options': {'id': 'idx'}}
     self.assertEqual(
         BaseChart.get_legend_names(pd.DataFrame([]), options_from_yaml),
         {})
예제 #5
0
 def test_legend_names_no_dataframe(self):
     ''' Tests if no legend names are returned when there's no dataframe '''
     options_from_yaml = {'chart_options': {'id': 'idx'}}
     self.assertEqual(BaseChart.get_legend_names(None, options_from_yaml),
                      {})
예제 #6
0
 def test_legend_names_no_chart_options(self):
     ''' Tests if no legend names are returned when there's no chart_options '''
     dataframe = pd.DataFrame([{'idx': 'A'}, {'idx': 'B'}])
     self.assertEqual(BaseChart.get_legend_names(dataframe, {}), {})