Пример #1
0
def main() :
    #h_pixals = 1600
    h_pixals = 1360
    # 500 horizontal pixals: 120 for names, 380 for bars.
    #     380 gives 10 nice bars..  I need 16 bars, so 60/bar = 960
    #     120 for names of 7 chars.  I have at least 38 chars. assume 42.
    #          120 * 6 = 720
    #     960 + 640 = 1600 horizontal pixals.
    h_legend = []
    allstarts = []
    allends = []
    colors = []
    tasknames = []
    pieces = []
    bars = {}
    starttimes = {}
    bar_color = (1.0, 0.7, 0.0)

    f = parse_commandline()

    for inputline in f :
        for line in csv.reader([inputline], escapechar='\\'):
            name = "__".join(line[0:3])
            start = int(line[3])
            end = int(line[4])
            #if time.gmtime(end)[3:5] == (6,13) :
            #    print name
            bars.setdefault(name, []).append((start,end))
            allstarts.append(start)
            allends.append(end)
            starttimes.setdefault(start, []).append(name)

    first = min(allstarts)
    last = max(allends)
    v_tickmarks = calc_vticks(first, last)
    v_pixals = (len(bars.keys()) + 1) * 70
    # 350 vertical pixals.  70 for each task + 70 for headers.
    # v_tickmarks = scale_vlines(first, last)
    for start in sorted(starttimes.keys()) :
        for name in starttimes[start] :
            # one task name.
            tasknames.append(name)
            # need 1 color per name
            colors.append(bar_color)
            times = bars[name]
            #print 'debug', name
            pieces.append(scaled_times(times, first))

    CairoPlot.gantt_chart('visual_schedule', pieces, h_pixals, v_pixals, 
                          tasknames, v_tickmarks, colors)
Пример #2
0
background.add_color_stop_rgb(1.0,0.1,0.1,0.1)
data = {"john" : 700, "mary" : 100, "philip" : 100 , "suzy" : 50, "yman" : 50}
CairoPlot.pie_plot("pie1", data, 600, 400, background = background )

#test2
CairoPlot.donut_plot("donut1_background", data, 600, 400, background = background, gradient = True, inner_radius = 0.3)
CairoPlot.donut_plot("donut1_gradient", data, 600, 400, gradient = True, inner_radius = 0.3)
CairoPlot.donut_plot("donut1_shadow", data, 600, 400, gradient = False, shadow = True, inner_radius = 0.3)

#Gantt Chart
#test1
pieces = [(0.5,5.5) , [(0,4),(6,8)] , (5.5,7) , (7,8)]
h_labels = [ 'teste01', 'teste02', 'teste03', 'teste04']
v_labels = [ '0001', '0002', '0003', '0004', '0005', '0006', '0007', '0008', '0009', '0010' ]
colors = [ (1.0, 0.0, 0.0), (1.0, 0.7, 0.0), (1.0, 1.0, 0.0), (0.0, 1.0, 0.0) ]
CairoPlot.gantt_chart('gantt1', pieces, 500, 350, h_labels, v_labels, colors)


background = cairo.LinearGradient(300, 0, 300, 400)
background.add_color_stop_rgb(0,0.7,0,0)
background.add_color_stop_rgb(1.0,0.3,0,0)
data = {"john" : 700, "mary" : 100, "philip" : 100 , "suzy" : 50, "yman" : 50}
colors = [ (232.0/255, 118.0/255, 107.0/255), 
           (255.0/255, 150.0/255, 117.0/255),
           (255.0/255, 130.0/255, 154.0/255),
           (232.0/255, 107.0/255, 194.0/255),
           (240.0/255, 117.0/255, 255.0/255) ]
CairoPlot.pie_plot("pie_blog.png", data, 600, 400, background = background, gradient = True, shadow = True, colors = colors)


background = cairo.LinearGradient(300, 0, 300, 400)
Пример #3
0
                     600,
                     400,
                     gradient=False,
                     shadow=True,
                     inner_radius=0.3)

#Gantt Chart
#test1
pieces = [(0.5, 5.5), [(0, 4), (6, 8)], (5.5, 7), (7, 8)]
h_labels = ['teste01', 'teste02', 'teste03', 'teste04']
v_labels = [
    '0001', '0002', '0003', '0004', '0005', '0006', '0007', '0008', '0009',
    '0010'
]
colors = [(1.0, 0.0, 0.0), (1.0, 0.7, 0.0), (1.0, 1.0, 0.0), (0.0, 1.0, 0.0)]
CairoPlot.gantt_chart('gantt1', pieces, 500, 350, h_labels, v_labels, colors)

background = cairo.LinearGradient(300, 0, 300, 400)
background.add_color_stop_rgb(0, 0.7, 0, 0)
background.add_color_stop_rgb(1.0, 0.3, 0, 0)
data = {"john": 700, "mary": 100, "philip": 100, "suzy": 50, "yman": 50}
colors = [(232.0 / 255, 118.0 / 255, 107.0 / 255),
          (255.0 / 255, 150.0 / 255, 117.0 / 255),
          (255.0 / 255, 130.0 / 255, 154.0 / 255),
          (232.0 / 255, 107.0 / 255, 194.0 / 255),
          (240.0 / 255, 117.0 / 255, 255.0 / 255)]
CairoPlot.pie_plot("pie_blog.png",
                   data,
                   600,
                   400,
                   background=background,