def _draw_segment(self, cur_drawing): """Draw a half circle representing the end of a linear chromosome. """ # set the coordinates of the segment -- it'll take up the MIDDLE part # of the space we have. width = (self.end_x_position - self.start_x_position) \ * self.chr_percent height = self.start_y_position - self.end_y_position center_x = 0.5 * (self.end_x_position + self.start_x_position) start_x = center_x - 0.5 * width if self._inverted: center_y = self.start_y_position start_angle = 180 end_angle = 360 else: center_y = self.end_y_position start_angle = 0 end_angle = 180 cap_wedge = Wedge(center_x, center_y, width / 2, start_angle, end_angle, height) cap_wedge.strokeColor = None cap_wedge.fillColor = self.fill_color cur_drawing.add(cap_wedge) # Now draw an arc for the curved edge of the wedge, # omitting the flat end. cap_arc = ArcPath() cap_arc.addArc(center_x, center_y, width / 2, start_angle, end_angle, height) cur_drawing.add(cap_arc)
def _draw_segment(self, cur_drawing): """Draw a half circle representing the end of a linear chromosome. """ # set the coordinates of the segment -- it'll take up the left part # of the space we have. width = (self.end_x_position - self.start_x_position) \ * self.chr_percent height = self.start_y_position - self.end_y_position center_x = self.start_x_position + width / 2 if self._inverted: center_y = self.start_y_position start_angle = 180 end_angle = 360 else: center_y = self.end_y_position start_angle = 0 end_angle = 180 cap_wedge = Wedge(center_x, center_y, width / 2, start_angle, end_angle, height / 2) cap_wedge.fillColor = self.fill_color cur_drawing.add(cap_wedge) # draw a line to cover up the the bottom part of the wedge if self._inverted: cover_line = Line(self.start_x_position, self.start_y_position, self.start_x_position + width, self.start_y_position) else: cover_line = Line(self.start_x_position, self.end_y_position, self.start_x_position + width, self.end_y_position) if self.fill_color is not None: cover_color = self.fill_color else: cover_color = colors.white cover_line.strokeColor = cover_color cur_drawing.add(cover_line)
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] n = [] for l in self.data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) self._seriesCount = max(n) else: normData = self.normalizeData(self.data) n = len(normData) self._seriesCount = n #labels checkLabelOverlap = self.checkLabelOverlap L = [] L_add = L.append if self.labels is None: labels = [] if type(n) not in (ListType,TupleType): labels = [''] * n else: for m in n: labels = list(labels) + [''] * m else: labels = self.labels #there's no point in raising errors for less than enough labels if #we silently create all for the extreme case of no labels. if type(n) not in (ListType,TupleType): i = n-len(labels) if i>0: labels = list(labels) + [''] * i else: tlab = 0 for m in n: tlab += m i = tlab-len(labels) if i>0: labels = list(labels) + [''] * i xradius = self.width/2.0 yradius = self.height/2.0 centerx = self.x + xradius centery = self.y + yradius if self.direction == "anticlockwise": whichWay = 1 else: whichWay = -1 g = Group() startAngle = self.startAngle #% 360 styleCount = len(self.slices) if type(self.data[0]) in (ListType, TupleType): #multi-series doughnut iradius = (self.height/5.0)/len(self.data) for sn,series in enumerate(normData): for i,angle in enumerate(series): endAngle = (startAngle + (angle * whichWay)) #% 360 if abs(startAngle-endAngle)<1e-5: startAngle = endAngle continue if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle startAngle = endAngle #if we didn't use %stylecount here we'd end up with the later sectors #all having the default style sectorStyle = self.slices[i%styleCount] # is it a popout? cx, cy = centerx, centery if sectorStyle.popout != 0: # pop out the sector averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle * pi/180.0 popdistance = sectorStyle.popout cx = centerx + popdistance * cos(aveAngleRadians) cy = centery + popdistance * sin(aveAngleRadians) if type(n) in (ListType,TupleType): theSector = Wedge(cx, cy, xradius+(sn*iradius)-iradius, a1, a2, yradius=yradius+(sn*iradius)-iradius, radius1=yradius+(sn*iradius)-(2*iradius)) else: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=iradius) theSector.fillColor = sectorStyle.fillColor theSector.strokeColor = sectorStyle.strokeColor theSector.strokeWidth = sectorStyle.strokeWidth theSector.strokeDashArray = sectorStyle.strokeDashArray g.add(theSector) if sn == 0: text = self.getSeriesName(i,'') if text: averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle*pi/180.0 labelRadius = sectorStyle.labelRadius rx = xradius*labelRadius ry = yradius*labelRadius labelX = centerx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius) labelY = centery + (0.5 * self.height * sin(aveAngleRadians) * labelRadius) l = _addWedgeLabel(self,text,averageAngle,labelX,labelY,sectorStyle) if checkLabelOverlap: l._origdata = { 'x': labelX, 'y':labelY, 'angle': averageAngle, 'rx': rx, 'ry':ry, 'cx':cx, 'cy':cy, 'bounds': l.getBounds(), } L_add(l) else: #single series doughnut iradius = self.height/5.0 for i,angle in enumerate(normData): endAngle = (startAngle + (angle * whichWay)) #% 360 if abs(startAngle-endAngle)<1e-5: startAngle = endAngle continue if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle startAngle = endAngle #if we didn't use %stylecount here we'd end up with the later sectors #all having the default style sectorStyle = self.slices[i%styleCount] # is it a popout? cx, cy = centerx, centery if sectorStyle.popout != 0: # pop out the sector averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle * pi/180.0 popdistance = sectorStyle.popout cx = centerx + popdistance * cos(aveAngleRadians) cy = centery + popdistance * sin(aveAngleRadians) if n > 1: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=iradius) elif n==1: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, iradius=iradius) theSector.fillColor = sectorStyle.fillColor theSector.strokeColor = sectorStyle.strokeColor theSector.strokeWidth = sectorStyle.strokeWidth theSector.strokeDashArray = sectorStyle.strokeDashArray g.add(theSector) # now draw a label if labels[i] != "": averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle*pi/180.0 labelRadius = sectorStyle.labelRadius labelX = centerx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius) labelY = centery + (0.5 * self.height * sin(aveAngleRadians) * labelRadius) rx = xradius*labelRadius ry = yradius*labelRadius l = _addWedgeLabel(self,labels[i],averageAngle,labelX,labelY,sectorStyle) if checkLabelOverlap: l._origdata = { 'x': labelX, 'y':labelY, 'angle': averageAngle, 'rx': rx, 'ry':ry, 'cx':cx, 'cy':cy, 'bounds': l.getBounds(), } L_add(l) if checkLabelOverlap and L: fixLabelOverlaps(L) for l in L: g.add(l) return g
def makeWedges(self): angles = self.makeAngles() n = len(angles) labels = _fixLabels(self.labels,n) self._seriesCount = n styleCount = len(self.slices) plMode = self.pointerLabelMode if plMode: checkLabelOverlap = False PL=self.makePointerLabels(angles,plMode) xradius = PL.xradius yradius = PL.yradius centerx = PL.centerx centery = PL.centery PL_data = PL.data gSN = lambda i: '' else: xradius = self.width*0.5 yradius = self.height*0.5 centerx = self.x + xradius centery = self.y + yradius if self.xradius: xradius = self.xradius if self.yradius: yradius = self.yradius if self.sameRadii: xradius=yradius=min(xradius,yradius) checkLabelOverlap = self.checkLabelOverlap gSN = lambda i: self.getSeriesName(i,'') g = Group() g_add = g.add if checkLabelOverlap: L = [] L_add = L.append else: L_add = g_add for i,(a1,a2) in angles: if a2 is None: continue #if we didn't use %stylecount here we'd end up with the later wedges #all having the default style wedgeStyle = self.slices[i%styleCount] if not wedgeStyle.visible: continue # is it a popout? cx, cy = centerx, centery text = gSN(i) popout = wedgeStyle.popout if text or popout: averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle/_180_pi cosAA = cos(aveAngleRadians) sinAA = sin(aveAngleRadians) if popout: # pop out the wedge cx = centerx + popout*cosAA cy = centery + popout*sinAA if n > 1: theWedge = Wedge(cx, cy, xradius, a1, a2, yradius=yradius) elif n==1: theWedge = Ellipse(cx, cy, xradius, yradius) theWedge.fillColor = wedgeStyle.fillColor theWedge.strokeColor = wedgeStyle.strokeColor theWedge.strokeWidth = wedgeStyle.strokeWidth theWedge.strokeDashArray = wedgeStyle.strokeDashArray g_add(theWedge) if wedgeStyle.label_visible: if text: labelRadius = wedgeStyle.labelRadius rx = xradius*labelRadius ry = yradius*labelRadius labelX = cx + rx*cosAA labelY = cy + ry*sinAA _addWedgeLabel(self,text,L_add,averageAngle,labelX,labelY,wedgeStyle) if checkLabelOverlap: l = L[-1] l._origdata = { 'x': labelX, 'y':labelY, 'angle': averageAngle, 'rx': rx, 'ry':ry, 'cx':cx, 'cy':cy, 'bounds': l.getBounds(), } elif plMode and PL_data: l = PL_data[i] if l: data = l._origdata sinM = data['smid'] cosM = data['cmid'] lX = cx + xradius*cosM lY = cy + yradius*sinM lpel = wedgeStyle.label_pointer_elbowLength lXi = lX + lpel*cosM lYi = lY + lpel*sinM L_add(PolyLine((lX,lY,lXi,lYi,l.x,l.y), strokeWidth=wedgeStyle.label_pointer_strokeWidth, strokeColor=wedgeStyle.label_pointer_strokeColor)) L_add(l) if checkLabelOverlap and L: fixLabelOverlaps(L) map(g_add,L) return g
def __init__(self, width=400, height=200, *args, **kw): Drawing.__init__(self, width, height, *args, **kw) self.transform = (1, 0, 0, 1, 0, 0) self.add( Wedge(200, 100, 50, 72.85714, 90, yradius=50, annular=False, fillColor=Color(0, .545098, .545098, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(200, 100, 50, 38.57143, 72.85714, yradius=50, annular=False, fillColor=Color(.541176, .168627, .886275, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(200, 100, 50, -12.85714, 38.57143, yradius=50, annular=False, fillColor=Color(0, 0, 1, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(213.6035, 85.33896, 50, -81.42857, -12.85714, yradius=50, annular=False, fillColor=Color(0, 1, 1, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=2, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=[2, 2], strokeOpacity=None)) self.add( Wedge(200, 100, 50, -167.1429, -81.42857, yradius=50, annular=False, fillColor=Color(1, .752941, .796078, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(200, 100, 50, -270, -167.1429, yradius=50, annular=False, fillColor=Color(1, 0, 1, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( String(208.9425, 159.3298, 'a', textAnchor='middle', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(233.7992, 149.5743, 'b', textAnchor='middle', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(258.4957, 113.3513, 'c', textAnchor='middle', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(273.1186, 21.19692, 'd', textAnchor='middle', fontName='Times-Roman', fontSize=10, fillColor=Color(1, 0, 0, 1))) self.add( String(166.2008, 50.42567, 'e', textAnchor='middle', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(153.0901, 137.4094, 'f', textAnchor='middle', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1)))
def sample1(): "Make up something from the individual Sectors" d = Drawing(400, 400) g = Group() s1 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=0, endangledegrees=120, radius1=100) s1.fillColor=colors.red s1.strokeColor=None d.add(s1) s2 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=120, endangledegrees=240, radius1=100) s2.fillColor=colors.green s2.strokeColor=None d.add(s2) s3 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=240, endangledegrees=260, radius1=100) s3.fillColor=colors.blue s3.strokeColor=None d.add(s3) s4 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=260, endangledegrees=360, radius1=100) s4.fillColor=colors.gray s4.strokeColor=None d.add(s4) return d
def __init__(self, width=400, height=400, *args, **kw): Drawing.__init__(self, width, height, *args, **kw) self.transform = (1, 0, 0, 1, 0, 0) self.add( Wedge(200, 200, 90, 72.85714, 90, yradius=90, annular=False, fillColor=Color(0, .545098, .545098, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=0, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None, radius1=30, yradius1=30)) self.add( Wedge(200, 200, 90, 38.57143, 72.85714, yradius=90, annular=False, fillColor=Color(0, .545098, .545098, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=0, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None, radius1=30, yradius1=30)) self.add( Wedge(200, 200, 90, -12.85714, 38.57143, yradius=90, annular=False, fillColor=Color(0, .545098, .545098, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=0, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None, radius1=30, yradius1=30)) self.add( Wedge(200, 200, 90, -81.42857, -12.85714, yradius=90, annular=False, fillColor=Color(0, .545098, .545098, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=0, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None, radius1=30, yradius1=30)) self.add( Wedge(200, 200, 90, -167.1429, -81.42857, yradius=90, annular=False, fillColor=Color(0, .545098, .545098, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=0, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None, radius1=30, yradius1=30)) self.add( Wedge(200, 200, 90, -270, -167.1429, yradius=90, annular=False, fillColor=Color(0, .545098, .545098, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=0, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None, radius1=30, yradius1=30)) self.add( Wedge(200, 200, 150, -306, -270, yradius=150, annular=False, fillColor=Color(.541176, .168627, .886275, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=0, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None, radius1=90, yradius1=90)) self.add( Wedge(200, 200, 150, -378, -306, yradius=150, annular=False, fillColor=Color(.541176, .168627, .886275, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=0, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None, radius1=90, yradius1=90)) self.add( Wedge(200, 200, 150, -486, -378, yradius=150, annular=False, fillColor=Color(.541176, .168627, .886275, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=0, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None, radius1=90, yradius1=90)) self.add( Wedge(200, 200, 150, -630, -486, yradius=150, annular=False, fillColor=Color(.541176, .168627, .886275, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=0, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None, radius1=90, yradius1=90)) self.add( String(226.8276, 377.9895, 'a', textAnchor='middle', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(301.3976, 348.723, 'b', textAnchor='middle', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(375.487, 240.0538, 'c', textAnchor='middle', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(322.4311, 68.05066, 'd', textAnchor='middle', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(98.60239, 51.27702, 'e', textAnchor='middle', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(59.27033, 312.2282, 'f', textAnchor='middle', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1)))
def makeWedges(self): # normalize slice data normData = self.normalizeData() n = len(normData) labels = _fixLabels(self.labels,n) xradius = self.width/2.0 yradius = self.height/2.0 centerx = self.x + xradius centery = self.y + yradius if self.direction == "anticlockwise": whichWay = 1 else: whichWay = -1 g = Group() i = 0 styleCount = len(self.slices) startAngle = self.startAngle #% 360 for angle in normData: endAngle = (startAngle + (angle * whichWay)) #% 360 if abs(startAngle-endAngle)>=1e-5: if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle #if we didn't use %stylecount here we'd end up with the later wedges #all having the default style wedgeStyle = self.slices[i%styleCount] # is it a popout? cx, cy = centerx, centery if wedgeStyle.popout <> 0: # pop out the wedge averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle * pi/180.0 popdistance = wedgeStyle.popout cx = centerx + popdistance * cos(aveAngleRadians) cy = centery + popdistance * sin(aveAngleRadians) if n > 1: theWedge = Wedge(cx, cy, xradius, a1, a2, yradius=yradius) elif n==1: theWedge = Ellipse(cx, cy, xradius, yradius) theWedge.fillColor = wedgeStyle.fillColor theWedge.strokeColor = wedgeStyle.strokeColor theWedge.strokeWidth = wedgeStyle.strokeWidth theWedge.strokeDashArray = wedgeStyle.strokeDashArray g.add(theWedge) text = labels[i] if text: averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle*pi/180.0 labelRadius = wedgeStyle.labelRadius labelX = cx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius) labelY = cy + (0.5 * self.height * sin(aveAngleRadians) * labelRadius) _addWedgeLabel(self,text,g.add,averageAngle,labelX,labelY,wedgeStyle) startAngle = endAngle i = i + 1 return g
def __init__(self, width=400, height=200, *args, **kw): Drawing.__init__(self, width, height, *args, **kw) self.transform = (1, 0, 0, 1, 0, 0) self.add( Wedge(200, 100, 75, -278.8462, -85, yradius=75, annular=False, fillColor=Color(.27451, .509804, .705882, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(200, 100, 75, -306.5385, -278.8462, yradius=75, annular=False, fillColor=Color(.847059, .74902, .847059, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(200, 100, 75, -334.2308, -306.5385, yradius=75, annular=False, fillColor=Color(.392157, .584314, .929412, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(200, 100, 75, -361.9231, -334.2308, yradius=75, annular=False, fillColor=Color(.690196, .768627, .870588, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(200, 100, 75, -389.6154, -361.9231, yradius=75, annular=False, fillColor=Color(.498039, 1, .831373, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(200, 100, 75, -445, -389.6154, yradius=75, annular=False, fillColor=Color(.372549, .619608, .627451, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( String(110, 103.0202, 'example1', textAnchor='end', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(290, 183.0331, 'example2', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(290, 157.3868, 'example3', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(290, 118.5938, 'example4', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(290, 75.54129, 'example5', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(290, 24.2575, 'example6', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( Line(125.0422, 102.5168, 117.5211, 106.0202, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(117.5211, 106.0202, 110, 106.0202, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(228.9337, 169.1942, 259.4668, 186.0331, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(259.4668, 186.0331, 290, 186.0331, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(257.7757, 147.8223, 273.8878, 160.3868, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(273.8878, 160.3868, 290, 160.3868, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(273.3819, 115.4949, 281.691, 121.5938, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(281.691, 121.5938, 290, 121.5938, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(272.1773, 79.61774, 281.0887, 78.54129, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(281.0887, 78.54129, 290, 78.54129, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(240.5096, 36.88125, 265.2548, 27.2575, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(265.2548, 27.2575, 290, 27.2575, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None))
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] n = [] for l in self.data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) self._seriesCount = max(n) else: normData = self.normalizeData(self.data) n = len(normData) self._seriesCount = n #labels if self.labels is None: labels = [] if type(n) not in (ListType,TupleType): labels = [''] * n else: for m in n: labels = list(labels) + [''] * m else: labels = self.labels #there's no point in raising errors for less than enough labels if #we silently create all for the extreme case of no labels. if type(n) not in (ListType,TupleType): i = n-len(labels) if i>0: labels = list(labels) + [''] * i else: tlab = 0 for m in n: tlab = tlab+m i = tlab-len(labels) if i>0: labels = list(labels) + [''] * i xradius = self.width/2.0 yradius = self.height/2.0 centerx = self.x + xradius centery = self.y + yradius if self.direction == "anticlockwise": whichWay = 1 else: whichWay = -1 g = Group() sn = 0 startAngle = self.startAngle #% 360 styleCount = len(self.slices) if type(self.data[0]) in (ListType, TupleType): #multi-series doughnut iradius = (self.height/5.0)/len(self.data) for series in normData: i = 0 for angle in series: endAngle = (startAngle + (angle * whichWay)) #% 360 if abs(startAngle-endAngle)>=1e-5: if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle #if we didn't use %stylecount here we'd end up with the later sectors #all having the default style sectorStyle = self.slices[i%styleCount] # is it a popout? cx, cy = centerx, centery if sectorStyle.popout != 0: # pop out the sector averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle * pi/180.0 popdistance = sectorStyle.popout cx = centerx + popdistance * cos(aveAngleRadians) cy = centery + popdistance * sin(aveAngleRadians) if type(n) in (ListType,TupleType): theSector = Wedge(cx, cy, xradius+(sn*iradius)-iradius, a1, a2, yradius=yradius+(sn*iradius)-iradius, radius1=yradius+(sn*iradius)-(2*iradius)) else: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=iradius) theSector.fillColor = sectorStyle.fillColor theSector.strokeColor = sectorStyle.strokeColor theSector.strokeWidth = sectorStyle.strokeWidth theSector.strokeDashArray = sectorStyle.strokeDashArray g.add(theSector) startAngle = endAngle text = self.getSeriesName(i,'') if text: averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle*pi/180.0 labelRadius = sectorStyle.labelRadius labelX = centerx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius) labelY = centery + (0.5 * self.height * sin(aveAngleRadians) * labelRadius) _addWedgeLabel(self,text,g.add,averageAngle,labelX,labelY,sectorStyle) i = i + 1 sn = sn + 1 else: i = 0 #single series doughnut iradius = self.height/5.0 for angle in normData: endAngle = (startAngle + (angle * whichWay)) #% 360 if abs(startAngle-endAngle)>=1e-5: if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle #if we didn't use %stylecount here we'd end up with the later sectors #all having the default style sectorStyle = self.slices[i%styleCount] # is it a popout? cx, cy = centerx, centery if sectorStyle.popout != 0: # pop out the sector averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle * pi/180.0 popdistance = sectorStyle.popout cx = centerx + popdistance * cos(aveAngleRadians) cy = centery + popdistance * sin(aveAngleRadians) if n > 1: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=iradius) elif n==1: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, iradius=iradius) theSector.fillColor = sectorStyle.fillColor theSector.strokeColor = sectorStyle.strokeColor theSector.strokeWidth = sectorStyle.strokeWidth theSector.strokeDashArray = sectorStyle.strokeDashArray g.add(theSector) # now draw a label if labels[i] != "": averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle*pi/180.0 labelRadius = sectorStyle.labelRadius labelX = centerx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius) labelY = centery + (0.5 * self.height * sin(aveAngleRadians) * labelRadius) theLabel = String(labelX, labelY, labels[i]) theLabel.textAnchor = "middle" theLabel.fontSize = sectorStyle.fontSize theLabel.fontName = sectorStyle.fontName theLabel.fillColor = sectorStyle.fontColor g.add(theLabel) startAngle = endAngle i = i + 1 return g
def makeWedges(self): angles = self.makeAngles() n = len(angles) labels = _fixLabels(self.labels,n) self._seriesCount = n styleCount = len(self.slices) plMode = self.pointerLabelMode if plMode: checkLabelOverlap = False PL=self.makePointerLabels(angles,plMode) xradius = PL.xradius yradius = PL.yradius centerx = PL.centerx centery = PL.centery PL_data = PL.data gSN = lambda i: '' else: xradius = self.width*0.5 yradius = self.height*0.5 centerx = self.x + xradius centery = self.y + yradius if self.xradius: xradius = self.xradius if self.yradius: yradius = self.yradius if self.sameRadii: xradius=yradius=min(xradius,yradius) checkLabelOverlap = self.checkLabelOverlap gSN = lambda i: self.getSeriesName(i,'') g = Group() g_add = g.add L = [] L_add = L.append for i,(a1,a2) in angles: if a2 is None: continue #if we didn't use %stylecount here we'd end up with the later wedges #all having the default style wedgeStyle = self.slices[i%styleCount] if not wedgeStyle.visible: continue # is it a popout? cx, cy = centerx, centery text = gSN(i) popout = wedgeStyle.popout if text or popout: averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle/_180_pi cosAA = cos(aveAngleRadians) sinAA = sin(aveAngleRadians) if popout: # pop out the wedge cx = centerx + popout*cosAA cy = centery + popout*sinAA if n > 1: theWedge = Wedge(cx, cy, xradius, a1, a2, yradius=yradius) elif n==1: theWedge = Ellipse(cx, cy, xradius, yradius) theWedge.fillColor = wedgeStyle.fillColor theWedge.strokeColor = wedgeStyle.strokeColor theWedge.strokeWidth = wedgeStyle.strokeWidth theWedge.strokeDashArray = wedgeStyle.strokeDashArray g_add(theWedge) if wedgeStyle.label_visible: if text: labelRadius = wedgeStyle.labelRadius rx = xradius*labelRadius ry = yradius*labelRadius labelX = cx + rx*cosAA labelY = cy + ry*sinAA l = _addWedgeLabel(self,text,averageAngle,labelX,labelY,wedgeStyle) L_add(l) if not plMode and l._simple_pointer: l._aax = cx+xradius*cosAA l._aay = cy+yradius*sinAA if checkLabelOverlap: l._origdata = { 'x': labelX, 'y':labelY, 'angle': averageAngle, 'rx': rx, 'ry':ry, 'cx':cx, 'cy':cy, 'bounds': l.getBounds(), } elif plMode and PL_data: l = PL_data[i] if l: data = l._origdata sinM = data['smid'] cosM = data['cmid'] lX = cx + xradius*cosM lY = cy + yradius*sinM lpel = wedgeStyle.label_pointer_elbowLength lXi = lX + lpel*cosM lYi = lY + lpel*sinM L_add(PolyLine((lX,lY,lXi,lYi,l.x,l.y), strokeWidth=wedgeStyle.label_pointer_strokeWidth, strokeColor=wedgeStyle.label_pointer_strokeColor)) L_add(l) if checkLabelOverlap and L: fixLabelOverlaps(L) map(g_add,L) if not plMode: for l in L: if l._simple_pointer: g_add(Line(l.x,l.y,l._aax,l._aay, strokeWidth=wedgeStyle.label_pointer_strokeWidth, strokeColor=wedgeStyle.label_pointer_strokeColor)) return g
def draw(self): slices = self.slices _3d_angle = self.angle_3d _3dva = self._3dva = _360(_3d_angle+90) a0 = _2rad(_3dva) self._xdepth_3d = cos(a0)*self.depth_3d self._ydepth_3d = sin(a0)*self.depth_3d self._cx = self.x+self.width/2.0 self._cy = self.y+(self.height - self._ydepth_3d)/2.0 radiusx = radiusy = self._cx-self.x if self.xradius: radiusx = self.xradius if self.yradius: radiusy = self.yradius self._radiusx = radiusx self._radiusy = radiusy = (1.0 - self.perspective/100.0)*radiusy data = self.normalizeData() sum = self._sum CX = self.CX CY = self.CY OX = self.OX OY = self.OY rad_dist = self.rad_dist _fillSide = self._fillSide self._seriesCount = n = len(data) _sl3d = self._sl3d = [] g = Group() last = _360(self.startAngle) a0 = self.direction=='clockwise' and -1 or 1 for v in data: v *= a0 angle1, angle0 = last, v+last last = angle0 if a0>0: angle0, angle1 = angle1, angle0 _sl3d.append(_SL3D(angle0,angle1)) labels = _fixLabels(self.labels,n) a0 = _3d_angle a1 = _3d_angle+180 T = [] S = [] L = [] class WedgeLabel3d(WedgeLabel): _ydepth_3d = self._ydepth_3d def _checkDXY(self,ba): if ba[0]=='n': if not hasattr(self,'_ody'): self._ody = self.dy self.dy = -self._ody + self._ydepth_3d checkLabelOverlap = self.checkLabelOverlap for i in xrange(n): style = slices[i] if not style.visible: continue sl = _sl3d[i] lo = angle0 = sl.lo hi = angle1 = sl.hi if abs(hi-lo)<=1e-7: continue fillColor = _getShaded(style.fillColor,style.fillColorShaded,style.shading) strokeColor = _getShaded(style.strokeColor,style.strokeColorShaded,style.shading) or fillColor strokeWidth = style.strokeWidth cx0 = CX(i,0) cy0 = CY(i,0) cx1 = CX(i,1) cy1 = CY(i,1) #background shaded pie bottom g.add(Wedge(cx1,cy1,radiusx, lo, hi,yradius=radiusy, strokeColor=strokeColor,strokeWidth=strokeWidth,fillColor=fillColor, strokeLineJoin=1)) #connect to top if lo < a0 < hi: angle0 = a0 if lo < a1 < hi: angle1 = a1 if 1: p = ArcPath(strokeColor=strokeColor, fillColor=fillColor,strokeWidth=strokeWidth,strokeLineJoin=1) p.addArc(cx1,cy1,radiusx,angle0,angle1,yradius=radiusy,moveTo=1) p.lineTo(OX(i,angle1,0),OY(i,angle1,0)) p.addArc(cx0,cy0,radiusx,angle0,angle1,yradius=radiusy,reverse=1) p.closePath() if angle0<=_3dva and angle1>=_3dva: rd = 0 else: rd = min(rad_dist(angle0),rad_dist(angle1)) S.append((rd,p)) _fillSide(S,i,lo,strokeColor,strokeWidth,fillColor) _fillSide(S,i,hi,strokeColor,strokeWidth,fillColor) #bright shaded top fillColor = style.fillColor strokeColor = style.strokeColor or fillColor T.append(Wedge(cx0,cy0,radiusx,lo,hi,yradius=radiusy, strokeColor=strokeColor,strokeWidth=strokeWidth,fillColor=fillColor,strokeLineJoin=1)) text = labels[i] if style.label_visible and text: rat = style.labelRadius self._radiusx *= rat self._radiusy *= rat mid = sl.mid labelX = OX(i,mid,0) labelY = OY(i,mid,0) l=_addWedgeLabel(self,text,mid,labelX,labelY,style,labelClass=WedgeLabel3d) L.append(l) if checkLabelOverlap: l._origdata = { 'x': labelX, 'y':labelY, 'angle': mid, 'rx': self._radiusx, 'ry':self._radiusy, 'cx':CX(i,0), 'cy':CY(i,0), 'bounds': l.getBounds(), } self._radiusx = radiusx self._radiusy = radiusy S.sort(lambda a,b: -cmp(a[0],b[0])) if checkLabelOverlap and L: fixLabelOverlaps(L) map(g.add,map(lambda x:x[1],S)+T+L) return g
def makeSectors(self): # normalize slice data if isinstance(self.data,(list,tuple)) and isinstance(self.data[0],(list,tuple)): #it's a nested list, more than one sequence normData = [] n = [] for l in self.data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) self._seriesCount = max(n) else: normData = self.normalizeData(self.data) n = len(normData) self._seriesCount = n #labels checkLabelOverlap = self.checkLabelOverlap L = [] L_add = L.append if self.labels is None: labels = [] if not isinstance(n,(list,tuple)): labels = [''] * n else: for m in n: labels = list(labels) + [''] * m else: labels = self.labels #there's no point in raising errors for less than enough labels if #we silently create all for the extreme case of no labels. if not isinstance(n,(list,tuple)): i = n-len(labels) if i>0: labels = list(labels) + [''] * i else: tlab = 0 for m in n: tlab += m i = tlab-len(labels) if i>0: labels = list(labels) + [''] * i xradius = self.width/2.0 yradius = self.height/2.0 centerx = self.x + xradius centery = self.y + yradius if self.direction == "anticlockwise": whichWay = 1 else: whichWay = -1 g = Group() startAngle = self.startAngle #% 360 styleCount = len(self.slices) if isinstance(self.data[0],(list,tuple)): #multi-series doughnut iradius = (self.height/5.0)/len(self.data) for sn,series in enumerate(normData): for i,angle in enumerate(series): endAngle = (startAngle + (angle * whichWay)) #% 360 if abs(startAngle-endAngle)<1e-5: startAngle = endAngle continue if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle startAngle = endAngle #if we didn't use %stylecount here we'd end up with the later sectors #all having the default style sectorStyle = self.slices[i%styleCount] # is it a popout? cx, cy = centerx, centery if sectorStyle.popout != 0: # pop out the sector averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle * pi/180.0 popdistance = sectorStyle.popout cx = centerx + popdistance * cos(aveAngleRadians) cy = centery + popdistance * sin(aveAngleRadians) if isinstance(n,(list,tuple)): theSector = Wedge(cx, cy, xradius+(sn*iradius)-iradius, a1, a2, yradius=yradius+(sn*iradius)-iradius, radius1=yradius+(sn*iradius)-(2*iradius)) else: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=iradius) theSector.fillColor = sectorStyle.fillColor theSector.strokeColor = sectorStyle.strokeColor theSector.strokeWidth = sectorStyle.strokeWidth theSector.strokeDashArray = sectorStyle.strokeDashArray g.add(theSector) if sn == 0: text = self.getSeriesName(i,'') if text: averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle*pi/180.0 labelRadius = sectorStyle.labelRadius rx = xradius*labelRadius ry = yradius*labelRadius labelX = centerx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius) labelY = centery + (0.5 * self.height * sin(aveAngleRadians) * labelRadius) l = _addWedgeLabel(self,text,averageAngle,labelX,labelY,sectorStyle) if checkLabelOverlap: l._origdata = { 'x': labelX, 'y':labelY, 'angle': averageAngle, 'rx': rx, 'ry':ry, 'cx':cx, 'cy':cy, 'bounds': l.getBounds(), } L_add(l) else: #single series doughnut iradius = self.height/5.0 for i,angle in enumerate(normData): endAngle = (startAngle + (angle * whichWay)) #% 360 if abs(startAngle-endAngle)<1e-5: startAngle = endAngle continue if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle startAngle = endAngle #if we didn't use %stylecount here we'd end up with the later sectors #all having the default style sectorStyle = self.slices[i%styleCount] # is it a popout? cx, cy = centerx, centery if sectorStyle.popout != 0: # pop out the sector averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle * pi/180.0 popdistance = sectorStyle.popout cx = centerx + popdistance * cos(aveAngleRadians) cy = centery + popdistance * sin(aveAngleRadians) if n > 1: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=iradius) elif n==1: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=iradius, annular=True) theSector.fillColor = sectorStyle.fillColor theSector.strokeColor = sectorStyle.strokeColor theSector.strokeWidth = sectorStyle.strokeWidth theSector.strokeDashArray = sectorStyle.strokeDashArray g.add(theSector) # now draw a label if labels[i] != "": averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle*pi/180.0 labelRadius = sectorStyle.labelRadius labelX = centerx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius) labelY = centery + (0.5 * self.height * sin(aveAngleRadians) * labelRadius) rx = xradius*labelRadius ry = yradius*labelRadius l = _addWedgeLabel(self,labels[i],averageAngle,labelX,labelY,sectorStyle) if checkLabelOverlap: l._origdata = { 'x': labelX, 'y':labelY, 'angle': averageAngle, 'rx': rx, 'ry':ry, 'cx':cx, 'cy':cy, 'bounds': l.getBounds(), } L_add(l) if checkLabelOverlap and L: fixLabelOverlaps(L) for l in L: g.add(l) return g
def __init__(self, width=400, height=200, *args, **kw): Drawing.__init__(self, width, height, *args, **kw) self.transform = (1, 0, 0, 1, 0, 0) self.add( Wedge(200, 100, 75, -176.4, 90, yradius=75, annular=False, fillColor=Color(.27451, .509804, .705882, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(200, 100, 75, -180, -176.4, yradius=75, annular=False, fillColor=Color(.847059, .74902, .847059, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(200, 100, 75, -183.6, -180, yradius=75, annular=False, fillColor=Color(.392157, .584314, .929412, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(200, 100, 75, -187.2, -183.6, yradius=75, annular=False, fillColor=Color(.690196, .768627, .870588, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(200, 100, 75, -190.8, -187.2, yradius=75, annular=False, fillColor=Color(.498039, 1, .831373, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(200, 100, 75, -270, -190.8, yradius=75, annular=False, fillColor=Color(.372549, .619608, .627451, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None))
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): # it's a nested list, more than one sequence normData = [] n = [] for l in self.data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) else: normData = self.normalizeData(self.data) n = len(normData) # labels if self.labels is None: labels = [] if type(n) not in (ListType, TupleType): labels = [""] * n else: for m in n: labels = list(labels) + [""] * m else: labels = self.labels # there's no point in raising errors for less than enough errors if # we silently create all for the extreme case of no labels. if type(n) not in (ListType, TupleType): i = n - len(labels) if i > 0: labels = list(labels) + [""] * i else: tlab = 0 for m in n: tlab = tlab + m i = tlab - len(labels) if i > 0: labels = list(labels) + [""] * i xradius = self.width / 2.0 yradius = self.height / 2.0 centerx = self.x + xradius centery = self.y + yradius if self.direction == "anticlockwise": whichWay = 1 else: whichWay = -1 g = Group() i = 0 sn = 0 startAngle = self.startAngle #% 360 if type(self.data[0]) in (ListType, TupleType): # multi-series doughnut styleCount = len(self.slices) iradius = (self.height / 5.0) / len(self.data) for series in normData: for angle in series: endAngle = startAngle + (angle * whichWay) #% 360 if abs(startAngle - endAngle) >= 1e-5: if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle # if we didn't use %stylecount here we'd end up with the later sectors # all having the default style sectorStyle = self.slices[i % styleCount] # is it a popout? cx, cy = centerx, centery if sectorStyle.popout != 0: # pop out the sector averageAngle = (a1 + a2) / 2.0 aveAngleRadians = averageAngle * pi / 180.0 popdistance = sectorStyle.popout cx = centerx + popdistance * cos(aveAngleRadians) cy = centery + popdistance * sin(aveAngleRadians) if type(n) in (ListType, TupleType): theSector = Wedge( cx, cy, xradius + (sn * iradius) - iradius, a1, a2, yradius=yradius + (sn * iradius) - iradius, radius1=yradius + (sn * iradius) - (2 * iradius), ) else: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=iradius) theSector.fillColor = sectorStyle.fillColor theSector.strokeColor = sectorStyle.strokeColor theSector.strokeWidth = sectorStyle.strokeWidth theSector.strokeDashArray = sectorStyle.strokeDashArray g.add(theSector) startAngle = endAngle if labels[i] != "": averageAngle = (a1 + a2) / 2.0 aveAngleRadians = averageAngle * pi / 180.0 labelRadius = sectorStyle.labelRadius labelX = centerx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius) labelY = centery + (0.5 * self.height * sin(aveAngleRadians) * labelRadius) theLabel = String(labelX, labelY, labels[i]) theLabel.textAnchor = "middle" theLabel.fontSize = sectorStyle.fontSize theLabel.fontName = sectorStyle.fontName theLabel.fillColor = sectorStyle.fontColor g.add(theLabel) i = i + 1 sn = sn + 1 else: # single series doughnut styleCount = len(self.slices) iradius = self.height / 5.0 for angle in normData: endAngle = startAngle + (angle * whichWay) #% 360 if abs(startAngle - endAngle) >= 1e-5: if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle # if we didn't use %stylecount here we'd end up with the later sectors # all having the default style sectorStyle = self.slices[i % styleCount] # is it a popout? cx, cy = centerx, centery if sectorStyle.popout != 0: # pop out the sector averageAngle = (a1 + a2) / 2.0 aveAngleRadians = averageAngle * pi / 180.0 popdistance = sectorStyle.popout cx = centerx + popdistance * cos(aveAngleRadians) cy = centery + popdistance * sin(aveAngleRadians) if n > 1: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=iradius) elif n == 1: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, iradius=iradius) theSector.fillColor = sectorStyle.fillColor theSector.strokeColor = sectorStyle.strokeColor theSector.strokeWidth = sectorStyle.strokeWidth theSector.strokeDashArray = sectorStyle.strokeDashArray g.add(theSector) # now draw a label if labels[i] != "": averageAngle = (a1 + a2) / 2.0 aveAngleRadians = averageAngle * pi / 180.0 labelRadius = sectorStyle.labelRadius labelX = centerx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius) labelY = centery + (0.5 * self.height * sin(aveAngleRadians) * labelRadius) theLabel = String(labelX, labelY, labels[i]) theLabel.textAnchor = "middle" theLabel.fontSize = sectorStyle.fontSize theLabel.fontName = sectorStyle.fontName theLabel.fillColor = sectorStyle.fontColor g.add(theLabel) startAngle = endAngle i = i + 1 return g
def sample1(): "Make up something from the individual Sectors" d = Drawing(400, 400) g = Group() s1 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=0, endangledegrees=120, radius1=100) s1.fillColor = colors.red s1.strokeColor = None d.add(s1) s2 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=120, endangledegrees=240, radius1=100) s2.fillColor = colors.green s2.strokeColor = None d.add(s2) s3 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=240, endangledegrees=260, radius1=100) s3.fillColor = colors.blue s3.strokeColor = None d.add(s3) s4 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=260, endangledegrees=360, radius1=100) s4.fillColor = colors.gray s4.strokeColor = None d.add(s4) return d
def _Flag_Brazil(self): s = _size # abbreviate as we will use this a lot g = Group() m = s / 14.0 self._width = w = (m * 20) def addStar(x, y, size, g=g, w=w, s=s, m=m): st = Star() st.fillColor = colors.mintcream st.size = size * m st.x = (w / 2.0) + (x * (0.35 * m)) st.y = (s / 2.0) + (y * (0.35 * m)) g.add(st) g.add( Rect(0, 0, w, s, fillColor=colors.green, strokeColor=None, strokeWidth=0)) g.add( Polygon(points=[ 1.7 * m, (s / 2.0), (w / 2.0), s - (1.7 * m), w - (1.7 * m), (s / 2.0), (w / 2.0), 1.7 * m ], fillColor=colors.yellow, strokeColor=None, strokeWidth=0)) g.add( Circle(cx=w / 2.0, cy=s / 2.0, r=3.5 * m, fillColor=colors.blue, strokeColor=None, strokeWidth=0)) g.add( Wedge((w / 2.0) - (2 * m), 0, 8.5 * m, 50, 98.1, 8.5 * m, fillColor=colors.mintcream, strokeColor=None, strokeWidth=0)) g.add( Wedge((w / 2.0), (s / 2.0), 3.501 * m, 156, 352, 3.501 * m, fillColor=colors.mintcream, strokeColor=None, strokeWidth=0)) g.add( Wedge((w / 2.0) - (2 * m), 0, 8 * m, 48.1, 100, 8 * m, fillColor=colors.blue, strokeColor=None, strokeWidth=0)) g.add( Rect(0, 0, w, (s / 4.0) + 1.7 * m, fillColor=colors.green, strokeColor=None, strokeWidth=0)) g.add( Polygon(points=[ 1.7 * m, (s / 2.0), (w / 2.0), s / 2.0 - 2 * m, w - (1.7 * m), (s / 2.0), (w / 2.0), 1.7 * m ], fillColor=colors.yellow, strokeColor=None, strokeWidth=0)) g.add( Wedge(w / 2.0, s / 2.0, 3.502 * m, 166, 342.1, 3.502 * m, fillColor=colors.blue, strokeColor=None, strokeWidth=0)) addStar(3.2, 3.5, 0.3) addStar(-8.5, 1.5, 0.3) addStar(-7.5, -3, 0.3) addStar(-4, -5.5, 0.3) addStar(0, -4.5, 0.3) addStar(7, -3.5, 0.3) addStar(-3.5, -0.5, 0.25) addStar(0, -1.5, 0.25) addStar(1, -2.5, 0.25) addStar(3, -7, 0.25) addStar(5, -6.5, 0.25) addStar(6.5, -5, 0.25) addStar(7, -4.5, 0.25) addStar(-5.5, -3.2, 0.25) addStar(-6, -4.2, 0.25) addStar(-1, -2.75, 0.2) addStar(2, -5.5, 0.2) addStar(4, -5.5, 0.2) addStar(5, -7.5, 0.2) addStar(5, -5.5, 0.2) addStar(6, -5.5, 0.2) addStar(-8.8, -3.2, 0.2) addStar(2.5, 0.5, 0.2) addStar(-0.2, -3.2, 0.14) addStar(-7.2, -2, 0.14) addStar(0, -8, 0.1) sTmp = "ORDEM E PROGRESSO" nTmp = len(sTmp) delta = 0.850848010347 / nTmp radius = 7.9 * m centerx = (w / 2.0) - (2 * m) centery = 0 for i in range(nTmp): rad = 2 * pi - i * delta - 4.60766922527 x = cos(rad) * radius + centerx y = sin(rad) * radius + centery if i == 6: z = 0.35 * m else: z = 0.45 * m g2 = Group( String(x, y, sTmp[i], fontName='Helvetica-Bold', fontSize=z, strokeColor=None, fillColor=colors.green)) g2.rotate(rad) g.add(g2) return g
def makeSectors(self): # normalize slice data data = self.data multi = isListOfListOfNoneOrNumber(data) if multi: #it's a nested list, more than one sequence normData = [] n = [] for l in data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) self._seriesCount = max(n) else: normData = self.normalizeData(data) n = len(normData) self._seriesCount = n #labels checkLabelOverlap = self.checkLabelOverlap L = [] L_add = L.append labels = self.labels if labels is None: labels = [] if not multi: labels = [''] * n else: for m in n: labels = list(labels) + [''] * m else: #there's no point in raising errors for less than enough labels if #we silently create all for the extreme case of no labels. if not multi: i = n-len(labels) if i>0: labels = list(labels) + [''] * i else: tlab = 0 for m in n: tlab += m i = tlab-len(labels) if i>0: labels = list(labels) + [''] * i self.labels = labels xradius = self.width/2.0 yradius = self.height/2.0 centerx = self.x + xradius centery = self.y + yradius if self.direction == "anticlockwise": whichWay = 1 else: whichWay = -1 g = Group() startAngle = self.startAngle #% 360 styleCount = len(self.slices) irf = self.innerRadiusFraction if multi: #multi-series doughnut ndata = len(data) if irf is None: yir = (yradius/2.5)/ndata xir = (xradius/2.5)/ndata else: yir = yradius*irf xir = xradius*irf ydr = (yradius-yir)/ndata xdr = (xradius-xir)/ndata for sn,series in enumerate(normData): for i,angle in enumerate(series): endAngle = (startAngle + (angle * whichWay)) #% 360 aa = abs(startAngle-endAngle) if aa<1e-5: startAngle = endAngle continue if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle startAngle = endAngle #if we didn't use %stylecount here we'd end up with the later sectors #all having the default style sectorStyle = self.slices[sn,i%styleCount] # is it a popout? cx, cy = centerx, centery if sectorStyle.popout != 0: # pop out the sector averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle * pi/180.0 popdistance = sectorStyle.popout cx = centerx + popdistance * cos(aveAngleRadians) cy = centery + popdistance * sin(aveAngleRadians) yr1 = yir+sn*ydr yr = yr1 + ydr xr1 = xir+sn*xdr xr = xr1 + xdr if len(series) > 1: theSector = Wedge(cx, cy, xr, a1, a2, yradius=yr, radius1=xr1, yradius1=yr1) else: theSector = Wedge(cx, cy, xr, a1, a2, yradius=yr, radius1=xr1, yradius1=yr1, annular=True) theSector.fillColor = sectorStyle.fillColor theSector.strokeColor = sectorStyle.strokeColor theSector.strokeWidth = sectorStyle.strokeWidth theSector.strokeDashArray = sectorStyle.strokeDashArray shader = sectorStyle.shadingKind if shader: nshades = aa / float(sectorStyle.shadingAngle) if nshades > 1: shader = colors.Whiter if shader=='lighten' else colors.Blacker nshades = 1+int(nshades) shadingAmount = 1-sectorStyle.shadingAmount if sectorStyle.shadingDirection=='normal': dsh = (1-shadingAmount)/float(nshades-1) shf1 = shadingAmount else: dsh = (shadingAmount-1)/float(nshades-1) shf1 = 1 shda = (a2-a1)/float(nshades) shsc = sectorStyle.fillColor theSector.fillColor = None for ish in xrange(nshades): sha1 = a1 + ish*shda sha2 = a1 + (ish+1)*shda shc = shader(shsc,shf1 + dsh*ish) if len(series)>1: shSector = Wedge(cx, cy, xr, sha1, sha2, yradius=yr, radius1=xr1, yradius1=yr1) else: shSector = Wedge(cx, cy, xr, sha1, sha2, yradius=yr, radius1=xr1, yradius1=yr1, annular=True) shSector.fillColor = shc shSector.strokeColor = None shSector.strokeWidth = 0 g.add(shSector) g.add(theSector) if sn == 0 and sectorStyle.visible and sectorStyle.label_visible: text = self.getSeriesName(i,'') if text: averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle*pi/180.0 labelRadius = sectorStyle.labelRadius rx = xradius*labelRadius ry = yradius*labelRadius labelX = centerx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius) labelY = centery + (0.5 * self.height * sin(aveAngleRadians) * labelRadius) l = _addWedgeLabel(self,text,averageAngle,labelX,labelY,sectorStyle) if checkLabelOverlap: l._origdata = { 'x': labelX, 'y':labelY, 'angle': averageAngle, 'rx': rx, 'ry':ry, 'cx':cx, 'cy':cy, 'bounds': l.getBounds(), } L_add(l) else: #single series doughnut if irf is None: yir = yradius/2.5 xir = xradius/2.5 else: yir = yradius*irf xir = xradius*irf for i,angle in enumerate(normData): endAngle = (startAngle + (angle * whichWay)) #% 360 aa = abs(startAngle-endAngle) if aa<1e-5: startAngle = endAngle continue if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle startAngle = endAngle #if we didn't use %stylecount here we'd end up with the later sectors #all having the default style sectorStyle = self.slices[i%styleCount] # is it a popout? cx, cy = centerx, centery if sectorStyle.popout != 0: # pop out the sector averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle * pi/180.0 popdistance = sectorStyle.popout cx = centerx + popdistance * cos(aveAngleRadians) cy = centery + popdistance * sin(aveAngleRadians) if n > 1: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=xir, yradius1=yir) elif n==1: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=xir, yradius1=yir, annular=True) theSector.fillColor = sectorStyle.fillColor theSector.strokeColor = sectorStyle.strokeColor theSector.strokeWidth = sectorStyle.strokeWidth theSector.strokeDashArray = sectorStyle.strokeDashArray shader = sectorStyle.shadingKind if shader: nshades = aa / float(sectorStyle.shadingAngle) if nshades > 1: shader = colors.Whiter if shader=='lighten' else colors.Blacker nshades = 1+int(nshades) shadingAmount = 1-sectorStyle.shadingAmount if sectorStyle.shadingDirection=='normal': dsh = (1-shadingAmount)/float(nshades-1) shf1 = shadingAmount else: dsh = (shadingAmount-1)/float(nshades-1) shf1 = 1 shda = (a2-a1)/float(nshades) shsc = sectorStyle.fillColor theSector.fillColor = None for ish in xrange(nshades): sha1 = a1 + ish*shda sha2 = a1 + (ish+1)*shda shc = shader(shsc,shf1 + dsh*ish) if n > 1: shSector = Wedge(cx, cy, xradius, sha1, sha2, yradius=yradius, radius1=xir, yradius1=yir) elif n==1: shSector = Wedge(cx, cy, xradius, sha1, sha2, yradius=yradius, radius1=xir, yradius1=yir, annular=True) shSector.fillColor = shc shSector.strokeColor = None shSector.strokeWidth = 0 g.add(shSector) g.add(theSector) # now draw a label if labels[i] and sectorStyle.visible and sectorStyle.label_visible: averageAngle = (a1+a2)/2.0 aveAngleRadians = averageAngle*pi/180.0 labelRadius = sectorStyle.labelRadius labelX = centerx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius) labelY = centery + (0.5 * self.height * sin(aveAngleRadians) * labelRadius) rx = xradius*labelRadius ry = yradius*labelRadius l = _addWedgeLabel(self,labels[i],averageAngle,labelX,labelY,sectorStyle) if checkLabelOverlap: l._origdata = { 'x': labelX, 'y':labelY, 'angle': averageAngle, 'rx': rx, 'ry':ry, 'cx':cx, 'cy':cy, 'bounds': l.getBounds(), } L_add(l) if checkLabelOverlap and L: fixLabelOverlaps(L) for l in L: g.add(l) return g
def __init__(self, width=400, height=200, *args, **kw): Drawing.__init__(self, width, height, *args, **kw) self.transform = (1, 0, 0, 1, 0, 0) self.add( Wedge(175, 100, 50, -127.3684, -95, yradius=50, annular=False, fillColor=Color(.27451, .509804, .705882, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -143.1579, -127.3684, yradius=50, annular=False, fillColor=Color(.847059, .74902, .847059, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -174.7368, -143.1579, yradius=50, annular=False, fillColor=Color(.392157, .584314, .929412, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -186.5789, -174.7368, yradius=50, annular=False, fillColor=Color(.690196, .768627, .870588, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -202.3684, -186.5789, yradius=50, annular=False, fillColor=Color(.498039, 1, .831373, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -226.0526, -202.3684, yradius=50, annular=False, fillColor=Color(.372549, .619608, .627451, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -265.5263, -226.0526, yradius=50, annular=False, fillColor=Color(1, 1, 0, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -277.3684, -265.5263, yradius=50, annular=False, fillColor=Color(.27451, .509804, .705882, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -297.1053, -277.3684, yradius=50, annular=False, fillColor=Color(.847059, .74902, .847059, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -324.7368, -297.1053, yradius=50, annular=False, fillColor=Color(.392157, .584314, .929412, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -344.4737, -324.7368, yradius=50, annular=False, fillColor=Color(.690196, .768627, .870588, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -360.2632, -344.4737, yradius=50, annular=False, fillColor=Color(.498039, 1, .831373, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -383.9474, -360.2632, yradius=50, annular=False, fillColor=Color(.372549, .619608, .627451, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -415.5263, -383.9474, yradius=50, annular=False, fillColor=Color(1, 1, 0, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -431.3158, -415.5263, yradius=50, annular=False, fillColor=Color(.27451, .509804, .705882, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Wedge(175, 100, 50, -455, -431.3158, yradius=50, annular=False, fillColor=Color(.847059, .74902, .847059, 1), fillOpacity=None, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( String(115, 44.05459, 'example1', textAnchor='end', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(115, 57.7689, 'example2', textAnchor='end', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(115, 78.44648, 'example3', textAnchor='end', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(115, 100.6889, 'example4', textAnchor='end', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(115, 114.9961, 'example5', textAnchor='end', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(115, 133.7341, 'example6', textAnchor='end', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(115, 154.7227, 'example7', textAnchor='end', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(235, 165.9809, 'example8', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(235, 157.3053, 'example9', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(235, 145.3368, 'example10', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(235, 125.7311, 'example11', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(235, 107.9682, 'example12', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(235, 87.4175, 'example13', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(235, 61.64425, 'example14', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(235, 52.34088, 'example15', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( String(235, 40.42731, 'example16', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( Line(156.9316, 53.37883, 135.9658, 47.05459, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(135.9658, 47.05459, 115, 47.05459, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(139.4826, 64.80742, 127.2413, 60.7689, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(127.2413, 60.7689, 115, 60.7689, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(128.3375, 82.03873, 121.6687, 81.44648, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(121.6687, 81.44648, 115, 81.44648, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(125.0033, 100.5741, 120.0016, 103.6889, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(120.0016, 103.6889, 115, 103.6889, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(126.5869, 112.4968, 120.7934, 117.9961, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(120.7934, 117.9961, 115, 117.9961, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(133.6511, 128.1118, 124.3256, 136.7341, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(124.3256, 136.7341, 115, 136.7341, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(154.4955, 145.6022, 134.7477, 157.7227, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(134.7477, 157.7227, 115, 157.7227, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(176.2629, 149.984, 205.6315, 168.9809, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(205.6315, 168.9809, 235, 168.9809, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(189.8161, 147.7544, 212.4081, 160.3053, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(212.4081, 160.3053, 235, 160.3053, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(207.7509, 137.7806, 221.3755, 148.3368, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(221.3755, 148.3368, 235, 148.3368, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(220.1687, 121.4426, 227.5844, 128.7311, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(227.5844, 128.7311, 235, 128.7311, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(224.5571, 106.6401, 229.7786, 110.9682, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(229.7786, 110.9682, 235, 110.9682, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(223.8882, 89.51458, 229.4441, 90.4175, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(229.4441, 90.4175, 235, 90.4175, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(213.4494, 68.03688, 224.2247, 64.64425, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(224.2247, 64.64425, 235, 64.64425, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(197.3715, 55.28406, 216.1858, 55.34088, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(216.1858, 55.34088, 235, 55.34088, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(180.9567, 50.35609, 207.9783, 43.42731, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(207.9783, 43.42731, 235, 43.42731, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None))