Ejemplo n.º 1
0
 def _do_draw_single_horizontal(self, context,  rect, n, i, mode, max_value, bar_padding, value_label_size, label_size, draw_labels):
     bar_width = (rect.width - value_label_size - label_size) * self._value / max_value
     bar_height = (rect.height - (n - 1) * bar_padding) / n
     bar_x = rect.x + label_size
     bar_y = rect.y + i * (bar_height + bar_padding)
     context.set_source_rgb(*color_gdk_to_cairo(self._color))
     draw_rounded_rectangle(context, bar_x, bar_y, bar_width, bar_height, self._corner_radius)
     context.fill()
     
     if self._highlighted:
         context.set_source_rgba(1, 1, 1, 0.1)
         draw_rounded_rectangle(context, bar_x, bar_y, bar_width, bar_height, self._corner_radius)
         context.fill()
         
     if draw_labels:
         #draw the value label
         self._value_label_object.set_text(str(self._value))
         self._value_label_object.set_color(self._color)
         self._value_label_object.set_position((bar_x + bar_width + 3, bar_y + bar_height / 2))
         self._value_label_object.set_anchor(label.ANCHOR_LEFT_CENTER)
         self._value_label_object.draw(context, rect)
         context.fill()
         
         #draw label
         self._label_object.set_text(self._label)
         self._label_object.set_color(self._color)
         self._label_object.set_max_width(0.25 * rect.width)
         self._label_object.set_position((bar_x - 3, bar_y + bar_height / 2))
         self._label_object.set_anchor(label.ANCHOR_RIGHT_CENTER)
         self._label_object.draw(context, rect)
         context.fill()
         
     chart.add_sensitive_area(chart.AREA_RECTANGLE, (bar_x, bar_y, bar_width, bar_height), self)
Ejemplo n.º 2
0
    def _do_draw_multi_vertical(self, context, rect, group, bar_count, n, i, m,
                                j, mode, group_padding, bar_padding,
                                maximum_value, group_end, value_label_size,
                                label_size, label_rotation, draw_labels):
        bar_width = (rect.width - (bar_count - n) * bar_padding -
                     (n - 1) * group_padding) / bar_count
        bar_height = (rect.height - value_label_size -
                      label_size) * self._value / maximum_value
        bar_x = group_end + j * (bar_width + bar_padding)
        bar_y = rect.y + rect.height - bar_height - label_size
        context.set_source_rgb(*color_gdk_to_cairo(self._color))
        bar_chart.draw_rounded_rectangle(context, bar_x, bar_y, bar_width,
                                         bar_height, self._corner_radius)
        context.fill()

        chart.add_sensitive_area(chart.AREA_RECTANGLE,
                                 (bar_x, bar_y, bar_width, bar_height),
                                 (group, self))

        if self._highlighted:
            context.set_source_rgba(1, 1, 1, 0.1)
            bar_chart.draw_rounded_rectangle(context, bar_x, bar_y, bar_width,
                                             bar_height, self._corner_radius)
            context.fill()

        if draw_labels:
            #draw the value label
            self._value_label_object.set_max_width(bar_width)
            self._value_label_object.set_text(str(self._value))
            self._value_label_object.set_color(self._color)
            self._value_label_object.set_position(
                (bar_x + bar_width / 2, bar_y - 3))
            self._value_label_object.set_anchor(label.ANCHOR_BOTTOM_CENTER)
            self._value_label_object.draw(context, rect)
            context.fill()

            #draw label
            self._label_object.set_rotation(label_rotation)
            self._label_object.set_wrap(False)
            self._label_object.set_color(self._color)
            self._label_object.set_fixed(True)
            self._label_object.set_max_width(3 * bar_width)
            self._label_object.set_text(self._label)
            self._label_object.set_position(
                (bar_x + bar_width / 2 + 5, bar_y + bar_height + 8))
            self._label_object.set_anchor(label.ANCHOR_TOP_RIGHT)
            self._label_object.draw(context, rect)
            context.fill()

        return bar_x + bar_width
 def _do_draw_multi_vertical(self, context, rect, group, bar_count, n, i, m, j, mode, group_padding, bar_padding, maximum_value, group_end, value_label_size, label_size, label_rotation, draw_labels):
     bar_width = (rect.width - (bar_count - n) * bar_padding - (n - 1) * group_padding) / bar_count
     bar_height = (rect.height - value_label_size - label_size) * self._value / maximum_value
     bar_x = group_end + j * (bar_width + bar_padding)
     bar_y = rect.y + rect.height - bar_height - label_size
     context.set_source_rgb(*color_gdk_to_cairo(self._color))
     bar_chart.draw_rounded_rectangle(context, bar_x, bar_y, bar_width, bar_height, self._corner_radius)
     context.fill()
     
     chart.add_sensitive_area(chart.AREA_RECTANGLE, (bar_x, bar_y, bar_width, bar_height), (group, self))
     
     if self._highlighted:
         context.set_source_rgba(1, 1, 1, 0.1)
         bar_chart.draw_rounded_rectangle(context, bar_x, bar_y, bar_width, bar_height, self._corner_radius)
         context.fill()
         
     if draw_labels:
         #draw the value label
         self._value_label_object.set_max_width(bar_width)
         self._value_label_object.set_text(str(self._value))
         self._value_label_object.set_color(self._color)
         self._value_label_object.set_position((bar_x + bar_width / 2, bar_y - 3))
         self._value_label_object.set_anchor(label.ANCHOR_BOTTOM_CENTER)
         self._value_label_object.draw(context, rect)
         context.fill()
         
         #draw label
         self._label_object.set_rotation(label_rotation)
         self._label_object.set_wrap(False)
         self._label_object.set_color(self._color)
         self._label_object.set_fixed(True)
         self._label_object.set_max_width(3 * bar_width)
         self._label_object.set_text(self._label)
         self._label_object.set_position((bar_x + bar_width / 2 + 5, bar_y + bar_height + 8))
         self._label_object.set_anchor(label.ANCHOR_TOP_RIGHT)
         self._label_object.draw(context, rect)
         context.fill()
     
     return bar_x + bar_width