示例#1
0
 def test_ctor(self):
     from openpyxl.chart import Axis, Legend
     from openpyxl.drawing import Drawing
     c = Chart(None, None)
     eq_(c.type, None)
     eq_(c.grouping, None)
     assert_true(isinstance(c.x_axis, Axis))
     assert_true(isinstance(c.y_axis, Axis))
     assert_true(isinstance(c.legend, Legend))
     eq_(c.show_legend, True)
     eq_(c.lang, 'fr-FR')
     eq_(c.title, '')
     eq_(c.print_margins, {
         'b': .75,
         'l': .7,
         'r': .7,
         't': .75,
         'header': 0.3,
         'footer': .3
     })
     assert_true(isinstance(c.drawing, Drawing))
     eq_(c.width, .6)
     eq_(c.height, .6)
     eq_(c.margin_top, c._get_max_margin_top())
     eq_(c.margin_left, 0)
     eq_(c._shapes, [])
示例#2
0
 def test_computer_xmin_xmax(self):
     c = Chart(None, None)
     s = Serie(self.range, xvalues=self.range)
     c._series.append(s)
     c._compute_xmin_xmax()
     eq_(c.x_axis.max, 2.0)
     eq_(c.x_axis.unit, 1.0)
    def test_mymin(self):
        c = Chart()
        eq_(c.mymin(range(10)), 0)
        from string import ascii_letters as letters

        eq_(c.mymin(list(letters)), "A")
        eq_(c.mymin(range(-10, 1)), -10)
        eq_(c.mymin([""] * 10), "")
 def test_compute_series_max_dates(self):
     ws = self.make_worksheet()
     for i in range(1, 10):
         ws.append([date(2013, i, 1)])
     c = Chart()
     ref = Reference(ws, (0, 0), (9, 0))
     series = Serie(ref)
     c._series.append(series)
     mini, maxi = c._get_extremes()
     eq_(mini, 0)
     eq_(maxi, 41518.0)
示例#5
0
 def test_ctor(self):
     from openpyxl.chart import Axis, Legend
     from openpyxl.drawing import Drawing
     c = Chart(None, None)
     eq_(c.type, None)
     eq_(c.grouping, None)
     assert_true(isinstance(c.x_axis, Axis))
     assert_true(isinstance(c.y_axis, Axis))
     assert_true(isinstance(c.legend, Legend))
     eq_(c.show_legend, True)
     eq_(c.lang, 'fr-FR')
     eq_(c.title, '')
     eq_(c.print_margins,
         {'b':.75, 'l':.7, 'r':.7, 't':.75, 'header':0.3, 'footer':.3}
         )
     assert_true(isinstance(c.drawing, Drawing))
     eq_(c.width, .6)
     eq_(c.height, .6)
     eq_(c.margin_top, c._get_max_margin_top())
     eq_(c.margin_left, 0)
     eq_(c._shapes, [])
示例#6
0
 def test_get_min_margin_left(self):
     c = Chart(None, None)
     c._series.append(self.range)
     eq_(c._get_min_margin_left(), 1.2857142857142858)
示例#7
0
 def test_get_max_margin_top(self):
     c = Chart(None, None)
     eq_(c._get_max_margin_top(), 0.21250000000000005)
示例#8
0
 def test_compute_min_max(self):
     c = Chart(None, None)
     c._series.append(self.range)
     c._compute_min_max()
     eq_(c.y_axis.max, 2.0)
     eq_(c.y_axis.unit, 1.0)
示例#9
0
 def test_get_y_char(self):
     c = Chart(None, None)
     c._series.append(self.range)
     eq_(c.get_y_chars(), 1)
示例#10
0
 def test_get_y_unit(self):
     c = Chart(None, None)
     c._series.append(self.range)
     c.y_axis.max = 10
     eq_(c.get_y_units(), 109728.0)
示例#11
0
 def test_get_x_unit(self):
     c = Chart(None, None)
     c._series.append(self.range)
     eq_(c.get_x_units(), 10)
示例#12
0
 def test_mymax(self):
     c = Chart(None, None)
     eq_(c.mymax(range(10)), 9)
     from string import letters
     eq_(c.mymax(list(letters)), "z")
 def test_set_margin_left(self):
     c = Chart()
     c._series.append(self.range)
     c.margin_left = 0
     eq_(c.margin_left, 0.03375)
 def test_set_margin_top(self):
     c = Chart()
     c.margin_top = 1
     eq_(c.margin_top, 0.31)
 def test_compute_series_extremes(self):
     c = Chart()
     c._series.append(self.range)
     mini, maxi = c._get_extremes()
     eq_(mini, 0)
     eq_(maxi, 1.0)