Example #1
0
    def create(self, session, adapter, stats):
        names = self.page.names.get(session)
        values = self.page.values.get(session)
        nvs = dict()
        for name, value in zip(names, values):
            nvs[name] = value

        # move Unclaimed to end of list
        sorted_names = sorted(names)
        sorted_names.remove("Unclaimed")
        sorted_names.append("Unclaimed")

        chart = Chart()
        chart.title.text = ""
        chart.bg_colour = "#FFFFFF"

        chart.elements = list()
        element = Element()
        element.type = "pie"
        element.alpha = 7
        element.start_angle = 0
        element.gradient_fill = True
        element.radius = 90

        element.animate = list()
        animation = Element()
        animation.type = "fade"
        element.animate.append(animation)
        animation = Element()
        animation.type = "bounce"
        animation.distance = 8
        element.animate.append(animation)
        element.tip = "#percent#"

        element.colours = []
        for i in range(len(sorted_names)):
            j = i % len(self.colors)
            if sorted_names[i] == "Unclaimed":
                color = "#EEEEEE"
            else:
                color = self.colors[j]
            element.colours.append(color)
        element.colours.append("#EEEEEE")

        element.on_click = "ofc_change_priority"
        id = self.page.chart_id.get(session)
        element.on_click_text = "#percent#|#val#|#label#|%s" % id

        element.values = [{"label": x, "value": float(nvs[x])} for x in sorted_names]

        chart.elements.append(element)
        return chart.create()
Example #2
0
    def make_chart_lines(self, session, chart, line_type, stats, dot_size, halo_size, line_width, samples, duration, end_secs, mode):
        chart.elements = list()
        for stat, color in reversed(zip(stats, self.colors)):
            line = Element()
            line.type = line_type
            line.fill = color
            line.fill_alpha = self.alpha
            line.on_show.type = "No"

            line.dot_style = {"type": "solid-dot",
                              "dot-size": dot_size,
                              "halo-size": halo_size}
            line.colour = color
            line.width = line_width
            tip_title = stat.title.split(" ")[-1]
            line.text = mode == "rate" and "%s / sec" % tip_title or self.get_line_title(stat)

            vals = self.get_vals(session, samples, stat, line.text, duration, end_secs)
            line.values = vals
            chart.elements.append(line)