main.EText(font, s, x=xpos, y=ypos, stroke='none') y += delta plot_items(name_width + duration_width, earliest, latest) # set total size self.set('width', str(WIDTH + 2 * self.PAD)) self.set('height', str(HEIGHT + 2 * self.PAD)) if __name__ == '__main__': from svgplotlib.SVG import show items = [] items.append(Duration('Item 1', date(2009, 1, 4), date(2009, 8, 10), '90%')) items.append( Duration('Item 2', date(2009, 3, 11), date(2009, 8, 17), '50%')) items.append( Duration('Item 3', date(2009, 4, 18), date(2009, 8, 24), '70%')) items.append( Duration('Item 4', date(2009, 5, 25), date(2009, 8, 31), '10%')) items.append( Duration('Item 4', date(2009, 5, 25), date(2009, 9, 27), '25%')) gantt = Gantt(items) #gantt.write(encoding=None) #gantt.write(file=open('gantt.svg','wb')) show(gantt, gantt.width, gantt.height)
# find center point for text cangle = math.radians(angle + .5 * delta) dx = .5 * r * math.cos(cangle) dy = .5 * r * math.sin(cangle) size = self.textSize(unicode(label)) xpos = .5 * SIZE + dx - .5 * size.width ypos = .5 * SIZE + dy + .5 * size.height - .5 * size.descent plotArea.EText(self.font, label, x=xpos, y=ypos, fill=labelColor, **textStyle) angle += delta if __name__ == '__main__': from svgplotlib.SVG import show graph = Pie( (10, 50, 100), title='Simple pie plot', labels=('Cars', 'Boats', 'Planes'), ) show(graph, graph.width, graph.height)
""" def __init__(self, *args, **kwargs): super( DateMonthGraph, self).__init__(*args, **kwargs) # plot graph color = kwargs.get('color', 'blue') self.drawLines(color = color) if __name__ == '__main__': from svgplotlib.SVG import show # plot dates xdata = ( datetime.date(2010,1,5), datetime.date(2010,2,15), datetime.date(2010,4,15), datetime.date(2010,6,15), ) ydata = ( 50., 40.5, 90., 50., ) graph = DateMonthGraph(xdata,ydata) show(graph, graph.width, graph.height)
if duration.text: s = unicode(duration.text) size = self.textSize(s) xpos = rect_start + .5*rect_width - .5*size.width ypos = y + .5*size.height + .5*delta main.EText(font, s, x = xpos, y = ypos, stroke='none') y += delta plot_items(name_width + duration_width, earliest, latest) # set total size self.set('width', str(WIDTH + 2*self.PAD)) self.set('height', str(HEIGHT + 2*self.PAD)) if __name__ == '__main__': from svgplotlib.SVG import show items = [] items.append(Duration('Item 1', date(2009, 1, 4), date(2009, 8, 10), '90%')) items.append(Duration('Item 2', date(2009, 3, 11), date(2009, 8, 17), '50%')) items.append(Duration('Item 3', date(2009, 4, 18), date(2009, 8, 24), '70%')) items.append(Duration('Item 4', date(2009, 5, 25), date(2009, 8, 31), '10%')) items.append(Duration('Item 4', date(2009, 5, 25), date(2009, 9, 27), '25%')) gantt = Gantt(items) #gantt.write(encoding=None) #gantt.write(file=open('gantt.svg','wb')) show(gantt, gantt.width, gantt.height)