Skip to content

Commit

Permalink
Fix some padding
Browse files Browse the repository at this point in the history
  • Loading branch information
katerina7479 committed Jul 16, 2014
1 parent 36c0f28 commit caae833
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pypdflite/pdfobjects/pdfgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _set_accessories(self, title, width, height):
if title is None:
self.padding = (self.background.padding * width, self.background.padding * height)
else:
self.padding = (self.background.padding * width, (self.background.padding * 1.2 * height))
self.padding = (self.background.padding * width, (self.background.padding * height + 0.13 * height))

def _draw_background(self, width, height):
if self.background.exists:
Expand Down Expand Up @@ -102,6 +102,8 @@ def draw_axis_titles(self, x_title=None, y_title=None):
PDFText(self.session, self.page, x_title, cursor=label_cursor_x)

if y_title is not None:
if self.padding[0] == 0:
self.padding = (self.width * 0.12, self.padding[1])
label_cursor_y = PDFCursor(self.origin.x - 0.8 * self.padding[0], self.origin.y - (self.height / 2.0) - 0.8 * self.padding[1])
text = PDFText(self.session, self.page, None, cursor=label_cursor_y)
text.text_rotate(-90)
Expand Down
11 changes: 10 additions & 1 deletion pypdflite/pdfobjects/pdfpiechart.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def draw_data(self):
self._draw_legend_title()
start_angle = 0
i = 0
self.max_x = 0
for pair in self.data:
if self.legend is not None:
self._draw_legend_line(i, pair[0])
Expand All @@ -114,4 +115,12 @@ def _draw_legend_line(self, index, series_name):
box._draw()
end.x_plus(10)
text = PDFText(self.session, self.page, series_name, cursor=end, color=self.base_color)
self.legend_data_start.y_plus(1.75 * self._legend_line_height)
w = end.x + 4
if w > self.max_x:
self.max_x = w
self.legend_data_start.y_plus(1.75 * self._legend_line_height)

def _draw_legend_box(self):
end_cursor = PDFCursor(self.max_x, self.legend_data_start.y + 1.2 * self.session.parent.document.font.font_size)
legend_box = PDFRectangle(self.session, self.page, self.legend_start_cursor, end_cursor, self.base_color)
legend_box._draw()

0 comments on commit caae833

Please sign in to comment.