Exemple #1
0
def graph(results):
    output = []
    sorted_keys = results.keys()
    sorted_keys.sort()
    for test in sorted_keys:
        data = results[test]
        datalist = [data[host[0]] for host in HOSTS]

        plots = []
        dates = []
        max_points = max([len(d) for d in datalist])
        for hostlist in datalist:
            hostplots = []
            hostdates = []
            for hostitem in hostlist:
                hostplots.append(hostitem[0])
                hostdates.append(hostitem[1])
            if len(hostplots) < max_points:
                hostplots.extend([hostlist[-1][0] for i in xrange(max_points-len(hostplots))])
            plots.append(hostplots)
            dates.append(hostdates)
        first_day = dates[0][0]
        last_day = dates[0][-1]
        delta = last_day - first_day
        diff = delta.days*60*60*24 + delta.seconds

        days = []
        days.append(first_day.strftime("%a"))
        days.append((first_day+timedelta(seconds=int(diff*0.2))).strftime("%a"))
        days.append((first_day+timedelta(seconds=int(diff*0.4))).strftime("%a"))
        days.append((first_day+timedelta(seconds=int(diff*0.6))).strftime("%a"))
        days.append((first_day+timedelta(seconds=int(diff*0.8))).strftime("%a"))
        days.append(last_day.strftime("%a"))

        maximum = max([max(d) for d in plots])
        minimum = min([min(d) for d in plots])

        def scale(value, scale=4095):
            return (value - minimum) * scale / abs(maximum - minimum)

        scaled_plots = []
        for hostplots in plots:
            scaled_plots.append([scale(v) for v in hostplots])

        g = Line(scaled_plots, encoding='extended')
        g.legend(*[host[1] for host in HOSTS])
        g.legend_pos('b')
        g.color("edc240", "afd8f8", "cb4b4b", "4da74d", "f8afe8", "4066ed", )
        for i in range(3):
            g.line(2.5, 1, 0)
        g.size(500, 300)
        #g.scale(minimum, maximum)
        g.axes.type('xy')
        labels = range(minimum, maximum, (maximum-minimum)/5)
        g.axes.label(0, *days)
        g.axes.label(1, *labels)
        #g.show()
        print test
        print g
        output.append("%s" % g)
Exemple #2
0
 def grid(self):
     # Create dashed line with grid x,y as floats
     # then, just like line, the line and blank segments
     G = Line(['foobarbaz'])
     G.color('76A4FB')
     G.line(3, 6, 3)
     G.grid(20.0, 25.0, 1, 0)
     return G
Exemple #3
0
 def line(self):
     # Add red line 6 thick
     # with 5 line segments with 2 blank segments
     G = Line(['hX1xPj'])
     G.axes.type('xy')
     G.axes.label('Mar', 'Apr', 'May', 'June', 'July')
     G.axes.label(None, '50+Kb')
     G.color('ff0000')
     G.line(6, 5, 2)
     return G
Exemple #4
0
 def fill(self):
     # Fill the chart/background using chf, add axes to show bg
     G = Line(['pqokeYONOMEBAKPOQVTXZdecaZcglprqxuux393ztpoonkeggjp'])
     G.color('ff0000')
     G.line(4, 3, 0)
     G.axes.type('xy')
     G.axes.label(1, 2, 3, 4, 5)
     G.axes.label(None, 50, 100)
     G.fill('c', 'lg', 45, 'ffffff', 0, '76A4FB', 0.75)
     G.fill('bg', 's', 'EFEFEF')
     return G
Exemple #5
0
def graph(results):
    output = []
    sorted_keys = results.keys()
    sorted_keys.sort()
    for test in sorted_keys:
        data = results[test]
        datalist = [data[host[0]] for host in HOSTS]

        plots = []
        dates = []
        max_points = max([len(d) for d in datalist])
        for hostlist in datalist:
            hostplots = []
            hostdates = []
            for hostitem in hostlist:
                hostplots.append(hostitem[0])
                hostdates.append(hostitem[1])
            if len(hostplots) < max_points:
                hostplots.extend([
                    hostlist[-1][0]
                    for i in xrange(max_points - len(hostplots))
                ])
            plots.append(hostplots)
            dates.append(hostdates)
        first_day = dates[0][0]
        last_day = dates[0][-1]
        delta = last_day - first_day
        diff = delta.days * 60 * 60 * 24 + delta.seconds

        days = []
        days.append(first_day.strftime("%a"))
        days.append(
            (first_day + timedelta(seconds=int(diff * 0.2))).strftime("%a"))
        days.append(
            (first_day + timedelta(seconds=int(diff * 0.4))).strftime("%a"))
        days.append(
            (first_day + timedelta(seconds=int(diff * 0.6))).strftime("%a"))
        days.append(
            (first_day + timedelta(seconds=int(diff * 0.8))).strftime("%a"))
        days.append(last_day.strftime("%a"))

        maximum = max([max(d) for d in plots])
        minimum = min([min(d) for d in plots])

        def scale(value, scale=4095):
            return (value - minimum) * scale / abs(maximum - minimum)

        scaled_plots = []
        for hostplots in plots:
            scaled_plots.append([scale(v) for v in hostplots])

        g = Line(scaled_plots, encoding='extended')
        g.legend(*[host[1] for host in HOSTS])
        g.legend_pos('b')
        g.color(
            "edc240",
            "afd8f8",
            "cb4b4b",
            "4da74d",
            "f8afe8",
            "4066ed",
        )
        for i in range(3):
            g.line(2.5, 1, 0)
        g.size(500, 300)
        #g.scale(minimum, maximum)
        g.axes.type('xy')
        labels = range(minimum, maximum, (maximum - minimum) / 5)
        g.axes.label(0, *days)
        g.axes.label(1, *labels)
        #g.show()
        print test
        print g
        output.append("%s" % g)