示例#1
0
    def __draw_y_axis_for_time_value(self, axis, axis_position, reverse):
        start_point = Point(axis_position, self.top_margin + self.height)
        end_point = Point(axis_position, self.top_margin)
        self.svg_contents += svg_monkey.write_line(start_point, end_point,
                                                   'Black', 'axis')

        if axis.markers != None:
            for counter in range(0, len(axis.markers)):
                start_point = Point(
                    axis_position, (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))
                end_point = Point(
                    self.__handle_reverse(reverse, axis_position, 15),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))
                self.svg_contents += svg_monkey.write_line(
                    start_point, end_point, 'Black', 'axis')

                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 20),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str(axis.markers[counter].marker.label), 0,
                    'y_axis_label')
        self.__draw_y_axis_title(axis, 150)
示例#2
0
    def __build_legend_contents(self, left, primary_colours_palete,
                                secondary_colours_palete):
        contents = ''

        #colours_palete = ColoursPalete(3)
        spacer = 20
        #left = self.left_margin + self.width + 50
        if self.additional_axis_meta_data is not None:
            left += 50
        #this is now handled with a separate method call (title and legend now different)
        #contents += svg_monkey.write_text(Point(left, self.top_margin), 'Legend', 0, 'legend_item_title')

        for data_set in self.data_sets:  #sorted(self.data_sets):
            if data_set.axis_type == AxisType.PRIMARY:
                colours_palete = primary_colours_palete
            else:
                colours_palete = secondary_colours_palete

            colour = colours_palete.get_next_colour()
            contents += svg_monkey.write_line(Point(left - 30, spacer - 3),
                                              Point(left - 10, spacer - 3),
                                              colour, None, str(data_set.id))
            contents += svg_monkey.write_text(
                Point(left, spacer), data_set.name, 0, 'legend_item', colour,
                str(data_set.id),
                'onclick="highlight_lines(\'' + str(data_set.id) + '\');"')
            spacer += 20
        return contents
示例#3
0
    def __draw_y_axis_for_int(self, axis, axis_position, reverse):
        start_point = Point(axis_position, self.top_margin + self.height)
        end_point = Point(axis_position, self.top_margin)
        self.svg_contents += svg_monkey.write_line(start_point, end_point,
                                                   'Black', 'axis')

        #REFACTOR AHOY!!
        css_label = 'y_axis_label'
        if reverse == True:
            css_label = css_label + '_reverse'

        if axis.markers != None:
            for counter in range(0, len(axis.markers)):  #-1
                start_point = Point(
                    axis_position, (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))
                end_point = Point(
                    self.__handle_reverse(reverse, axis_position, 15),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))

                #print(axis.markers[counter].marker.label,axis.markers[counter].percentile, start_point.x, start_point.y)

                self.svg_contents += svg_monkey.write_line(
                    start_point, end_point, 'Black', 'axis')

                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 20),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str((axis.markers[counter].marker.label)), 0,
                    css_label)
        self.__draw_y_axis_title(axis)
示例#4
0
    def __translate_data_to_points(self, data_set):
        y_axis = None
        if self.additional_axis_meta_data is None:
            y_axis = self.y_primary_axis
        else:
            if self.additional_axis_meta_data.get_axis_meta_data_item(
                    data_set.name).axis_type == AxisType.PRIMARY:
                y_axis = self.y_primary_axis
            else:
                y_axis = self.y_secondary_axis

        points = []
        for data_item in data_set:
            if data_item.value != None:
                x = self.left_margin + round(
                    (((data_item.key - self.x_axis.low) /
                      (self.x_axis.high - self.x_axis.low)) * self.width), 2)

                y = self.top_margin + round(
                    self.height -
                    ((((data_item.value - y_axis.low) /
                       (y_axis.high - y_axis.low)) * self.height)), 2)
                point = Point(x, y)
                # if data_item.value == 942104:
                #     print(data_item.value, str(point), self.height, self.top_margin)
                points.append(point)

        return points
示例#5
0
    def __draw_y_axis_title(self, axis, offset=75):
        offset = self.__determine_y_axis_title_offset(axis)

        if axis.title != '' and axis.title != None:
            point = Point(self.left_margin - offset,
                          self.top_margin + (self.height / 2))
            self.svg_contents += svg_monkey.write_text(point, axis.title, 270,
                                                       'axis_title')
示例#6
0
 def __draw_x_axis_title(self, rotated_labels=False):
     if self.x_axis.title != '':
         y_buffer = 60
         if rotated_labels == True:
             y_buffer += 95
         point = Point(self.left_margin + (self.width / 2),
                       self.top_margin + self.height + y_buffer)
         self.svg_contents += svg_monkey.write_text(point,
                                                    self.x_axis.title, 0,
                                                    'axis_title')
示例#7
0
    def __draw_x_axis(self):
        start_point = Point(self.left_margin, self.top_margin + self.height)
        end_point = Point(self.left_margin + self.width,
                          self.top_margin + self.height)
        self.svg_contents += svg_monkey.write_line(start_point, end_point,
                                                   'Black', 'axis')

        rotated_labels = False
        if self.x_axis.markers != None:
            for counter in range(0, len(self.x_axis.markers) - 1):  #-1
                start_point = Point(
                    self.left_margin +
                    (self.x_axis.markers[counter].percentile * self.width),
                    self.top_margin + self.height)
                end_point = Point(
                    self.left_margin +
                    (self.x_axis.markers[counter].percentile * self.width),
                    self.top_margin + self.height + 15)
                self.svg_contents += svg_monkey.write_line(
                    start_point, end_point, 'Black', 'axis')

                start_point = Point(
                    self.left_margin + 5 +
                    (self.x_axis.markers[counter].percentile * self.width),
                    self.top_margin + self.height + 30)
                rotation = 0
                y_position = self.top_margin + self.height + 30
                if str(self.x_axis.markers[counter].marker.label).find(
                        ' ') > -1:
                    if rotated_labels == False:
                        rotated_labels = True
                    rotation = 90
                    y_position = y_position + 45

                self.svg_contents += svg_monkey.write_text(
                    start_point,
                    str(self.x_axis.markers[counter].marker.label), rotation,
                    'x_axis_label')

        self.__draw_x_axis_title(rotated_labels)
示例#8
0
    def __write_point_markers(self,
                              points,
                              display_markers=True,
                              display_labels=True,
                              color="",
                              label=""):
        point = None

        for point in points:
            if display_markers == True:
                self.svg_contents += svg_monkey.write_circle(point, 4, color)
        if display_labels == True:
            self.svg_contents += svg_monkey.write_text(
                Point(point.x + 10, point.y + 5), label, 0, 'legend_item',
                color)
示例#9
0
    def __draw_y_axis_for_float(self, axis, axis_position, reverse):
        # print(axis.low, axis.high)
        # print(len(axis.markers))
        start_point = Point(axis_position, self.top_margin + self.height)
        end_point = Point(axis_position, self.top_margin)
        self.svg_contents += svg_monkey.write_line(start_point, end_point,
                                                   'Black', 'axis')

        #refactor AHOY!
        css_label = 'y_axis_label'
        if reverse == True:
            css_label = css_label + '_reverse'

        if axis.markers != None:
            for counter in range(0, len(axis.markers)):  #-1
                start_point = Point(
                    axis_position, (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))
                end_point = Point(
                    self.__handle_reverse(reverse, axis_position, 15),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))

                # print(str(start_point.x) + ',' +  str(start_point.y) + ',' + str(axis.markers[counter].percentile) + ',"' + str(axis.markers[counter].marker.value) + '"')

                self.svg_contents += svg_monkey.write_line(
                    start_point, end_point, 'Black', 'axis')

                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 20),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str(axis.markers[counter].marker.label), 0,
                    css_label)
        self.__draw_y_axis_title(axis, 150)
示例#10
0
 def draw_legend_title(self):
     self.svg_legend_title_contents = svg_monkey.write_svg_start(100, 60)
     self.svg_legend_title_contents += svg_monkey.write_text(
         Point(30, 50), 'Legend', 0, 'legend_item_title')
     self.svg_legend_title_contents += svg_monkey.write_svg_end()
示例#11
0
 def __draw_graph_title(self):
     if self.title != '':
         point = Point(self.left_margin + (self.width / 2),
                       self.top_margin - (self.top_margin / 3))
         self.svg_contents += svg_monkey.write_text(point, self.title, 0,
                                                    'title')
示例#12
0
    def __new_draw_y_axis(self, axis, axis_position, reverse):

        start_point = Point(axis_position, self.top_margin + self.height)
        end_point = Point(axis_position, self.top_margin)
        self.svg_contents += svg_monkey.write_line(start_point, end_point,
                                                   'Black', 'axis')

        #REFACTOR AHOY!!
        css_label = 'y_axis_label'
        if reverse == True:
            css_label = css_label + '_reverse'

        if axis.markers != None:
            for counter in range(0, len(axis.markers) - 1):
                start_point = Point(
                    axis_position, (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))
                end_point = Point(
                    self.__handle_reverse(reverse, axis_position, 15),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))

                self.svg_contents += svg_monkey.write_line(
                    start_point, end_point, 'Black', 'axis')

                #int
                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 20),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str((axis.markers[counter].marker.label)), 0,
                    css_label)

                #date
                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 65),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point,
                    self.__format_axis_label_for_date(
                        axis.markers[counter].marker.value,
                        self.x_axis_format), 0, 'y_axis_label')

                #datetime
                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 65),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str(axis.markers[counter].marker.label), 0,
                    'y_axis_label')

                #timevalue
                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 20),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str(axis.markers[counter].marker.label), 0,
                    'y_axis_label')

                #float
                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 20),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str(axis.markers[counter].marker.label), 0,
                    css_label)

        self.__draw_y_axis_title(axis)