def draw(self): s = float(self.size) #abbreviate as we will use this a lot g = Group() # new algorithm from markers.StarFive R = float(self.size) / 2 r = R * sin(18 * (pi / 180.0)) / cos(36 * (pi / 180.0)) P = [] angle = 90 for i in xrange(5): for radius in R, r: theta = angle * (pi / 180.0) P.append(radius * cos(theta)) P.append(radius * sin(theta)) angle = angle + 36 # star specific bits star = Polygon(P, fillColor=self.fillColor, strokeColor=self.strokeColor, strokeWidth=s / 50) g.rotate(self.angle) g.shift(self.x + self.dx, self.y + self.dy) g.add(star) return g
def draw(self): sx = 0.5 fillColor = self.fillColor strokeColor = self.strokeColor shadow = Color(fillColor.red * sx, fillColor.green * sx, fillColor.blue * sx) g = Group() g2 = Group() g.add( Rect(fillColor=fillColor, strokeColor=fillColor, x=0, y=0, width=self._w, height=self._h)) sx = (self._w - 2) / self._sw() g2.scale(sx, 1) self._addPage(g2, strokeWidth=3, dx=2, dy=-2.5, color=shadow) self._addPage(g2, strokeWidth=3, color=strokeColor) g2.scale(1 / sx, 1) g2.add(self._getText(x=1, y=0, color=shadow)) g2.add(self._getText(x=0, y=1, color=strokeColor)) g2.scale(sx, 1) g2.skew(kx=10, ky=0) g2.shift(0, 38) g.add(g2) g.scale(self.width / self._w, self.height / self._h) g.shift(self.x, self.y) return g
def draw(self): s = float(self.size) #abbreviate as we will use this a lot g = Group() # new algorithm from markers.StarFive R = float(self.size)/2 r = R*sin(18*(pi/180.0))/cos(36*(pi/180.0)) P = [] angle = 90 for i in xrange(5): for radius in R, r: theta = angle*(pi/180.0) P.append(radius*cos(theta)) P.append(radius*sin(theta)) angle = angle + 36 # star specific bits star = Polygon(P, fillColor = self.fillColor, strokeColor = self.strokeColor, strokeWidth=s/50) g.rotate(self.angle) g.shift(self.x+self.dx,self.y+self.dy) g.add(star) return g
def _borderDraw(self,f): s = self.size # abbreviate as we will use this a lot g = Group() g.add(f) x, y, sW = self.x+self.dx, self.y+self.dy, self.strokeWidth/2. g.insert(0,Rect(-sW, -sW, width=getattr(self,'_width',2*s)+3*sW, height=getattr(self,'_height',s)+2*sW, fillColor = None, strokeColor = self.strokeColor, strokeWidth=sW*2)) g.shift(x,y) g.scale(s/_size, s/_size) return g
def draw(self): fillColor = self.fillColor strokeColor = self.strokeColor g = Group() bg = self.background bd = self.border bdw = self.borderWidth shadow = self.shadow x, y = self.x, self.y if bg: if shadow is not None and 0 <= shadow < 1: shadow = Color(bg.red * shadow, bg.green * shadow, bg.blue * shadow) self._paintLogo(g, dy=-2.5, dx=2, fillColor=shadow) self._paintLogo(g, fillColor=fillColor, strokeColor=strokeColor, _ocolors=getattr(self, '_ocolors', None), _pagecolors=getattr(self, '_pagecolors', None)) g.skew(kx=self.skewX, ky=self.skewY) g.shift(self._dx, self._dy) G = Group() G.add(g) _w, _h = 130, 86 w, h = self.width, self.height if bg or (bd and bdw): G.insert( 0, Rect(0, 0, _w, _h, fillColor=bg, strokeColor=bd, strokeWidth=bdw)) if w != _w or h != _h: G.scale(w / float(_w), h / float(_h)) angle = self.angle if self.angle: w, h = w / 2., h / 2. G.shift(-w, -h) G.rotate(angle) G.shift(w, h) xFlip = getattr(self, 'xFlip', 0) and -1 or 0 yFlip = getattr(self, 'yFlip', 0) and -1 or 0 if xFlip or yFlip: sx = xFlip or 1 sy = yFlip or 1 G.shift(sx * x + w * xFlip, sy * y + yFlip * h) G = Group(G, transform=(sx, 0, 0, sy, 0, 0)) else: G.shift(x, y) return G
def draw(self): fillColor = self.fillColor strokeColor = self.strokeColor g = Group() bg = self.background bd = self.border bdw = self.borderWidth shadow = self.shadow x, y = self.x, self.y if bg: if shadow is not None and 0<=shadow<1: shadow = Color(bg.red*shadow,bg.green*shadow,bg.blue*shadow) self._paintLogo(g,dy=-2.5, dx=2,fillColor=shadow) self._paintLogo(g,fillColor=fillColor,strokeColor=strokeColor) g.skew(kx=self.skewX, ky=self.skewY) g.shift(self._dx,self._dy) G = Group() G.add(g) _w, _h = 130, 86 w, h = self.width, self.height if bg or (bd and bdw): G.insert(0,Rect(0,0,_w,_h,fillColor=bg,strokeColor=bd,strokeWidth=bdw)) if w!=_w or h!=_h: G.scale(w/float(_w),h/float(_h)) angle = self.angle if self.angle: w, h = w/2., h/2. G.shift(-w,-h) G.rotate(angle) G.shift(w,h) G.shift(x,y) return G
def draw(self): fillColor = self.fillColor strokeColor = self.strokeColor g = Group() bg = self.background bd = self.border bdw = self.borderWidth shadow = self.shadow x, y = self.x, self.y if bg: if shadow is not None and 0 <= shadow < 1: shadow = Color(bg.red * shadow, bg.green * shadow, bg.blue * shadow) self._paintLogo(g, dy=-2.5, dx=2, fillColor=shadow) self._paintLogo( g, fillColor=fillColor, strokeColor=strokeColor, _ocolors=getattr(self, "_ocolors", None), _pagecolors=getattr(self, "_pagecolors", None), ) g.skew(kx=self.skewX, ky=self.skewY) g.shift(self._dx, self._dy) G = Group() G.add(g) _w, _h = 130, 86 w, h = self.width, self.height if bg or (bd and bdw): G.insert(0, Rect(0, 0, _w, _h, fillColor=bg, strokeColor=bd, strokeWidth=bdw)) if w != _w or h != _h: G.scale(w / float(_w), h / float(_h)) angle = self.angle if self.angle: w, h = w / 2.0, h / 2.0 G.shift(-w, -h) G.rotate(angle) G.shift(w, h) xFlip = getattr(self, "xFlip", 0) and -1 or 0 yFlip = getattr(self, "yFlip", 0) and -1 or 0 if xFlip or yFlip: sx = xFlip or 1 sy = yFlip or 1 G.shift(sx * x + w * xFlip, sy * y + yFlip * h) G = Group(G, transform=(sx, 0, 0, sy, 0, 0)) else: G.shift(x, y) return G
def draw(self): sx = 0.5 fillColor = self.fillColor strokeColor = self.strokeColor shadow = Color(fillColor.red*sx,fillColor.green*sx,fillColor.blue*sx) g = Group() g2= Group() g.add(Rect(fillColor=fillColor, strokeColor=fillColor, x=0, y=0, width=self._w, height=self._h)) sx = (self._w-2)/self._sw() g2.scale(sx,1) self._addPage(g2,strokeWidth=3,dx=2,dy=-2.5,color=shadow) self._addPage(g2,strokeWidth=3,color=strokeColor) g2.scale(1/sx,1) g2.add(self._getText(x=1,y=0,color=shadow)) g2.add(self._getText(x=0,y=1,color=strokeColor)) g2.scale(sx,1) g2.skew(kx=10, ky=0) g2.shift(0,38) g.add(g2) g.scale(self.width/self._w,self.height/self._h) g.shift(self.x,self.y) return g
def draw(self): fillColor = self.fillColor strokeColor = self.strokeColor g = Group() g.add(Rect(x = 0, y = 0, fillColor = self.fillColor, strokeColor = self.fillColor, width = self.borderWidth, height = self.height)) g.add(Rect(x = 0, y = self.height-self.borderWidth, fillColor = self.fillColor, strokeColor = self.fillColor, width = self.width, height = self.borderWidth)) g2 = Group() rl=RL_CorpLogo() rl.height = 1.25*cm rl.width = 1.9*cm rl.draw() g2.add(rl) g.add(g2) g2.shift(x=(self.width-(rl.width+(self.width/42))), y=(self.height - (rl.height+(self.height/42)))) g.add(String(x = self.borderWidth/5.0, y = ((self.height - (rl.height+(self.height/42)))+((38/90.5)*rl.height)), fontSize = 6, fillColor = self.altStrokeColor, fontName = "Helvetica-BoldOblique", textAnchor = 'start', text = self._strapline)) leftText=["Tel:", "Mobile:", "Fax:", "Email:", "Web:"] leftDetails=[self.telephone,self.mobile,self.fax,self.email,self.web] leftText.reverse() leftDetails.reverse() for f in range(len(leftText),0,-1): g.add(String(x = self.borderWidth+(self.borderWidth/5.0), y = (self.borderWidth/5.0)+((f-1)*(5*1.2)), fontSize = 5, fillColor = self.strokeColor, fontName = "Helvetica", textAnchor = 'start', text = leftText[f-1])) g.add(String(x = self.borderWidth+(self.borderWidth/5.0)+self.borderWidth, y = (self.borderWidth/5.0)+((f-1)*(5*1.2)), fontSize = 5, fillColor = self.strokeColor, fontName = "Helvetica", textAnchor = 'start', text = leftDetails[f-1])) rightText=self.rh_blurb_bottom rightText.reverse() for f in range(len(rightText),0,-1): g.add(String(x = self.width-((self.borderWidth/5.0)), y = (self.borderWidth/5.0)+((f-1)*(5*1.2)), fontSize = 5, fillColor = self.strokeColor, fontName = "Helvetica", textAnchor = 'end', text = rightText[f-1])) ty = (self.height-self.borderWidth-(self.borderWidth/5.0)+2) # g.add(Line(self.borderWidth, ty, self.borderWidth+(self.borderWidth/5.0), ty)) # g.add(Line(self.borderWidth+(self.borderWidth/5.0), ty, self.borderWidth+(self.borderWidth/5.0), # ty+(self.borderWidth/5.0))) # g.add(Line(self.borderWidth, ty-10, # self.borderWidth+(self.borderWidth/5.0), ty-10)) rightText=self.rh_blurb_top for f in range(1,(len(rightText)+1)): g.add(String(x = self.width-(self.borderWidth/5.0), y = ty-((f)*(5*1.2)), fontSize = 5, fillColor = self.strokeColor, fontName = "Helvetica", textAnchor = 'end', text = rightText[f-1])) g.add(String(x = self.borderWidth+(self.borderWidth/5.0), y = ty-10, fontSize = 10, fillColor = self.strokeColor, fontName = "Helvetica", textAnchor = 'start', text = self.name)) ty1 = ty-10*1.2 g.add(String(x = self.borderWidth+(self.borderWidth/5.0), y = ty1-8, fontSize = 8, fillColor = self.strokeColor, fontName = "Helvetica", textAnchor = 'start', text = self.position)) if self.border: g.add(Rect(x = 0, y = 0, fillColor=None, strokeColor = black, width = self.width, height = self.height)) g.shift(self.x,self.y) return g
def draw(self): fillColor = self.fillColor strokeColor = self.strokeColor g = Group() g.add( Rect(x=0, y=0, fillColor=self.fillColor, strokeColor=self.fillColor, width=self.borderWidth, height=self.height)) g.add( Rect(x=0, y=self.height - self.borderWidth, fillColor=self.fillColor, strokeColor=self.fillColor, width=self.width, height=self.borderWidth)) g2 = Group() rl = RL_CorpLogo() rl.height = 1.25 * cm rl.width = 1.9 * cm rl.draw() g2.add(rl) g.add(g2) g2.shift(x=(self.width - (rl.width + (self.width / 42))), y=(self.height - (rl.height + (self.height / 42)))) g.add( String(x=self.borderWidth / 5.0, y=((self.height - (rl.height + (self.height / 42))) + ((38 / 90.5) * rl.height)), fontSize=6, fillColor=self.altStrokeColor, fontName="Helvetica-BoldOblique", textAnchor='start', text=self._strapline)) leftText = ["Tel:", "Mobile:", "Fax:", "Email:", "Web:"] leftDetails = [ self.telephone, self.mobile, self.fax, self.email, self.web ] leftText.reverse() leftDetails.reverse() for f in range(len(leftText), 0, -1): g.add( String(x=self.borderWidth + (self.borderWidth / 5.0), y=(self.borderWidth / 5.0) + ((f - 1) * (5 * 1.2)), fontSize=5, fillColor=self.strokeColor, fontName="Helvetica", textAnchor='start', text=leftText[f - 1])) g.add( String(x=self.borderWidth + (self.borderWidth / 5.0) + self.borderWidth, y=(self.borderWidth / 5.0) + ((f - 1) * (5 * 1.2)), fontSize=5, fillColor=self.strokeColor, fontName="Helvetica", textAnchor='start', text=leftDetails[f - 1])) ty = (self.height - self.borderWidth - (self.borderWidth / 5.0) + 2) # g.add(Line(self.borderWidth, ty, self.borderWidth+(self.borderWidth/5.0), ty)) # g.add(Line(self.borderWidth+(self.borderWidth/5.0), ty, self.borderWidth+(self.borderWidth/5.0), # ty+(self.borderWidth/5.0))) # g.add(Line(self.borderWidth, ty-10, # self.borderWidth+(self.borderWidth/5.0), ty-10)) rightText = self.rh_blurb_top for f in range(1, (len(rightText) + 1)): g.add( String(x=self.width - (self.borderWidth / 5.0), y=ty - ((f) * (5 * 1.2)), fontSize=5, fillColor=self.strokeColor, fontName="Helvetica", textAnchor='end', text=rightText[f - 1])) g.add( String(x=self.borderWidth + (self.borderWidth / 5.0), y=ty - 10, fontSize=10, fillColor=self.strokeColor, fontName="Helvetica", textAnchor='start', text=self.name)) ty1 = ty - 10 * 1.2 g.add( String(x=self.borderWidth + (self.borderWidth / 5.0), y=ty1 - 8, fontSize=8, fillColor=self.strokeColor, fontName="Helvetica", textAnchor='start', text=self.position)) if self.border: g.add( Rect(x=0, y=0, fillColor=None, strokeColor=black, width=self.width, height=self.height)) g.shift(self.x, self.y) return g
btmfront = Group( Rect(0, 0, bottom_width, bottom_thickness, strokeWidth=0.02, fillColor=colors.white)) btmtop = Group( Rect(0, 0, bottom_width, bottom_depth, strokeWidth=0.02, fillColor=colors.white)) btmtop.translate(0, bottom_thickness) btmtop.shift(0, bottom_thickness) btmtop.skew(iso_angle, 0) btmright = Group( Rect(0, 0, bottom_depth, bottom_thickness, strokeWidth=0.02, fillColor=colors.white)) btmright.translate(bottom_width, 0) btmright.shift(bottom_width, 0) btmright.skew(0, 90 - iso_angle) d.add(btmfront) d.add(btmtop) d.add(btmright)
def draw(self): g = Group() ys = self.bottomPadding + ( self.triangleHeight / 2) + self.sourceLabelOffset + self.sourceLabelFontSize if self.background: x, y = self._getDrawingDimensions() g.add( Rect(-self.leftPadding, -ys, x, y, strokeColor=None, strokeWidth=0, fillColor=self.background)) ascent = getFont(self.labelFontName).face.ascent / 1000. if ascent == 0: ascent = 0.718 # default (from helvetica) ascent = ascent * self.labelFontSize # normalize colorsList = self._getColors() # Draw the boxes - now uses ShadedRect from grids x = 0 for f in range(0, self.numberOfBoxes): sr = ShadedRect() sr.x = x sr.y = 0 sr.width = self.boxWidth sr.height = self.boxHeight sr.orientation = 'vertical' sr.numShades = 30 sr.fillColorStart = colorsList[f] sr.fillColorEnd = colorsList[f + 1] sr.strokeColor = None sr.strokeWidth = 0 g.add(sr) g.add( Rect(x, 0, self.boxWidth, self.boxHeight, strokeColor=self.boxOutlineColor, strokeWidth=self.boxOutlineWidth, fillColor=None)) g.add( String(x + self.boxWidth / 2., (self.boxHeight - ascent) / 2., text=str(f + 1), fillColor=self.labelFillColor, strokeColor=self.labelStrokeColor, textAnchor='middle', fontName=self.labelFontName, fontSize=self.labelFontSize)) x = x + self.boxWidth + self.boxSpacing #do triangles xt = (self.trianglePosition * self.boxWidth) if self.trianglePosition > 1: xt = xt + (self.trianglePosition - 1) * self.boxSpacing xt = xt - (self.boxWidth / 2) g.add( Polygon(strokeColor=self.triangleStrokeColor, strokeWidth=self.triangleStrokeWidth, fillColor=self.triangleFillColor, points=[ xt, self.boxHeight - (self.triangleHeight / 2), xt - (self.triangleWidth / 2), self.boxHeight + (self.triangleHeight / 2), xt + (self.triangleWidth / 2), self.boxHeight + (self.triangleHeight / 2), xt, self.boxHeight - (self.triangleHeight / 2) ])) g.add( Polygon(strokeColor=self.triangleStrokeColor, strokeWidth=self.triangleStrokeWidth, fillColor=self.triangleFillColor, points=[ xt, 0 + (self.triangleHeight / 2), xt - (self.triangleWidth / 2), 0 - (self.triangleHeight / 2), xt + (self.triangleWidth / 2), 0 - (self.triangleHeight / 2), xt, 0 + (self.triangleHeight / 2) ])) #source label if self.sourceLabelText != None: g.add( String(x - self.boxSpacing, 0 - (self.triangleHeight / 2) - self.sourceLabelOffset - (self.sourceLabelFontSize), text=self.sourceLabelText, fillColor=self.sourceLabelFillColor, textAnchor='end', fontName=self.sourceLabelFontName, fontSize=self.sourceLabelFontSize)) g.shift(self.leftPadding, ys) return g
def __init__(self, width=1000, height=400, *args, **kwargs): Drawing.__init__(self, width, height, *args, **kwargs) # background color self.background = Rect(0, 0, self.width, self.height, strokeWidth=0, fillColor=colors.lightgrey) # end here self.add(Circle(500, 200, 180), name='circle_perfect') self.add(Circle(500, 200, 145), name='circle_good') self.add(Circle(500, 200, 115), name='circle_medium') self.add(Circle(500, 200, 85), name='circle_bad') self.add(Circle(500, 200, 50), name='circle_awful') self.add(Circle(500, 200, 20), name='circle_center') self.add(SpiderChart(), name='background_chart') self.add(SpiderChart(), name='chart') # QR code qrw = QrCodeWidget('Well met') # QR size qrw.barHeight = 150 qrw.barWidth = 150 # QR position qrw.y = 100 qrw.x = 10 self.add(qrw) # end here # barcode barcode_group = Group() barcode = createBarcodeDrawing('EAN13', value='1234567890', width=200, height=100) barcode_group.add(barcode) barcode_group.shift(10, 10) # barcode position self.add(barcode_group) # end here self.add(String(470, 386, 'Аналіз крові'), name='text0') self.add(String(605, 352, 'Антропометрія'), name='text1') self.add(String(670, 275, 'Постава'), name='text2') self.add(String(685, 170, 'Композиція тіла'), name='text3') self.add(String(645, 75, 'Електрокардіограмма'), name='text4') self.add(String(550, 10, 'Варіаційна пульсометрія'), name='text5') self.add(String(350, 10, 'Система дихання'), name='text6') self.add(String(220, 75, 'Кистьова динамометрія'), name='text7') self.add(String(225, 170, 'Основний обмін'), name='text8') self.add(String(160, 275, 'Карідореспіраторний профіль'), name='text9') self.add(String(330, 350, 'Психотест'), name='text10') # info self.add(String(840, 366, 'Чудово'), name='info_perfect') self.circle_perfect.fillColor = colors.Color(0, 0, 255, alpha=0.3) self.circle_perfect.strokeColor = colors.transparent self.info_perfect.fontName = 'HelveticaNeueC' self.info_perfect.fontSize = 12 self.add(Rect(800, 356, 30, 30), name='rect_perfect') self.rect_perfect.fillColor = colors.Color(0, 0, 255, alpha=0.3) self.rect_perfect.strokeColor = colors.transparent self.add(String(840, 326, 'Добре'), name='info_good') self.circle_good.fillColor = colors.Color(0, 255, 0, alpha=0.5) self.circle_good.strokeColor = colors.transparent self.info_good.fontName = 'HelveticaNeueC' self.info_good.fontSize = 12 self.add(Rect(800, 316, 30, 30), name='rect_good') self.rect_good.fillColor = colors.Color(0, 255, 0, alpha=0.5) self.rect_good.strokeColor = colors.transparent self.add(String(840, 286, 'Задовільно'), name='info_medium') self.circle_medium.fillColor = colors.yellow self.circle_medium.strokeColor = colors.transparent self.info_medium.fontName = 'HelveticaNeueC' self.info_medium.fontSize = 12 self.add(Rect(800, 276, 30, 30), name='rect_medium') self.rect_medium.fillColor = colors.yellow self.rect_medium.strokeColor = colors.transparent self.add(String(840, 246, 'Погано'), name='info_bad') self.circle_bad.fillColor = colors.orange self.circle_bad.strokeColor = colors.transparent self.info_bad.fontName = 'HelveticaNeueC' self.info_bad.fontSize = 12 self.add(Rect(800, 236, 30, 30), name='rect_bad') self.rect_bad.fillColor = colors.orange self.rect_bad.strokeColor = colors.transparent self.add(String(840, 206, 'Дуже погано'), name='info_awful') self.circle_awful.fillColor = colors.red self.circle_awful.strokeColor = colors.transparent self.info_awful.fontName = 'HelveticaNeueC' self.info_awful.fontSize = 12 self.add(Rect(800, 196, 30, 30), name='rect_awful') self.rect_awful.fillColor = colors.red self.rect_awful.strokeColor = colors.transparent # end here self.chart.x = 20 self.chart.y = 40 self.chart.width = self.width - 40 self.chart.height = self.height - 80 self.background_chart.x = 10 self.background_chart.y = 20 self.background_chart.width = self.width - 20 self.background_chart.height = self.height - 40 # ruin has com to my code TODO rework this garbage self.text0.fontName = 'HelveticaNeueC' self.text0.fontSize = 12 self.text1.fontName = 'HelveticaNeueC' self.text1.fontSize = 12 self.text2.fontName = 'HelveticaNeueC' self.text2.fontSize = 12 self.text3.fontName = 'HelveticaNeueC' self.text3.fontSize = 12 self.text4.fontName = 'HelveticaNeueC' self.text4.fontSize = 12 self.text5.fontName = 'HelveticaNeueC' self.text5.fontSize = 12 self.text6.fontName = 'HelveticaNeueC' self.text6.fontSize = 12 self.text7.fontName = 'HelveticaNeueC' self.text7.fontSize = 12 self.text8.fontName = 'HelveticaNeueC' self.text8.fontSize = 12 self.text9.fontName = 'HelveticaNeueC' self.text9.fontSize = 12 self.text10.fontName = 'HelveticaNeueC' self.text10.fontSize = 12 # end here aaaaaaaaaaaaaaaaaa self.chart.labels = [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ] self.background_chart.labels = [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ] self.chart.data = [ [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], # style [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], # style [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], # style [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], # style [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], # style [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], # values ] self.background_chart.data = [ [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], # style [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], # style [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], # style [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], # style [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], # style ] # style self.chart.strands.strokeColor = colors.transparent self.background_chart.strands.strokeColor = colors.transparent self.background_chart.spokes.strokeColor = colors.lightgrey # self.chart.strands[1].strokeWidth = 15 # self.chart.strands[1].strokeColor = colors.lightgreen # self.chart.strands[2].strokeWidth = 15 # self.chart.strands[2].strokeColor = colors.yellow # self.chart.strands[3].strokeWidth = 15 # self.chart.strands[3].strokeColor = colors.orange # self.chart.strands[4].strokeWidth = 15 # self.chart.strands[4].strokeColor = colors.red # self.background_chart.strands[0].fillColor = colors.Color(0, 0, 255, alpha=0.3) # self.background_chart.strands[1].fillColor = colors.Color(0, 255, 0, alpha=0.5) # self.background_chart.strands[2].fillColor = colors.yellow # self.background_chart.strands[3].fillColor = colors.orange # self.background_chart.strands[4].fillColor = colors.red # self.chart.strands[0].strokeColor = colors.blue # self.chart.strands[0].strokeDashArray = (4, 4) # self.chart.strands[0].symbol = makeMarker("Circle") # self.chart.strands[0].strokeWidth = 0.5 # self.chart.strands[0].symbol.fillColor = colors.black #end here self.chart.strandLabels.format = 'values' # main graph style self.chart.strands[5].strokeColor = colors.darkblue self.chart.spokes.strokeColor = colors.transparent self.chart.strands[5].symbol = makeMarker('FilledCircle', size=11) # self.chart.strandLabels.dR = -20 self.chart.strands[5].symbol.fillColor = colors.white self.chart.strands[5].strokeWidth = 2
def draw(self): g = Group() ys = self.bottomPadding+(self.triangleHeight/2)+self.sourceLabelOffset+self.sourceLabelFontSize if self.background: x,y = self._getDrawingDimensions() g.add(Rect(-self.leftPadding,-ys,x,y, strokeColor=None, strokeWidth=0, fillColor=self.background)) ascent=getFont(self.labelFontName).face.ascent/1000. if ascent==0: ascent=0.718 # default (from helvetica) ascent=ascent*self.labelFontSize # normalize colorsList = self._getColors() # Draw the boxes - now uses ShadedRect from grids x=0 for f in range (0,self.numberOfBoxes): sr=ShadedRect() sr.x=x sr.y=0 sr.width=self.boxWidth sr.height=self.boxHeight sr.orientation = 'vertical' sr.numShades = 30 sr.fillColorStart = colorsList[f] sr.fillColorEnd = colorsList[f+1] sr.strokeColor = None sr.strokeWidth = 0 g.add(sr) g.add(Rect(x,0,self.boxWidth,self.boxHeight, strokeColor=self.boxOutlineColor, strokeWidth=self.boxOutlineWidth, fillColor=None)) g.add(String(x+self.boxWidth/2.,(self.boxHeight-ascent)/2., text = str(f+1), fillColor = self.labelFillColor, strokeColor=self.labelStrokeColor, textAnchor = 'middle', fontName = self.labelFontName, fontSize = self.labelFontSize)) x=x+self.boxWidth+self.boxSpacing #do triangles xt = (self.trianglePosition*self.boxWidth) if self.trianglePosition>1: xt = xt+(self.trianglePosition-1)*self.boxSpacing xt = xt-(self.boxWidth/2) g.add(Polygon( strokeColor = self.triangleStrokeColor, strokeWidth = self.triangleStrokeWidth, fillColor = self.triangleFillColor, points=[xt,self.boxHeight-(self.triangleHeight/2), xt-(self.triangleWidth/2),self.boxHeight+(self.triangleHeight/2), xt+(self.triangleWidth/2),self.boxHeight+(self.triangleHeight/2), xt,self.boxHeight-(self.triangleHeight/2)])) g.add(Polygon( strokeColor = self.triangleStrokeColor, strokeWidth = self.triangleStrokeWidth, fillColor = self.triangleFillColor, points=[xt,0+(self.triangleHeight/2), xt-(self.triangleWidth/2),0-(self.triangleHeight/2), xt+(self.triangleWidth/2),0-(self.triangleHeight/2), xt,0+(self.triangleHeight/2)])) #source label if self.sourceLabelText != None: g.add(String(x-self.boxSpacing,0-(self.triangleHeight/2)-self.sourceLabelOffset-(self.sourceLabelFontSize), text = self.sourceLabelText, fillColor = self.sourceLabelFillColor, textAnchor = 'end', fontName = self.sourceLabelFontName, fontSize = self.sourceLabelFontSize)) g.shift(self.leftPadding, ys) return g