Exemplo n.º 1
0
 def _draw_legend_line(self, index, series_name):
     end = PDFCursor(self.legend_data_start.x + 10, self.legend_data_start.y + 10)
     box = PDFRectangle(self.session, self.page, self.legend_data_start, end, None, self.bar_fill_colors[index], style="F", stroke="solid")
     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)
Exemplo n.º 2
0
 def _draw_legend_box(self):
     end_cursor = PDFCursor(
         self.legend_start_cursor.x + self.legend_width,
         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()
Exemplo n.º 3
0
 def _draw_legend_line(self, index, series_name):
     end = PDFCursor(self.legend_data_start.x + 10, self.legend_data_start.y + 10)
     box = PDFRectangle(self.session, self.page, self.legend_data_start, end, None, self.fill_colors[index], style="F", stroke="solid")
     box._draw()
     end.x_plus(10)
     text = PDFText(self.session, self.page, series_name, cursor=end, color=self.base_color)
     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)
Exemplo n.º 4
0
 def draw_bars(self):
     x_space = int(self.bar_padding * self.x_delta)
     i = 0
     for pair in self.data:
         draw, fill = self._get_colors(i)
         cursor1 = PDFCursor(self.x_array[i][1] + x_space, self.interpolate(pair[1], self.y_array))
         cursor2 = PDFCursor(self.x_array[i][1] + self.x_delta - x_space, self.origin.y)
         rect = PDFRectangle(self.session, self.page, cursor1, cursor2, draw, fill, self.bar_style, "solid")
         rect._draw()
         i += 1
Exemplo n.º 5
0
 def _draw_background(self, width, height):
     if self.background.exists:
         cursor_end = PDFCursor(self.origin.x + width,
                                self.origin.y + height)
         rectangle = PDFRectangle(self.session, self.page, self.origin,
                                  cursor_end, self.background.border_color,
                                  self.background.fill_color,
                                  self.background.style,
                                  self.background.stroke,
                                  self.background.size)
         rectangle._draw()
Exemplo n.º 6
0
 def _draw_fill(self):
     if self.format['fill_color'] is not None:
         if isinstance(self.format['fill_color'], PDFColor):
             rect = PDFRectangle(self.table.session,
                                 self.table.page,
                                 self.point_nw,
                                 self.point_se,
                                 fill_color=self.format['fill_color'],
                                 style='F')
             rect._draw()
         else:
             raise Exception("Color %s is not a PDFColor" %
                             self.format['fill_color'])
Exemplo n.º 7
0
 def draw_bars(self):
     x_space = int(self.bar_padding * self.x_delta)
     i = 0
     for pair in self.data:
         draw, fill = self._get_colors(i)
         cursor1 = PDFCursor(self.x_array[i][1] + x_space,
                             self.interpolate(pair[1], self.y_array))
         cursor2 = PDFCursor(self.x_array[i][1] + self.x_delta - x_space,
                             self.origin.y)
         rect = PDFRectangle(self.session, self.page, cursor1, cursor2,
                             draw, fill, self.bar_style, "solid")
         rect._draw()
         i += 1
Exemplo n.º 8
0
 def _draw_fill(self):
     if self.format["fill_color"] is not None:
         if isinstance(self.format["fill_color"], PDFColor):
             rect = PDFRectangle(
                 self.table.session,
                 self.table.page,
                 self.point_nw,
                 self.point_se,
                 fill_color=self.format["fill_color"],
                 style="F",
             )
             rect._draw()
         else:
             raise Exception("Color %s is not a PDFColor" % self.format["fill_color"])
Exemplo n.º 9
0
    def draw_bars(self):
        x_space = int(self.bar_padding * self.x_delta)

        sub_array = []
        for x in self.x_array:
            sub_array.append((x[0], x[1] + x_space))
        self.new_x_array = [sub_array]

        new_x_delta = self.x_delta / float(len(self.data))
        for series in range(1, len(self.data)):
            sub_array = []
            for pair in self.x_array:
                sub_array.append((pair[0], pair[1] + new_x_delta))
            self.new_x_array.append(sub_array)

        if self.legend is not None:
            self._legend_line_height = self.session.parent.document.font.font_size
            self.legend_start_cursor.x_plus(-self.padding[0] * 0.5)
            self.legend_width += self.padding[0] * 0.55
            self._draw_legend_title()

        j = 0
        for series in self.data:
            values_list = series.values()[0]
            draw, fill = self._get_colors(j)
            if self.legend is not None:
                self._draw_legend_line(j, series.keys()[0])
            i = 0
            for pair in values_list:
                cursor1 = PDFCursor(self.new_x_array[j][i][1],
                                    self.interpolate(pair[1], self.y_array))
                cursor2 = PDFCursor(
                    self.new_x_array[j][i][1] + new_x_delta - x_space,
                    self.origin.y)
                rect = PDFRectangle(self.session, self.page, cursor1, cursor2,
                                    draw, fill, self.bar_style, "solid")
                rect._draw()
                i += 1
            j += 1

        if self.legend is not None:
            self._draw_legend_box()
Exemplo n.º 10
0
    def draw_bars(self):
        x_space = int(self.bar_padding * self.x_delta)

        sub_array = []
        for x in self.x_array:
            sub_array.append((x[0], x[1] + x_space))
        self.new_x_array = [sub_array]

        new_x_delta = self.x_delta / float(len(self.data))
        for series in range(1, len(self.data)):
            sub_array = []
            for pair in self.x_array:
                sub_array.append((pair[0], pair[1] + new_x_delta))
            self.new_x_array.append(sub_array)

        if self.legend is not None:
            self._legend_line_height = self.session.parent.document.font.font_size
            self.legend_start_cursor.x_plus(-self.padding[0] * 0.5)
            self.legend_width += self.padding[0] * 0.55
            self._draw_legend_title()

        j = 0
        for series in self.data:
            values_list = series.values()[0]
            draw, fill = self._get_colors(j)
            if self.legend is not None:
                self._draw_legend_line(j, series.keys()[0])
            i = 0
            for pair in values_list:
                cursor1 = PDFCursor(self.new_x_array[j][i][1], self.interpolate(pair[1], self.y_array))
                cursor2 = PDFCursor(self.new_x_array[j][i][1] + new_x_delta - x_space, self.origin.y)
                rect = PDFRectangle(self.session, self.page, cursor1, cursor2, draw, fill, self.bar_style, "solid")
                rect._draw()
                i += 1
            j += 1

        if self.legend is not None:
            self._draw_legend_box()
Exemplo n.º 11
0
 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()
Exemplo n.º 12
0
 def _draw_background(self, width, height):
     if self.background.exists:
         cursor_end = PDFCursor(self.origin.x + width, self.origin.y + height)
         rectangle = PDFRectangle(self.session, self.page, self.origin, cursor_end, self.background.border_color, self.background.fill_color, self.background.style, self.background.stroke, self.background.size)
         rectangle._draw()