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(Polygon(points=[108.3032,252.9412,200,288.2353,291.6968,252.9412,306.9796,138.2353,200,58.82353,93.02039,138.2353,108.3032,252.9412],fillColor=Color(1,.972549,.862745,1),fillOpacity=None,strokeColor=None,strokeWidth=0,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(Polygon(points=[85.37899,266.1765,200,252.9412,261.1312,235.2941,276.414,155.8824,200,94.11765,131.2274,160.2941,85.37899,266.1765],fillColor=Color(0,1,1,1),fillOpacity=None,strokeColor=None,strokeWidth=0,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(Polygon(points=[138.8688,235.2941,200,261.7647,261.1312,235.2941,329.9038,125,200,164.7059,108.3032,147.0588,138.8688,235.2941],fillColor=Color(.596078,.984314,.596078,1),fillOpacity=None,strokeColor=None,strokeWidth=0,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(PolyLine(points=[108.3032,252.9412,200,288.2353,291.6968,252.9412,306.9796,138.2353,200,58.82353,93.02039,138.2353,108.3032,252.9412],strokeColor=Color(1,.972549,.862745,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(PolyLine(points=[85.37899,266.1765,200,252.9412,261.1312,235.2941,276.414,155.8824,200,94.11765,131.2274,160.2941,85.37899,266.1765],strokeColor=Color(0,1,1,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(PolyLine(points=[138.8688,235.2941,200,261.7647,261.1312,235.2941,329.9038,125,200,164.7059,108.3032,147.0588,138.8688,235.2941],strokeColor=Color(.596078,.984314,.596078,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(200,200,200,350,strokeColor=Color(0,0,0,1),strokeWidth=.5,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=(2,2),strokeOpacity=None))
		self.add(Line(200,200,329.9038,275,strokeColor=Color(0,0,0,1),strokeWidth=.5,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=(2,2),strokeOpacity=None))
		self.add(Line(200,200,329.9038,125,strokeColor=Color(0,0,0,1),strokeWidth=.5,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=(2,2),strokeOpacity=None))
		self.add(Line(200,200,200,50,strokeColor=Color(0,0,0,1),strokeWidth=.5,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=(2,2),strokeOpacity=None))
		self.add(Line(200,200,70.09619,125,strokeColor=Color(0,0,0,1),strokeWidth=.5,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=(2,2),strokeOpacity=None))
		self.add(Line(200,200,70.09619,275,strokeColor=Color(0,0,0,1),strokeWidth=.5,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=(2,2),strokeOpacity=None))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,200,357.5)
		v0.add(String(-2.22,-4,'a',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,336.399,278.75)
		v0.add(String(-2.5,-4,'b',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,336.399,121.25)
		v0.add(String(-2.22,-4,'c',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,200,42.5)
		v0.add(String(-2.5,-4,'d',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,63.601,121.25)
		v0.add(String(-2.22,-4,'e',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,63.601,278.75)
		v0.add(String(-1.665,-4,'f',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
Example #2
0
	def __init__(self,width=400,height=300,*args,**kw):
		Drawing.__init__(self,width,height,*args,**kw)
		self.transform = (1,0,0,1,0,0)
		self.add(Line(40,30,390,30,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(107.1717,30,107.1717,25,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(177.8788,30,177.8788,25,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(248.5859,30,248.5859,25,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(319.2929,30,319.2929,25,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(390,30,390,25,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,107.1717,25)
		v0.add(String(-7.5,-10,'200',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,177.8788,25)
		v0.add(String(-7.5,-10,'400',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,248.5859,25)
		v0.add(String(-7.5,-10,'600',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,319.2929,25)
		v0.add(String(-7.5,-10,'800',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,390,25)
		v0.add(String(-10,-10,'1000',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		self.add(Line(40,30,40,280,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(40,43.51351,35,43.51351,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(40,111.0811,35,111.0811,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(40,178.6486,35,178.6486,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(40,246.2162,35,246.2162,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,35,43.51351)
		v0.add(String(-25.08,-4,'1e+02',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,35,111.0811)
		v0.add(String(-25.08,-4,'1e+04',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,35,178.6486)
		v0.add(String(-25.08,-4,'1e+06',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,35,246.2162)
		v0.add(String(-25.08,-4,'1e+08',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		self.add(Line(107.1717,30,107.1717,280,strokeColor=Color(0,0,0,1),strokeWidth=.25,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=[1,1],strokeOpacity=None))
		self.add(Line(177.8788,30,177.8788,280,strokeColor=Color(0,0,0,1),strokeWidth=.25,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=[1,1],strokeOpacity=None))
		self.add(Line(248.5859,30,248.5859,280,strokeColor=Color(0,0,0,1),strokeWidth=.25,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=[1,1],strokeOpacity=None))
		self.add(Line(319.2929,30,319.2929,280,strokeColor=Color(0,0,0,1),strokeWidth=.25,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=[1,1],strokeOpacity=None))
		self.add(Line(390,30,390,280,strokeColor=Color(0,0,0,1),strokeWidth=.25,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=[1,1],strokeOpacity=None))
		self.add(Line(40,43.51351,390,43.51351,strokeColor=Color(0,0,0,1),strokeWidth=.25,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=[1,1],strokeOpacity=None))
		self.add(Line(40,111.0811,390,111.0811,strokeColor=Color(0,0,0,1),strokeWidth=.25,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=[1,1],strokeOpacity=None))
		self.add(Line(40,178.6486,390,178.6486,strokeColor=Color(0,0,0,1),strokeWidth=.25,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=[1,1],strokeOpacity=None))
		self.add(Line(40,246.2162,390,246.2162,strokeColor=Color(0,0,0,1),strokeWidth=.25,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=[1,1],strokeOpacity=None))
		self.add(PolyLine(points=[40,43.51351,43.53535,63.85338,47.07071,75.75144,50.60606,84.19324,54.14141,90.74122,57.67677,96.0913,61.21212,100.6147,64.74747,104.5331,68.28283,107.9894,71.81818,111.0811,75.35354,113.8779,78.88889,116.4312,82.42424,118.78,85.9596,120.9546,89.49495,122.9791,93.0303,124.873,96.56566,126.652,100.101,128.3292,103.6364,129.9158,107.1717,131.4209,110.7071,132.8527,114.2424,134.2177,117.7778,135.5222,121.3131,136.771,124.8485,137.9689,128.3838,139.1198,131.9192,140.2273,135.4545,141.2945,138.9899,142.3242,142.5253,143.319,146.0606,144.2812,149.596,145.2128,153.1313,146.1158,156.6667,146.9918,160.202,147.8424,163.7374,148.6691,167.2727,149.4731,170.8081,150.2556,174.3434,151.0179,177.8788,151.7608,181.4141,152.4854,184.9495,153.1925,188.4848,153.883,192.0202,154.5576,195.5556,155.2171,199.0909,155.862,202.6263,156.4931,206.1616,157.1109,209.697,157.716,213.2323,158.3088,216.7677,158.8899,220.303,159.4597,223.8384,160.0186,227.3737,160.5671,230.9091,161.1056,234.4444,161.6343,237.9798,162.1537,241.5152,162.6641,245.0505,163.1657,248.5859,163.6589,252.1212,164.1439,255.6566,164.6211,259.1919,165.0906,262.7273,165.5527,266.2626,166.0077,269.798,166.4557,273.3333,166.8969,276.8687,167.3317,280.404,167.7601,283.9394,168.1823,287.4747,168.5985,291.0101,169.009,294.5455,169.4137,298.0808,169.813,301.6162,170.2068,305.1515,170.5955,308.6869,170.9791,312.2222,171.3577,315.7576,171.7316,319.2929,172.1007,322.8283,172.4652,326.3636,172.8253,329.899,173.181,333.4343,173.5324,336.9697,173.8797,340.5051,174.2229,344.0404,174.5621,347.5758,174.8975,351.1111,175.2291,354.6465,175.5569,358.1818,175.8812,361.7172,176.2019,365.2525,176.5191,368.7879,176.833,372.3232,177.1435,375.8586,177.4508,379.3939,177.7548,382.9293,178.0558,386.4646,178.3537,390,178.6486],strokeColor=Color(1,0,0,1),strokeWidth=.2,strokeLineCap=0,strokeLineJoin=1,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(PolyLine(points=[40,77.2973,43.53535,107.8071,47.07071,125.6542,50.60606,138.3169,54.14141,148.1389,57.67677,156.164,61.21212,162.9491,64.74747,168.8267,68.28283,174.0111,71.81818,178.6486,75.35354,182.8439,78.88889,186.6738,82.42424,190.197,85.9596,193.4589,89.49495,196.4957,93.0303,199.3365,96.56566,202.005,100.101,204.5209,103.6364,206.9007,107.1717,209.1584,110.7071,211.306,114.2424,213.3537,117.7778,215.3103,121.3131,217.1836,124.8485,218.9804,128.3838,220.7068,131.9192,222.3679,135.4545,223.9687,138.9899,225.5133,142.5253,227.0055,146.0606,228.4488,149.596,229.8463,153.1313,231.2007,156.6667,232.5148,160.202,233.7907,163.7374,235.0307,167.2727,236.2367,170.8081,237.4105,174.3434,238.5538,177.8788,239.6682,181.4141,240.7551,184.9495,241.8158,188.4848,242.8515,192.0202,243.8634,195.5556,244.8526,199.0909,245.8201,202.6263,246.7667,206.1616,247.6934,209.697,248.601,213.2323,249.4902,216.7677,250.3618,220.303,251.2166,223.8384,252.055,227.3737,252.8777,230.9091,253.6854,234.4444,254.4785,237.9798,255.2576,241.5152,256.0231,245.0505,256.7755,248.5859,257.5153,252.1212,258.2429,255.6566,258.9586,259.1919,259.6629,262.7273,260.3561,266.2626,261.0385,269.798,261.7105,273.3333,262.3724,276.8687,263.0246,280.404,263.6671,283.9394,264.3005,287.4747,264.9248,291.0101,265.5405,294.5455,266.1476,298.0808,266.7465,301.6162,267.3373,305.1515,267.9203,308.6869,268.4957,312.2222,269.0636,315.7576,269.6244,319.2929,270.178,322.8283,270.7248,326.3636,271.2649,329.899,271.7985,333.4343,272.3256,336.9697,272.8465,340.5051,273.3613,344.0404,273.8702,347.5758,274.3732,351.1111,274.8706,354.6465,275.3624,358.1818,275.8488,361.7172,276.3298,365.2525,276.8057,368.7879,277.2765,372.3232,277.7423,375.8586,278.2032,379.3939,278.6593,382.9293,279.1108,386.4646,279.5576,390,280],strokeColor=Color(0,0,1,1),strokeWidth=.2,strokeLineCap=0,strokeLineJoin=1,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(PolyLine(points=[40,30,43.53535,46.27189,47.07071,55.79034,50.60606,62.54378,54.14141,67.78216,57.67677,72.06223,61.21212,75.68098,64.74747,78.81567,68.28283,81.58068,71.81818,84.05405,75.35354,86.2915,78.88889,88.33412,82.42424,90.21315,85.9596,91.95287,89.49495,93.5725,93.0303,95.08757,96.56566,96.51075,100.101,97.85257,103.6364,99.12182,107.1717,100.3259,110.7071,101.4713,114.2424,102.5634,117.7778,103.6069,121.3131,104.606,124.8485,105.5643,128.3838,106.485,131.9192,107.371,135.4545,108.2248,138.9899,109.0485,142.5253,109.8444,146.0606,110.6141,149.596,111.3595,153.1313,112.0818,156.6667,112.7826,160.202,113.4631,163.7374,114.1245,167.2727,114.7677,170.8081,115.3937,174.3434,116.0035,177.8788,116.5978,181.4141,117.1775,184.9495,117.7432,188.4848,118.2956,192.0202,118.8353,195.5556,119.3628,199.0909,119.8788,202.6263,120.3837,206.1616,120.8779,209.697,121.362,213.2323,121.8362,216.7677,122.3011,220.303,122.7569,223.8384,123.2041,227.3737,123.6429,230.9091,124.0737,234.4444,124.4967,237.9798,124.9122,241.5152,125.3204,245.0505,125.7217,248.5859,126.1163,252.1212,126.5043,255.6566,126.886,259.1919,127.2617,262.7273,127.6313,266.2626,127.9953,269.798,128.3537,273.3333,128.7067,276.8687,129.0545,280.404,129.3972,283.9394,129.735,287.4747,130.068,291.0101,130.3964,294.5455,130.7202,298.0808,131.0396,301.6162,131.3547,305.1515,131.6656,308.6869,131.9725,312.2222,132.2754,315.7576,132.5744,319.2929,132.8697,322.8283,133.1614,326.3636,133.4494,329.899,133.734,333.4343,134.0151,336.9697,134.2929,340.5051,134.5675,344.0404,134.8389,347.5758,135.1072,351.1111,135.3724,354.6465,135.6347,358.1818,135.8941,361.7172,136.1507,365.2525,136.4045,368.7879,136.6556,372.3232,136.904,375.8586,137.1498,379.3939,137.3931,382.9293,137.6338,386.4646,137.8722,390,138.1081],strokeColor=Color(0,.501961,0,1),strokeWidth=.2,strokeLineCap=0,strokeLineJoin=1,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
def drawSunspots():
    d = Drawing(200, 150)
    pred = [row[2] - 40 for row in data]
    high = [row[3] - 40 for row in data]
    low = [row[4] - 40 for row in data]
    times = [200 * ((row[0] + row[1] / 12.0) - 2007) - 110 for row in data]
    d.add(PolyLine(zip(times, pred), strokeColor=colors.blue))
    d.add(PolyLine(zip(times, high), strokeColor=colors.red))
    d.add(PolyLine(zip(times, low), strokeColor=colors.green))
    d.add(String(65, 115, 'Sunspots', fontSize=18, fillColor=colors.red))

    renderPDF.drawToFile(d, 'report.pdf', 'Sunspots')
Example #4
0
	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(Line(20,10,200,10,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(25.54729,10,25.54729,5,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(60.17003,10,60.17003,5,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(95.36663,10,95.36663,5,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(129.9894,10,129.9894,5,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(165.186,10,165.186,5,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(200,10,200,5,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,25.54729,5)
		v0.add(String(-11.39,-10,'12/97',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,60.17003,5)
		v0.add(String(-11.39,-10,'06/98',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,95.36663,5)
		v0.add(String(-11.39,-10,'12/98',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,129.9894,5)
		v0.add(String(-11.39,-10,'06/99',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,165.186,5)
		v0.add(String(-11.39,-10,'12/99',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,200,5)
		v0.add(String(-11.39,-10,'06/00',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		self.add(Line(20,10,20,95,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(20,10,15,10,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(20,36.89873,15,36.89873,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(20,63.79747,15,63.79747,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		self.add(Line(20,90.6962,15,90.6962,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=10,strokeDashArray=None,strokeOpacity=None))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,15,10)
		v0.add(String(-15,-4,'100',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,15,36.89873)
		v0.add(String(-15,-4,'105',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,15,63.79747)
		v0.add(String(-15,-4,'110',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		v0=self._nn(Group())
		v0.transform = (1,0,0,1,15,90.6962)
		v0.add(String(-15,-4,'115',textAnchor='start',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
		self.add(Polygon(points=[20,10,25.54729,10.91691,31.47715,18.4137,36.83316,21.77085,42.76302,18.78903,48.50159,24.86986,54.43146,25.70781,60.17003,27.53468,66.09989,27.49301,72.02976,39.45106,77.76833,60.16221,83.69819,74.48126,89.43677,68.73857,95.36663,68.73857,101.2965,74.49377,106.6525,62.67451,112.5824,65.09881,118.3209,66.09963,124.2508,60.24444,129.9894,54.29778,135.9192,64.94306,141.8491,69.00671,147.5877,76.9377,153.5175,78.49173,159.2561,76.44506,165.186,76.5263,171.1158,68.77656,176.6631,66.63061,182.593,81.61309,188.3316,69.41884,194.2614,72.95765,200,83.07427,200,88.5443,194.2614,77.78481,188.3316,75.63291,182.593,95,176.6631,84.77848,171.1158,78.32278,165.186,92.8481,159.2561,84.77848,153.5175,81.01266,147.5877,77.78481,141.8491,72.94304,135.9192,70.25316,129.9894,60.03165,124.2508,64.33544,118.3209,76.17089,112.5824,73.48101,106.6525,64.87342,101.2965,80.47468,95.36663,74.01899,89.43677,53.57595,83.69819,54.6519,77.76833,40.12658,72.02976,25.06329,66.09989,26.67722,60.17003,26.67722,54.43146,26.13924,48.50159,26.13924,42.76302,20.22152,36.83316,20.75949,31.47715,14.3038,25.54729,10,20,10],fillColor=Color(.623529,.623529,.623529,1),fillOpacity=None,strokeColor=None,strokeWidth=0,strokeLineCap=0,strokeLineJoin=0,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(PolyLine(points=[20,10,25.54729,10.91691,31.47715,18.4137,36.83316,21.77085,42.76302,18.78903,48.50159,24.86986,54.43146,25.70781,60.17003,27.53468,66.09989,27.49301,72.02976,39.45106,77.76833,60.16221,83.69819,74.48126,89.43677,68.73857,95.36663,68.73857,101.2965,74.49377,106.6525,62.67451,112.5824,65.09881,118.3209,66.09963,124.2508,60.24444,129.9894,54.29778,135.9192,64.94306,141.8491,69.00671,147.5877,76.9377,153.5175,78.49173,159.2561,76.44506,165.186,76.5263,171.1158,68.77656,176.6631,66.63061,182.593,81.61309,188.3316,69.41884,194.2614,72.95765,200,83.07427],strokeColor=None,strokeWidth=1,strokeLineCap=0,strokeLineJoin=1,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(PolyLine(points=[20,10,25.54729,10,31.47715,14.3038,36.83316,20.75949,42.76302,20.22152,48.50159,26.13924,54.43146,26.13924,60.17003,26.67722,66.09989,26.67722,72.02976,25.06329,77.76833,40.12658,83.69819,54.6519,89.43677,53.57595,95.36663,74.01899,101.2965,80.47468,106.6525,64.87342,112.5824,73.48101,118.3209,76.17089,124.2508,64.33544,129.9894,60.03165,135.9192,70.25316,141.8491,72.94304,147.5877,77.78481,153.5175,81.01266,159.2561,84.77848,165.186,92.8481,171.1158,78.32278,176.6631,84.77848,182.593,95,188.3316,75.63291,194.2614,77.78481,200,88.5443],strokeColor=None,strokeWidth=1,strokeLineCap=0,strokeLineJoin=1,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
Example #5
0
    def convertPolyline(self, node):
        getAttr = node.getAttribute
        points = getAttr("points")
        points = points.replace(',', ' ')
        points = points.split()
        points = list(map(self.attrConverter.convertLength, points))
        if len(points) % 2 != 0 or len(points) == 0:
            # Odd number of coordinates or no coordinates, invalid polyline
            return None

        polyline = PolyLine(points)
        self.applyStyleOnShape(polyline, node)
        has_fill = self.attrConverter.findAttr(node, 'fill') not in ('', 'none')

        if has_fill:
            # ReportLab doesn't fill polylines, so we are creating a polygon
            # polygon copy of the polyline, but without stroke.
            group = Group()
            polygon = Polygon(points)
            self.applyStyleOnShape(polygon, node)
            polygon.strokeColor = None
            group.add(polygon)
            group.add(polyline)
            return group

        return polyline
Example #6
0
    def _addPage(self, g, strokeWidth=3, color=None, dx=0, dy=0):
        x1, x2 = 31.85+dx, 80.97+dx
        fL = 10 # fold length
        y1, y2 = dy-34, dy+50.5
        L = [[x1,dy-4,x1,y1, x2, y1, x2, dy-1],
            [x1,dy+11,x1,y2,x2-fL,y2,x2,y2-fL,x2,dy+14],
            [x2-10,y2,x2-10,y2-fL,x2,y2-fL]]

        for l in L:
            g.add(PolyLine(l, strokeWidth=strokeWidth, strokeColor=color, strokeLineJoin=0))
Example #7
0
def line_demo():
    drawing = Drawing(width=400, height=200)
    line = Line(25, 25, 150, 150)
    line.strokeColor = colors.red
    line.strokeWidth = 5
    drawing.add(line)

    points = [25, 50, 35, 100, 100, 50, 150, 150]
    poly = PolyLine(points=points, strokeWidth=3, strokeColor=colors.blue)
    drawing.add(poly)

    drawing.save(formats=['pdf'], outDir='.', fnRoot='line_demo')
Example #8
0
def draw_tour(gene, file_name, text=""):
    d = Drawing(draw_size, draw_size)
    tour_xy = []
    for i in range(CITY_NUM):
        tour_i = gene[i]
        if i == 0:
            color = "red"
        else:
            color = "black"
        c = Circle(city_pos[tour_i][0],
                   city_pos[tour_i][1],
                   5,
                   fillColor=color)
        d.add(c)
        tour_xy.append(city_pos[tour_i])
    tour_xy.append(city_pos[gene[0]])
    l = PolyLine(tour_xy[1:], strokeColor="blue")
    d.add(l)
    l = PolyLine(tour_xy[:2], strokeColor="red")
    d.add(l)
    if text != "":
        s = String(center, 10, text, textAnchor="middle")
        d.add(s)
    renderPDF.drawToFile(d, "{}.pdf".format(file_name))
def sample_paths(sample_data, x_axis, y_axis):
    paths = []
    for idx, sample in enumerate(sample_data):
        points = []
        for x_idx, value in enumerate(sample_data[sample]):
            points.append(scale(value[0], x_axis))
            points.append(scale(value[1], y_axis))

        color = color_arr[idx % len(color_arr)]
        paths.append(
            PolyLine(points,
                     strokeColor=color,
                     fillColor=color,
                     strokeOpacity=1.0,
                     strokeWidth=0.5))

    return paths
Example #10
0
    def convert_polyline(self, node):
        points = attributes.convert_length_list(node_attr(node, "points"))
        has_fill = node_attr(node, 'fill') not in ('', 'none')

        if len(points) % 2 != 0 or len(points) == 0:
            _logger.warn("Invalid Polyline points: %s" % points)
            return None

        polyline = PolyLine(points)
        self.apply_style(polyline, node)

        if has_fill:
            # Need to use two shapes, because standard RLG polylines do not support filling...
            # Polygon is the same as the polyline but without a border (stroke)
            gr = Group()
            polygon = Polygon(points)
            self.apply_style(polygon, node)
            polygon.strokeColor = None
            gr.add(polygon)
            gr.add(polyline)
            return gr
        else:
            return polyline
Example #11
0
    def makeLines(self):
        g = Group()
        bubblePlot = getattr(self, '_bubblePlot', None)
        if bubblePlot:
            yA = self.yValueAxis
            xA = self.xValueAxis
            bubbleR = min(yA._bubbleRadius, xA._bubbleRadius)
            bubbleMax = xA._bubbleMax

        labelFmt = self.lineLabelFormat

        P = range(len(self._positions))
        if self.reversePlotOrder: P.reverse()
        inFill = getattr(self, '_inFill', None)
        styleCount = len(self.lines)
        if inFill or [
                rowNo for rowNo in P
                if getattr(self.lines[rowNo % styleCount], 'inFill', False)
        ]:
            inFillY = self.xValueAxis._y
            inFillX0 = self.yValueAxis._x
            inFillX1 = inFillX0 + self.xValueAxis._length
            inFillG = getattr(self, '_inFillG', g)
        lG = getattr(self, '_lineG', g)
        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            rowStyle = self.lines[rowNo % styleCount]
            rowColor = getattr(rowStyle, 'strokeColor', None)
            dash = getattr(rowStyle, 'strokeDashArray', None)

            if hasattr(rowStyle, 'strokeWidth'):
                width = rowStyle.strokeWidth
            elif hasattr(self.lines, 'strokeWidth'):
                width = self.lines.strokeWidth
            else:
                width = None

            # Iterate over data columns.
            if self.joinedLines:
                points = []
                for xy in row:
                    points += [xy[0], xy[1]]
                if inFill or getattr(rowStyle, 'inFill', False):
                    fpoints = [inFillX0, inFillY
                               ] + points + [inFillX1, inFillY]
                    filler = getattr(rowStyle, 'filler', None)
                    if filler:
                        filler.fill(self, inFillG, rowNo, rowColor, fpoints)
                    else:
                        inFillG.add(
                            Polygon(fpoints,
                                    fillColor=rowColor,
                                    strokeColor=rowColor,
                                    strokeWidth=width or 0.1))
                if inFill in (None, 0, 2):
                    line = PolyLine(points,
                                    strokeColor=rowColor,
                                    strokeLineCap=0,
                                    strokeLineJoin=1)
                    if width:
                        line.strokeWidth = width
                    if dash:
                        line.strokeDashArray = dash
                    lG.add(line)

            if hasattr(rowStyle, 'symbol'):
                uSymbol = rowStyle.symbol
            elif hasattr(self.lines, 'symbol'):
                uSymbol = self.lines.symbol
            else:
                uSymbol = None

            if uSymbol:
                j = -1
                if bubblePlot: drow = self.data[rowNo]
                for xy in row:
                    j += 1
                    symbol = uSymbol2Symbol(uSymbol, xy[0], xy[1], rowColor)
                    if symbol:
                        if bubblePlot:
                            symbol.size = bubbleR * (drow[j][2] /
                                                     bubbleMax)**0.5
                        g.add(symbol)

            # Draw data labels.
            for colNo in range(len(row)):
                x1, y1 = row[colNo]
                self.drawLabel(g, rowNo, colNo, x1, y1)

            shader = getattr(rowStyle, 'shader', None)
            if shader: shader.shade(self, g, rowNo, rowColor, row)

        return g
Example #12
0
    def render(self, node, parent=None):
        if parent is None:
            parent = self.mainGroup

        # ignore if display = none
        display = node.get('display')
        if display == "none":
            return

        if node.tag == self.SVG_ROOT:
            self.level += 1

            if not self.drawing is None:
                raise SVGError('drawing already created!')

            self.root = node

            # default styles
            style = {
                'color': 'none',
                'fill': 'none',
                'stroke': 'none',
                'font-family': 'Helvetica',
                'font-size': '12'
            }

            self.styles[self.level] = style

            # iterate children
            for child in node:
                self.render(child, self.mainGroup)

            # create drawing
            width = node.get('width', '100%')
            height = node.get('height', '100%')

            if node.get("viewBox"):
                try:
                    minx, miny, width, height = node.get("viewBox").split()
                except ValueError:
                    raise SVGError("viewBox values not valid")

            if width.endswith('%') and height.endswith('%'):
                # handle relative size
                wscale = parseLength(width) / 100.
                hscale = parseLength(height) / 100.

                xL, yL, xH, yH = self.mainGroup.getBounds()
                self.drawing = Drawing(xH * wscale + xL, yH * hscale + yL)

            else:
                self.drawing = Drawing(parseLength(width), parseLength(height))

            height = self.drawing.height
            self.mainGroup.scale(1, -1)
            self.mainGroup.translate(0, -height)
            self.drawing.add(self.mainGroup)

            self.level -= 1

            return self.drawing

        elif node.tag in (self.SVG_G, self.SVG_A):
            self.level += 1

            # set this levels style
            style = self.styles[self.level - 1].copy()
            style = self.nodeStyle(node, style)
            self.styles[self.level] = style

            group = Group()

            # iterate children
            for child in node:
                self.render(child, group)

            parent.add(group)

            transforms = node.get('transform')
            if transforms:
                for op in parseTransform.iterparse(transforms):
                    self.applyTransformOnGroup(group, op)

            self.level -= 1

        elif node.tag == self.SVG_USE:
            self.level += 1

            # set this levels style
            style = self.styles[self.level - 1].copy()
            style = self.nodeStyle(node, style)
            self.styles[self.level] = style

            group = Group()

            # link id
            link_id = node.get(self.LINK).lstrip('#')

            # find linked node in defs or symbol section
            target = None
            for defs in self.root.getiterator(self.SVG_DEFS):
                for element in defs:
                    if element.get('id') == link_id:
                        target = element
                        break

            if target is None:
                for defs in self.root.getiterator(self.SVG_SYMBOL):
                    for element in defs:
                        if element.get('id') == link_id:
                            target = element
                            break

                if target is None:
                    msg = "Could not find use node '%s'" % link_id
                    raise SVGError(msg)

            self.render(target, group)

            parent.add(group)

            # apply transform
            transforms = node.get('transform')
            if transforms:
                for op in parseTransform.iterparse(transforms):
                    self.applyTransformOnGroup(group, op)

            # apply 'x' and 'y' attribute as translation of defs object
            if node.get('x') or node.get('y'):
                dx = parseLength(node.get('x', '0'))
                dy = parseLength(node.get('y', '0'))

                self.applyTransformOnGroup(group, ('translate', (dx, dy)))

            self.level -= 1

        elif node.tag == self.SVG_LINE:
            # get coordinates
            x1 = parseLength(node.get('x1', '0'))
            y1 = parseLength(node.get('y1', '0'))
            x2 = parseLength(node.get('x2', '0'))
            y2 = parseLength(node.get('y2', '0'))

            shape = Line(x1, y1, x2, y2)
            self.addShape(parent, node, shape)

        elif node.tag == self.SVG_RECT:
            # get coordinates
            x = parseLength(node.get('x', '0'))
            y = parseLength(node.get('y', '0'))
            width = parseLength(node.get('width'))
            height = parseLength(node.get('height'))

            rx = parseLength(node.get('rx', '0'))
            ry = parseLength(node.get('ry', '0'))

            shape = Rect(x, y, width, height, rx=rx, ry=ry)
            self.addShape(parent, node, shape)

        elif node.tag == self.SVG_CIRCLE:
            cx = parseLength(node.get('cx', '0'))
            cy = parseLength(node.get('cy', '0'))
            r = parseLength(node.get('r'))

            if r > 0.:
                shape = Circle(cx, cy, r)
                self.addShape(parent, node, shape)

        elif node.tag == self.SVG_ELLIPSE:
            cx = parseLength(node.get('cx', '0'))
            cy = parseLength(node.get('cy', '0'))
            rx = parseLength(node.get('rx'))
            ry = parseLength(node.get('ry'))

            if rx > 0. and ry > 0.:
                shape = Ellipse(cx, cy, rx, ry)
                self.addShape(parent, node, shape)

        elif node.tag == self.SVG_POLYLINE:
            # convert points
            points = node.get('points').strip()
            if len(points) == 0:
                return

            points = list(map(parseLength, re.split('[ ,]+', points)))

            # Need to use two shapes, because standard RLG polylines
            # do not support filling...
            group = Group()
            shape = Polygon(points)
            self.applyStyleToShape(shape, node)
            shape.strokeColor = None
            group.add(shape)

            shape = PolyLine(points)
            self.applyStyleToShape(shape, node)
            group.add(shape)

            self.addShape(parent, node, group)

        elif node.tag == self.SVG_POLYGON:
            # convert points
            points = node.get('points').strip()
            if len(points) == 0:
                return

            points = list(map(parseLength, re.split('[ ,]+', points)))

            shape = Polygon(points)
            self.addShape(parent, node, shape)

        elif node.tag == self.SVG_IMAGE:
            x = parseLength(node.get('x', '0'))
            y = parseLength(node.get('y', '0'))
            width = parseLength(node.get('width', '0'))
            height = parseLength(node.get('height', '0'))

            # link id
            link_id = node.get(self.LINK)

            filename = os.path.join(os.path.dirname(self.filename), link_id)
            shape = Image(x, y, width, height, filename)

            self.addShape(parent, node, shape)

        elif node.tag == self.SVG_TEXT:
            # Todo:
            # - rotation not handled
            # - baseshift not handled
            # - embedded span node not handled
            #
            def parsePos(node, subnode, name, default='0'):
                values = subnode.get(name)
                if values is None:
                    if node is not None:
                        values = node.get(name, default)
                    else:
                        values = default

                return list(map(parseLength, values.split()))

            def getPos(values, i, default=None):
                if i >= len(values):
                    if default is None:
                        return values[-1]
                    else:
                        return default
                else:
                    return values[i]

            def handleText(node, subnode, text):
                # get position variables
                xs = parsePos(node, subnode, 'x')
                dxs = parsePos(node, subnode, 'dx')
                ys = parsePos(node, subnode, 'y')
                dys = parsePos(node, subnode, 'dy')

                if sum(map(len, (xs, ys, dxs, dys))) == 4:
                    # single value
                    shape = String(xs[0] + dxs[0], -ys[0] - dys[0], text)
                    self.applyStyleToShape(shape, subnode)
                    group.add(shape)

                else:
                    # multiple values
                    for i, c in enumerate(text):
                        x = getPos(xs, i)
                        dx = getPos(dxs, i, 0)
                        y = getPos(ys, i)
                        dy = getPos(dys, i, 0)

                        shape = String(x + dx, -y - dy, c)
                        self.applyStyleToShape(shape, subnode)
                        group.add(shape)

            if node.text and node.text.strip():
                group = Group()

                handleText(None, node, node.text.strip())

                group.scale(1, -1)

                self.addShape(parent, node, group)

            if len(node) > 0:
                group = Group()

                self.level += 1

                # set this levels style
                style = self.styles[self.level - 1].copy()
                nodestylestyle = self.nodeStyle(node, style)
                self.styles[self.level] = nodestylestyle

                for subnode in node:
                    if subnode.tag == self.SVG_TSPAN:
                        handleText(node, subnode, subnode.text.strip())

                self.level -= 1

                group.scale(1, -1)
                self.addShape(parent, node, group)

        elif node.tag == self.SVG_PATH:

            def convertQuadratic(Q0, Q1, Q2):
                C1 = (Q0[0] + 2. / 3 * (Q1[0] - Q0[0]),
                      Q0[1] + 2. / 3 * (Q1[1] - Q0[1]))
                C2 = (C1[0] + 1. / 3 * (Q2[0] - Q0[0]),
                      C1[1] + 1. / 3 * (Q2[1] - Q0[1]))
                C3 = Q2
                return C1[0], C1[1], C2[0], C2[1], C3[0], C3[1]

            def prevCtrl(lastOp, lastArgs, currentX, currentY):
                # fetch last controll point
                if lastOp in 'CScsQqTt':
                    x, y = lastArgs[-2]

                    # mirror about current point
                    return currentX + (currentX - x), currentY + (currentY - y)

                else:
                    # defaults to current point
                    return currentX, currentY

            # store sub paths in 'paths' list
            shape = Path()

            # keep track of current point and path start point
            startX, startY = 0., 0.
            currentX, currentY = 0., 0.

            # keep track of last operation
            lastOp = None
            lastArgs = None

            # avoid empty path data
            data = node.get('d')
            if data is None or len(data) == 0:
                return

            for op, args in parsePath.iterparse(data):
                if op == 'z' or op == 'Z':
                    # close path or subpath
                    shape.closePath()

                    # next sub path starts at begining of current path
                    currentX, currentY = startX, startY

                elif op == 'M':
                    # moveto absolute
                    if lastOp is not None and lastOp not in ('z', 'Z'):
                        # close sub path
                        shape.closePath()

                    x, y = args[0]
                    shape.moveTo(x, y)

                    startX, startY = x, y

                    # multiple moveto arge result in line
                    for x, y in args[1:]:
                        shape.lineTo(x, y)

                    currentX, currentY = x, y

                elif op == 'm':
                    if lastOp is not None and lastOp not in ('z', 'Z'):
                        # close sub path
                        shape.closePath()

                    # moveto relative
                    rx, ry = args[0]
                    x, y = currentX + rx, currentY + ry
                    shape.moveTo(x, y)

                    startX, startY = x, y
                    currentX, currentY = x, y

                    # multiple moveto arge result in line
                    for rx, ry in args[1:]:
                        x, y = currentX + rx, currentY + ry
                        shape.lineTo(x, y)
                        currentX, currentY = x, y

                elif op == 'L':
                    # lineto absolute
                    for x, y in args:
                        shape.lineTo(x, y)

                    currentX, currentY = x, y

                elif op == 'l':
                    # lineto relative
                    for rx, ry in args:
                        x, y = currentX + rx, currentY + ry
                        shape.lineTo(x, y)
                        currentX, currentY = x, y

                elif op == 'V':
                    # vertical line absolute
                    for y in args:
                        shape.lineTo(currentX, y)

                    currentY = y

                elif op == 'v':
                    # vertical line relative
                    for ry in args:
                        y = currentY + ry
                        shape.lineTo(currentX, y)
                        currentY = y

                elif op == 'H':
                    # horisontal line absolute
                    for x in args:
                        shape.lineTo(x, currentY)
                    currentX = x

                elif op == 'h':
                    # horisontal line relative
                    for rx in args:
                        x = currentX + rx
                        shape.lineTo(x, currentY)
                    currentX = x

                elif op == 'C':
                    # cubic bezier absolute
                    for p1, p2, p3 in zip(*([iter(args)] * 3)):
                        shape.curveTo(*(p1 + p2 + p3))
                        currentX, currentY = p3

                elif op == 'c':
                    # cubic bezier relative
                    for pnts in zip(*([iter(args)] * 3)):
                        (x1, y1), (x2, y2), (x3, y3) = pnts
                        pnts = tuple(
                            (p[0] + currentX, p[1] + currentY) for p in pnts)
                        shape.curveTo(*(pnts[0] + pnts[1] + pnts[2]))
                        currentX, currentY = pnts[2]
                        lastOp = op
                        lastArgs = pnts
                    continue

                elif op == 'S':
                    # shorthand cubic bezier absolute
                    for p2, p3 in zip(*([iter(args)] * 2)):
                        x1, y1 = prevCtrl(lastOp, lastArgs, currentX, currentY)
                        x2, y2 = p2
                        x3, y3 = p3
                        shape.curveTo(x1, y1, x2, y2, x3, y3)
                        lastOp = op
                        lastArgs = (x2, y2), (x3, y3)
                        currentX, currentY = x3, y3
                    continue

                elif op == 's':
                    # shorthand cubic bezier relative
                    for p2, p3 in zip(*([iter(args)] * 2)):
                        x1, y1 = prevCtrl(lastOp, lastArgs, currentX, currentY)
                        x2, y2 = p2
                        x2, y2 = x2 + currentX, y2 + currentY
                        x3, y3 = p3
                        x3, y3 = x3 + currentX, y3 + currentY
                        shape.curveTo(x1, y1, x2, y2, x3, y3)
                        currentX, currentY = x3, y3
                        lastOp = op
                        lastArgs = (x1, y1), (x2, y2), (x3, y3)
                    continue

                elif op == 'Q':
                    # quadratic bezier absolute
                    for p2, p3 in zip(*([iter(args)] * 2)):
                        x1, y1 = currentX, currentY
                        x2, y2 = p2
                        x3, y3 = p3
                        ctrls = convertQuadratic((x1, y1), (x2, y2), (x3, y3))
                        shape.curveTo(*ctrls)
                        currentX, currentY = x3, y3
                    lastOp = op
                    lastArgs = (x2, y2), (x3, y3)
                    continue

                elif op == 'q':
                    # quadratic bezier relative
                    for p2, p3 in zip(*([iter(args)] * 2)):
                        x1, y1 = currentX, currentY
                        x2, y2 = p2
                        x2, y2 = x2 + currentX, y2 + currentY
                        x3, y3 = p3
                        x3, y3 = x3 + currentX, y3 + currentY
                        ctrls = convertQuadratic((x1, y1), (x2, y2), (x3, y3))
                        shape.curveTo(*ctrls)
                        currentX, currentY = x3, y3

                    lastOp = op
                    lastArgs = (x2, y2), (x3, y3)
                    continue

                elif op == 'T':
                    # shorthand quadratic bezier absolute
                    for i in range(len(args)):
                        x1, y1 = currentX, currentY
                        x2, y2 = prevCtrl(lastOp, lastArgs, currentX, currentY)
                        x3, y3 = args[i]
                        ctrls = convertQuadratic((x1, y1), (x2, y2), (x3, y3))
                        shape.curveTo(*ctrls)
                        currentX, currentY = x3, y3
                        lastOp = op
                        lastArgs = (x2, y2), (x3, y3)

                    continue

                elif op == 't':
                    # shorthand quadratic bezier relative
                    for i in range(len(args)):
                        x1, y1 = currentX, currentY
                        x2, y2 = prevCtrl(lastOp, lastArgs, currentX, currentY)
                        x3, y3 = args[i]
                        x3, y3 = x3 + currentX, y3 + currentY
                        ctrls = convertQuadratic((x1, y1), (x2, y2), (x3, y3))
                        shape.curveTo(*ctrls)
                        currentX, currentY = x3, y3
                        lastOp = op
                        lastArgs = (x2, y2), (x3, y3)

                    continue

                elif op == 'A' or op == 'a':
                    # elliptic arc missing
                    continue

                lastOp = op
                lastArgs = args

            # check if fill applies to path
            fill = None
            if node.get('fill'):
                # inline style
                fill = node.get('fill')
            else:
                # try local style
                if node.get('style'):
                    style = parseStyle.parse(node.get('style'))

                    if 'fill' in style:
                        fill = style['fill']

                # try global style
                if fill is None:
                    style = self.styles[self.level]

                    if 'fill' in style:
                        fill = style['fill']
                    else:
                        fill = 'none'

            # hack because RLG has no "semi-closed" paths...
            if lastOp == 'z' or lastOp == 'Z' or fill == 'none':
                self.addShape(parent, node, shape)

            else:
                group = Group()
                strokeshape = shape.copy()
                self.addShape(group, node, strokeshape, fill='none')
                shape.closePath()
                self.addShape(group, node, shape, stroke='none')
                self.addShape(parent, node, group)

        elif node.tag == self.SVG_TITLE or node.tag == self.SVG_DESC:
            # Skip non-graphics elements
            return
def drawLines():
    d = Drawing(100, 100)
    d.add(PolyLine([(45, 45), (55, 55), (55, 45), (45, 55)], strokeColor=colors.blue))
    renderPDF.drawToFile(d, 'polyLine.pdf', 'A simple PDF file')
 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(
         Line(40,
              30,
              220,
              30,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(74.54545,
              30,
              74.54545,
              25,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(110.9091,
              30,
              110.9091,
              25,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(147.2727,
              30,
              147.2727,
              25,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(183.6364,
              30,
              183.6364,
              25,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(220,
              30,
              220,
              25,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 74.54545, 25)
     v0.add(
         String(-7.5,
                -10,
                '200',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 110.9091, 25)
     v0.add(
         String(-7.5,
                -10,
                '400',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 147.2727, 25)
     v0.add(
         String(-7.5,
                -10,
                '600',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 183.6364, 25)
     v0.add(
         String(-7.5,
                -10,
                '800',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 220, 25)
     v0.add(
         String(-10,
                -10,
                '1000',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         Line(40,
              30,
              40,
              115,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(40,
              34.59459,
              35,
              34.59459,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(40,
              57.56757,
              35,
              57.56757,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(40,
              80.54054,
              35,
              80.54054,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(40,
              103.5135,
              35,
              103.5135,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 35, 34.59459)
     v0.add(
         String(-25.08,
                -4,
                '1e+02',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 35, 57.56757)
     v0.add(
         String(-25.08,
                -4,
                '1e+04',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 35, 80.54054)
     v0.add(
         String(-25.08,
                -4,
                '1e+06',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 35, 103.5135)
     v0.add(
         String(-25.08,
                -4,
                '1e+08',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         PolyLine(points=[
             40, 34.59459, 41.81818, 41.51015, 43.63636, 45.55549, 45.45455,
             48.4257, 47.27273, 50.65201, 49.09091, 52.47104, 50.90909,
             54.00901, 52.72727, 55.34126, 54.54545, 56.51638, 56.36364,
             57.56757, 58.18182, 58.51848, 60, 59.3866, 61.81818, 60.18519,
             63.63636, 60.92456, 65.45455, 61.61291, 67.27273, 62.25681,
             69.09091, 62.86166, 70.90909, 63.43194, 72.72727, 63.97137,
             74.54545, 64.48312, 76.36364, 64.9699, 78.18182, 65.43403, 80,
             65.87753, 81.81818, 66.30215, 83.63636, 66.70943, 85.45455,
             67.10074, 87.27273, 67.47728, 89.09091, 67.84012, 90.90909,
             68.19022, 92.72727, 68.52846, 94.54545, 68.85561, 96.36364,
             69.17236, 98.18182, 69.47937, 100, 69.77722, 101.8182,
             70.06643, 103.6364, 70.34749, 105.4545, 70.62085, 107.2727,
             70.88692, 109.0909, 71.14608, 110.9091, 71.39868, 112.7273,
             71.64503, 114.5455, 71.88546, 116.3636, 72.12022, 118.1818,
             72.34959, 120, 72.5738, 121.8182, 72.79309, 123.6364, 73.00765,
             125.4545, 73.2177, 127.2727, 73.42342, 129.0909, 73.62499,
             130.9091, 73.82256, 132.7273, 74.01629, 134.5455, 74.20634,
             136.3636, 74.39283, 138.1818, 74.5759, 140, 74.75567, 141.8182,
             74.93226, 143.6364, 75.10578, 145.4545, 75.27633, 147.2727,
             75.44402, 149.0909, 75.60893, 150.9091, 75.77116, 152.7273,
             75.9308, 154.5455, 76.08792, 156.3636, 76.2426, 158.1818,
             76.39493, 160, 76.54496, 161.8182, 76.69277, 163.6364,
             76.83843, 165.4545, 76.98198, 167.2727, 77.1235, 169.0909,
             77.26304, 170.9091, 77.40066, 172.7273, 77.5364, 174.5455,
             77.67033, 176.3636, 77.80247, 178.1818, 77.9329, 180, 78.06163,
             181.8182, 78.18873, 183.6364, 78.31423, 185.4545, 78.43817,
             187.2727, 78.56059, 189.0909, 78.68152, 190.9091, 78.80101,
             192.7273, 78.91908, 194.5455, 79.03578, 196.3636, 79.15112,
             198.1818, 79.26514, 200, 79.37788, 201.8182, 79.48935,
             203.6364, 79.5996, 205.4545, 79.70864, 207.2727, 79.8165,
             209.0909, 79.92321, 210.9091, 80.02879, 212.7273, 80.13326,
             214.5455, 80.23665, 216.3636, 80.33898, 218.1818, 80.44027,
             220, 80.54054
         ],
                  strokeColor=Color(1, 0, 0, 1),
                  strokeWidth=.2,
                  strokeLineCap=0,
                  strokeLineJoin=1,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None))
     self.add(
         PolyLine(points=[
             40, 46.08108, 41.81818, 56.45441, 43.63636, 62.52242, 45.45455,
             66.82774, 47.27273, 70.16721, 49.09091, 72.89575, 50.90909,
             75.2027, 52.72727, 77.20107, 54.54545, 78.96376, 56.36364,
             80.54054, 58.18182, 81.96691, 60, 83.26908, 61.81818, 84.46697,
             63.63636, 85.57603, 65.45455, 86.60855, 67.27273, 87.5744,
             69.09091, 88.48169, 70.90909, 89.33709, 72.72727, 90.14624,
             74.54545, 90.91387, 76.36364, 91.64404, 78.18182, 92.34024, 80,
             93.00549, 81.81818, 93.64241, 83.63636, 94.25334, 85.45455,
             94.8403, 87.27273, 95.4051, 89.09091, 95.94936, 90.90909,
             96.47453, 92.72727, 96.98188, 94.54545, 97.4726, 96.36364,
             97.94774, 98.18182, 98.40825, 100, 98.85502, 101.8182,
             99.28883, 103.6364, 99.71042, 105.4545, 100.1205, 107.2727,
             100.5196, 109.0909, 100.9083, 110.9091, 101.2872, 112.7273,
             101.6567, 114.5455, 102.0174, 116.3636, 102.3695, 118.1818,
             102.7136, 120, 103.0499, 121.8182, 103.3788, 123.6364,
             103.7007, 125.4545, 104.0157, 127.2727, 104.3243, 129.0909,
             104.6267, 130.9091, 104.923, 132.7273, 105.2136, 134.5455,
             105.4987, 136.3636, 105.7784, 138.1818, 106.053, 140, 106.3227,
             141.8182, 106.5876, 143.6364, 106.8479, 145.4545, 107.1037,
             147.2727, 107.3552, 149.0909, 107.6026, 150.9091, 107.8459,
             152.7273, 108.0854, 154.5455, 108.3211, 156.3636, 108.5531,
             158.1818, 108.7816, 160, 109.0066, 161.8182, 109.2283,
             163.6364, 109.4468, 165.4545, 109.6622, 167.2727, 109.8744,
             169.0909, 110.0838, 170.9091, 110.2902, 172.7273, 110.4938,
             174.5455, 110.6947, 176.3636, 110.8929, 178.1818, 111.0885,
             180, 111.2816, 181.8182, 111.4723, 183.6364, 111.6605,
             185.4545, 111.8464, 187.2727, 112.0301, 189.0909, 112.2115,
             190.9091, 112.3907, 192.7273, 112.5678, 194.5455, 112.7429,
             196.3636, 112.9159, 198.1818, 113.0869, 200, 113.256, 201.8182,
             113.4232, 203.6364, 113.5886, 205.4545, 113.7521, 207.2727,
             113.9139, 209.0909, 114.074, 210.9091, 114.2324, 212.7273,
             114.3891, 214.5455, 114.5442, 216.3636, 114.6977, 218.1818,
             114.8496, 220, 115
         ],
                  strokeColor=Color(0, 0, 1, 1),
                  strokeWidth=.2,
                  strokeLineCap=0,
                  strokeLineJoin=1,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None))
     self.add(
         PolyLine(points=[
             40, 30, 41.81818, 35.53244, 43.63636, 38.76871, 45.45455,
             41.06489, 47.27273, 42.84594, 49.09091, 44.30116, 50.90909,
             45.53153, 52.72727, 46.59733, 54.54545, 47.53743, 56.36364,
             48.37838, 58.18182, 49.13911, 60, 49.8336, 61.81818, 50.47247,
             63.63636, 51.06397, 65.45455, 51.61465, 67.27273, 52.12977,
             69.09091, 52.61366, 70.90909, 53.06987, 72.72727, 53.50142,
             74.54545, 53.91082, 76.36364, 54.30025, 78.18182, 54.67155, 80,
             55.02635, 81.81818, 55.36604, 83.63636, 55.69187, 85.45455,
             56.00492, 87.27273, 56.30614, 89.09091, 56.59642, 90.90909,
             56.8765, 92.72727, 57.14709, 94.54545, 57.40881, 96.36364,
             57.66222, 98.18182, 57.90782, 100, 58.1461, 101.8182, 58.37747,
             103.6364, 58.60232, 105.4545, 58.821, 107.2727, 59.03386,
             109.0909, 59.24119, 110.9091, 59.44326, 112.7273, 59.64035,
             114.5455, 59.83269, 116.3636, 60.0205, 118.1818, 60.204, 120,
             60.38337, 121.8182, 60.55879, 123.6364, 60.73045, 125.4545,
             60.89849, 127.2727, 61.06306, 129.0909, 61.22431, 130.9091,
             61.38237, 132.7273, 61.53736, 134.5455, 61.68939, 136.3636,
             61.83859, 138.1818, 61.98504, 140, 62.12886, 141.8182,
             62.27013, 143.6364, 62.40895, 145.4545, 62.54539, 147.2727,
             62.67954, 149.0909, 62.81147, 150.9091, 62.94125, 152.7273,
             63.06896, 154.5455, 63.19466, 156.3636, 63.31841, 158.1818,
             63.44027, 160, 63.56029, 161.8182, 63.67854, 163.6364,
             63.79506, 165.4545, 63.90991, 167.2727, 64.02313, 169.0909,
             64.13476, 170.9091, 64.24485, 172.7273, 64.35345, 174.5455,
             64.46059, 176.3636, 64.5663, 178.1818, 64.67064, 180, 64.77363,
             181.8182, 64.87531, 183.6364, 64.97571, 185.4545, 65.07486,
             187.2727, 65.1728, 189.0909, 65.26954, 190.9091, 65.36513,
             192.7273, 65.45959, 194.5455, 65.55294, 196.3636, 65.64522,
             198.1818, 65.73644, 200, 65.82663, 201.8182, 65.91581,
             203.6364, 66.004, 205.4545, 66.09124, 207.2727, 66.17752,
             209.0909, 66.26289, 210.9091, 66.34735, 212.7273, 66.43093,
             214.5455, 66.51364, 216.3636, 66.59551, 218.1818, 66.67654,
             220, 66.75676
         ],
                  strokeColor=Color(0, .501961, 0, 1),
                  strokeWidth=.2,
                  strokeLineCap=0,
                  strokeLineJoin=1,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None))
Example #15
0
    def makeLines(self):
        g = Group()
        bubblePlot = getattr(self,'_bubblePlot',None)
        if bubblePlot:
            yA = self.yValueAxis
            xA = self.xValueAxis
            bubbleR = min(yA._bubbleRadius,xA._bubbleRadius)
            bubbleMax = xA._bubbleMax

        labelFmt = self.lineLabelFormat

        P = range(len(self._positions))
        if self.reversePlotOrder: P.reverse()
        inFill = getattr(self,'_inFill',None)
        styleCount = len(self.lines)
        if inFill or [rowNo for rowNo in P if getattr(self.lines[rowNo%styleCount],'inFill',False)]:
            inFillY = self.xValueAxis._y
            inFillX0 = self.yValueAxis._x
            inFillX1 = inFillX0 + self.xValueAxis._length
            inFillG = getattr(self,'_inFillG',g)
        lG = getattr(self,'_lineG',g)
        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            rowStyle = self.lines[rowNo % styleCount]
            rowColor = getattr(rowStyle,'strokeColor',None)
            dash = getattr(rowStyle, 'strokeDashArray', None)

            if hasattr(rowStyle, 'strokeWidth'):
                width = rowStyle.strokeWidth
            elif hasattr(self.lines, 'strokeWidth'):
                width = self.lines.strokeWidth
            else:
                width = None

            # Iterate over data columns.
            if self.joinedLines:
                points = []
                for xy in row:
                    points = points + [xy[0], xy[1]]
                if inFill or getattr(rowStyle,'inFill',False):
                    fpoints = [inFillX0,inFillY] + points + [inFillX1,inFillY]
                    filler = getattr(rowStyle, 'filler', None)
                    if filler:
                        filler.fill(self,inFillG,rowNo,rowColor,fpoints)
                    else:
                        inFillG.add(Polygon(fpoints,fillColor=rowColor,strokeColor=rowColor,strokeWidth=width or 0.1))
                if inFill in (None,0,2):
                    line = PolyLine(points,strokeColor=rowColor,strokeLineCap=0,strokeLineJoin=1)
                    if width:
                        line.strokeWidth = width
                    if dash:
                        line.strokeDashArray = dash
                    lG.add(line)

            if hasattr(rowStyle, 'symbol'):
                uSymbol = rowStyle.symbol
            elif hasattr(self.lines, 'symbol'):
                uSymbol = self.lines.symbol
            else:
                uSymbol = None

            if uSymbol:
                j = -1
                if bubblePlot: drow = self.data[rowNo]
                for xy in row:
                    j += 1
                    symbol = uSymbol2Symbol(uSymbol,xy[0],xy[1],rowColor)
                    if symbol:
                        if bubblePlot:
                            symbol.size = bubbleR*(drow[j][2]/bubbleMax)**0.5
                        g.add(symbol)

            # Draw data labels.
            for colNo in range(len(row)):
                x1, y1 = row[colNo]
                self.drawLabel(g, rowNo, colNo, x1, y1)

            shader = getattr(rowStyle, 'shader', None)
            if shader: shader.shade(self,g,rowNo,rowColor,row)

        return g
Example #16
0
 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(
         Rect(50,
              50,
              300,
              125,
              rx=0,
              ry=0,
              fillColor=None,
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              50,
              350,
              50,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(110,
              50,
              110,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(170,
              50,
              170,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(200,
              50,
              200,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(230,
              50,
              230,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(290,
              50,
              290,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(350,
              50,
              350,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 110, 45)
     v0.add(
         String(-6.25,
                -10,
                '1.0',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 170, 45)
     v0.add(
         String(-6.25,
                -10,
                '2.0',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 200, 45)
     v0.add(
         String(-6.25,
                -10,
                '2.5',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 230, 45)
     v0.add(
         String(-6.25,
                -10,
                '3.0',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 290, 45)
     v0.add(
         String(-6.25,
                -10,
                '4.0',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 350, 45)
     v0.add(
         String(-6.25,
                -10,
                '5.0',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         Line(50,
              50,
              50,
              175,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              67.85714,
              45,
              67.85714,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              85.71429,
              45,
              85.71429,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              103.5714,
              45,
              103.5714,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              139.2857,
              45,
              139.2857,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              157.1429,
              45,
              157.1429,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 67.85714)
     v0.add(
         String(-5,
                -4,
                '1',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 85.71429)
     v0.add(
         String(-5,
                -4,
                '2',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 103.5714)
     v0.add(
         String(-5,
                -4,
                '3',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 139.2857)
     v0.add(
         String(-5,
                -4,
                '5',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 157.1429)
     v0.add(
         String(-5,
                -4,
                '6',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         PolyLine(points=[
             110, 67.85714, 170, 85.71429, 200, 67.85714, 230, 103.5714,
             290, 139.2857
         ],
                  strokeColor=Color(1, 0, 0, 1),
                  strokeWidth=1,
                  strokeLineCap=0,
                  strokeLineJoin=1,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None))
     self.add(
         PolyLine(points=[
             110, 85.71429, 170, 103.5714, 200, 85.71429, 260, 139.2857,
             290, 157.1429
         ],
                  strokeColor=Color(0, 0, 1, 1),
                  strokeWidth=1,
                  strokeLineCap=0,
                  strokeLineJoin=1,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None))
     self.add(
         Circle(110,
                67.85714,
                2.5,
                fillColor=Color(1, 0, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(170,
                85.71429,
                2.5,
                fillColor=Color(1, 0, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(200,
                67.85714,
                2.5,
                fillColor=Color(1, 0, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(230,
                103.5714,
                2.5,
                fillColor=Color(1, 0, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(290,
                139.2857,
                2.5,
                fillColor=Color(1, 0, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 110, 77.85714)
     v0.add(
         String(-3.75,
                -4,
                ' 1',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 170, 95.71429)
     v0.add(
         String(-3.75,
                -4,
                ' 2',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 200, 77.85714)
     v0.add(
         String(-3.75,
                -4,
                ' 1',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 230, 113.5714)
     v0.add(
         String(-3.75,
                -4,
                ' 3',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 290, 149.2857)
     v0.add(
         String(-3.75,
                -4,
                ' 5',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         Circle(110,
                85.71429,
                2.5,
                fillColor=Color(0, 0, 1, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(170,
                103.5714,
                2.5,
                fillColor=Color(0, 0, 1, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(200,
                85.71429,
                2.5,
                fillColor=Color(0, 0, 1, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(260,
                139.2857,
                2.5,
                fillColor=Color(0, 0, 1, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(290,
                157.1429,
                2.5,
                fillColor=Color(0, 0, 1, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 110, 95.71429)
     v0.add(
         String(-3.75,
                -4,
                ' 2',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 170, 113.5714)
     v0.add(
         String(-3.75,
                -4,
                ' 3',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 200, 95.71429)
     v0.add(
         String(-3.75,
                -4,
                ' 2',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 260, 149.2857)
     v0.add(
         String(-3.75,
                -4,
                ' 5',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 290, 167.1429)
     v0.add(
         String(-3.75,
                -4,
                ' 6',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
#C:\python27\python
#this is only prototype
from reportlab.graphics.shapes import Drawing, String, PolyLine
from reportlab.graphics import renderPDF

d = Drawing(100, 100)
s = String(50, 50, 'Hello, world', textAnchor='middle')
d.add(s)
p = PolyLine([(0, 0), (10, 10), (10, 0), (0, 10)])
d.add(p)
renderPDF.drawToFile(d, 'hello.pdf', 'A simple PDF FILE')
Example #18
0
 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(
         Line(10,
              10,
              390,
              190,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Circle(100,
                100,
                20,
                fillColor=Color(0, .501961, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(200,
                100,
                40,
                fillColor=Color(0, .501961, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(300,
                100,
                30,
                fillColor=Color(0, .501961, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Wedge(330,
               100,
               40,
               -10,
               40,
               yradius=None,
               annular=False,
               fillColor=Color(0, .501961, 0, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=0,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         PolyLine(points=[
             120, 10, 130, 20, 140, 10, 150, 20, 160, 10, 170, 20, 180, 10,
             190, 20, 200, 10
         ],
                  strokeColor=Color(0, 0, 0, 1),
                  strokeWidth=1,
                  strokeLineCap=0,
                  strokeLineJoin=0,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None,
                  fillColor=Color(0, .501961, 0, 1)))
     self.add(
         Polygon(points=[300, 20, 350, 20, 390, 80, 300, 75, 330, 40],
                 fillColor=Color(0, .501961, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Ellipse(50,
                 150,
                 40,
                 20,
                 fillColor=Color(0, .501961, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Rect(120,
              150,
              60,
              30,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(1, 1, 0, 1),
              strokeWidth=10,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(220,
              150,
              60,
              30,
              rx=10,
              ry=10,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         String(10,
                50,
                'Basic Shapes',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
Example #19
0
    def makeLines(self):
        g = Group()

        labelFmt = self.lineLabelFormat
        P = range(len(self._positions))
        if self.reversePlotOrder: P.reverse()
        inFill = self.inFill
        if inFill:
            inFillY = self.categoryAxis._y
            inFillX0 = self.valueAxis._x
            inFillX1 = inFillX0 + self.categoryAxis._length
            inFillG = getattr(self,'_inFillG',g)
        yzero = self._yzero

        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            styleCount = len(self.lines)
            styleIdx = rowNo % styleCount
            rowStyle = self.lines[styleIdx]
            rowColor = rowStyle.strokeColor
            dash = getattr(rowStyle, 'strokeDashArray', None)
            lineStyle = getattr(rowStyle,'lineStyle',None)

            if hasattr(rowStyle, 'strokeWidth'):
                strokeWidth = rowStyle.strokeWidth
            elif hasattr(self.lines, 'strokeWidth'):
                strokeWidth = self.lines.strokeWidth
            else:
                strokeWidth = None

            # Iterate over data columns.
            if lineStyle=='bar':
                barWidth = getattr(rowStyle,'barWidth',Percentage(50))
                fillColor = getattr(rowStyle,'fillColor',rowColor)
                if isinstance(barWidth,Percentage):
                    hbw = self._hngs*barWidth*0.01
                else:
                    hbw = barWidth*0.5
                for colNo in range(len(row)):
                    x,y = row[colNo]
                    g.add(Rect(x-hbw,min(y,yzero),2*hbw,abs(y-yzero),strokeWidth=strokeWidth,strokeColor=rowColor,fillColor=fillColor))
            elif self.joinedLines or lineStyle=='joinedLine':
                points = []
                for colNo in range(len(row)):
                    points += row[colNo]
                if inFill:
                    points = points + [inFillX1,inFillY,inFillX0,inFillY]
                    inFillG.add(Polygon(points,fillColor=rowColor,strokeColor=rowColor,strokeWidth=0.1))
                else:
                    line = PolyLine(points,strokeColor=rowColor,strokeLineCap=0,strokeLineJoin=1)
                    if strokeWidth:
                        line.strokeWidth = strokeWidth
                    if dash:
                        line.strokeDashArray = dash
                    g.add(line)

            if hasattr(rowStyle, 'symbol'):
                uSymbol = rowStyle.symbol
            elif hasattr(self.lines, 'symbol'):
                uSymbol = self.lines.symbol
            else:
                uSymbol = None

            if uSymbol:
                for colNo in range(len(row)):
                    x1, y1 = row[colNo]
                    symbol = uSymbol2Symbol(uSymbol,x1,y1,rowStyle.strokeColor)
                    if symbol: g.add(symbol)

            # Draw item labels.
            for colNo in range(len(row)):
                x1, y1 = row[colNo]
                self.drawLabel(g, rowNo, colNo, x1, y1)

        return g
    def makeLines(self):
        g = Group()

        labelFmt = self.lineLabelFormat
        P = self._positions
        if self.reversePlotOrder: P.reverse()
        lines = self.lines
        styleCount = len(lines)
        _inFill = self.inFill
        if (_inFill or self._pairInFills or [
                rowNo for rowNo in range(len(P))
                if getattr(lines[rowNo % styleCount], 'inFill', False)
        ]):
            inFillY = self.categoryAxis._y
            inFillX0 = self.valueAxis._x
            inFillX1 = inFillX0 + self.categoryAxis._length
            inFillG = getattr(self, '_inFillG', g)
        yzero = self._yzero

        # Iterate over data rows.
        for rowNo, row in enumerate(
                reversed(P) if self.reversePlotOrder else P):
            styleIdx = rowNo % styleCount
            rowStyle = lines[styleIdx]
            strokeColor = rowStyle.strokeColor
            fillColor = getattr(rowStyle, 'fillColor', strokeColor)
            inFill = getattr(rowStyle, 'inFill', _inFill)
            dash = getattr(rowStyle, 'strokeDashArray', None)
            lineStyle = getattr(rowStyle, 'lineStyle', None)

            if hasattr(rowStyle, 'strokeWidth'):
                strokeWidth = rowStyle.strokeWidth
            elif hasattr(lines, 'strokeWidth'):
                strokeWidth = lines.strokeWidth
            else:
                strokeWidth = None

            # Iterate over data columns.
            if lineStyle == 'bar':
                barWidth = getattr(rowStyle, 'barWidth', Percentage(50))
                if isinstance(barWidth, Percentage):
                    hbw = self._hngs * barWidth * 0.01
                else:
                    hbw = barWidth * 0.5
                for x, y in row:
                    g.add(
                        Rect(x - hbw,
                             min(y, yzero),
                             2 * hbw,
                             abs(y - yzero),
                             strokeWidth=strokeWidth,
                             strokeColor=strokeColor,
                             fillColor=fillColor))
            elif self.joinedLines or lineStyle == 'joinedLine':
                points = flatten(row)
                if inFill or isinstance(row, FillPairedData):
                    filler = getattr(rowStyle, 'filler', None)
                    if isinstance(row, FillPairedData):
                        fpoints = points + flatten(reversed(P[row.other]))
                    else:
                        fpoints = [inFillX0, inFillY
                                   ] + points + [inFillX1, inFillY]
                    if filler:
                        filler.fill(self, inFillG, rowNo, fillColor, fpoints)
                    else:
                        inFillG.add(
                            Polygon(fpoints,
                                    fillColor=fillColor,
                                    strokeColor=strokeColor
                                    if strokeColor == fillColor else None,
                                    strokeWidth=strokeWidth or 0.1))
                if not inFill or inFill == 2 or strokeColor != fillColor:
                    line = PolyLine(points,
                                    strokeColor=strokeColor,
                                    strokeLineCap=0,
                                    strokeLineJoin=1)
                    if strokeWidth:
                        line.strokeWidth = strokeWidth
                    if dash:
                        line.strokeDashArray = dash
                    g.add(line)

            if hasattr(rowStyle, 'symbol'):
                uSymbol = rowStyle.symbol
            elif hasattr(lines, 'symbol'):
                uSymbol = lines.symbol
            else:
                uSymbol = None

            if uSymbol:
                for colNo, (x, y) in enumerate(row):
                    symbol = uSymbol2Symbol(tpcGetItem(uSymbol, colNo), x, y,
                                            rowStyle.strokeColor)
                    if symbol: g.add(symbol)

            # Draw item labels.
            for colNo, (x, y) in enumerate(row):
                self.drawLabel(g, rowNo, colNo, x, y)

        return g
Example #21
0
 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(
         PolyLine(points=[
             68.75, 77.08333, 106.25, 60.41667, 143.75, 91.66667, 181.25,
             95.83333, 218.75, 127.0833, 256.25, 143.75, 293.75, 89.58333,
             331.25, 58.33333
         ],
                  strokeColor=Color(1, 0, 0, 1),
                  strokeWidth=1,
                  strokeLineCap=0,
                  strokeLineJoin=1,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None))
     self.add(
         PolyLine(points=[
             68.75, 60.41667, 106.25, 91.66667, 143.75, 145.8333, 181.25,
             129.1667, 218.75, 97.91667, 256.25, 93.75, 293.75, 62.5,
             331.25, 79.16667
         ],
                  strokeColor=Color(0, .501961, 0, 1),
                  strokeWidth=1,
                  strokeLineCap=0,
                  strokeLineJoin=1,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None))
     self.add(
         Polygon(points=[
             66.25, 77.08333, 68.75, 79.58333, 71.25, 77.08333, 68.75,
             74.58333
         ],
                 fillColor=Color(1, 0, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             103.75, 60.41667, 106.25, 62.91667, 108.75, 60.41667, 106.25,
             57.91667
         ],
                 fillColor=Color(1, 0, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             141.25, 91.66667, 143.75, 94.16667, 146.25, 91.66667, 143.75,
             89.16667
         ],
                 fillColor=Color(1, 0, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             178.75, 95.83333, 181.25, 98.33333, 183.75, 95.83333, 181.25,
             93.33333
         ],
                 fillColor=Color(1, 0, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             216.25, 127.0833, 218.75, 129.5833, 221.25, 127.0833, 218.75,
             124.5833
         ],
                 fillColor=Color(1, 0, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             253.75, 143.75, 256.25, 146.25, 258.75, 143.75, 256.25, 141.25
         ],
                 fillColor=Color(1, 0, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             291.25, 89.58333, 293.75, 92.08333, 296.25, 89.58333, 293.75,
             87.08333
         ],
                 fillColor=Color(1, 0, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             328.75, 58.33333, 331.25, 60.83333, 333.75, 58.33333, 331.25,
             55.83333
         ],
                 fillColor=Color(1, 0, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 68.75, 87.08333)
     v0.add(
         String(-5,
                -4,
                '13',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 106.25, 70.41667)
     v0.add(
         String(-3.75,
                -4,
                ' 5',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 143.75, 101.6667)
     v0.add(
         String(-5,
                -4,
                '20',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 181.25, 105.8333)
     v0.add(
         String(-5,
                -4,
                '22',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 218.75, 137.0833)
     v0.add(
         String(-5,
                -4,
                '37',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 256.25, 153.75)
     v0.add(
         String(-5,
                -4,
                '45',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 293.75, 99.58333)
     v0.add(
         String(-5,
                -4,
                '19',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 331.25, 68.33333)
     v0.add(
         String(-3.75,
                -4,
                ' 4',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         Polygon(points=[
             66.25, 60.41667, 68.75, 62.91667, 71.25, 60.41667, 68.75,
             57.91667
         ],
                 fillColor=Color(0, .501961, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             103.75, 91.66667, 106.25, 94.16667, 108.75, 91.66667, 106.25,
             89.16667
         ],
                 fillColor=Color(0, .501961, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             141.25, 145.8333, 143.75, 148.3333, 146.25, 145.8333, 143.75,
             143.3333
         ],
                 fillColor=Color(0, .501961, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             178.75, 129.1667, 181.25, 131.6667, 183.75, 129.1667, 181.25,
             126.6667
         ],
                 fillColor=Color(0, .501961, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             216.25, 97.91667, 218.75, 100.4167, 221.25, 97.91667, 218.75,
             95.41667
         ],
                 fillColor=Color(0, .501961, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             253.75, 93.75, 256.25, 96.25, 258.75, 93.75, 256.25, 91.25
         ],
                 fillColor=Color(0, .501961, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(
             points=[291.25, 62.5, 293.75, 65, 296.25, 62.5, 293.75, 60],
             fillColor=Color(0, .501961, 0, 1),
             fillOpacity=None,
             strokeColor=Color(0, 0, 0, 1),
             strokeWidth=.1,
             strokeLineCap=0,
             strokeLineJoin=0,
             strokeMiterLimit=0,
             strokeDashArray=None,
             strokeOpacity=None))
     self.add(
         Polygon(points=[
             328.75, 79.16667, 331.25, 81.66667, 333.75, 79.16667, 331.25,
             76.66667
         ],
                 fillColor=Color(0, .501961, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 68.75, 70.41667)
     v0.add(
         String(-3.75,
                -4,
                ' 5',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 106.25, 101.6667)
     v0.add(
         String(-5,
                -4,
                '20',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 143.75, 155.8333)
     v0.add(
         String(-5,
                -4,
                '46',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 181.25, 139.1667)
     v0.add(
         String(-5,
                -4,
                '38',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 218.75, 107.9167)
     v0.add(
         String(-5,
                -4,
                '23',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 256.25, 103.75)
     v0.add(
         String(-5,
                -4,
                '21',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 293.75, 72.5)
     v0.add(
         String(-3.75,
                -4,
                ' 6',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 331.25, 89.16667)
     v0.add(
         String(-5,
                -4,
                '14',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         Line(50,
              50,
              350,
              50,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              50,
              50,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(87.5,
              50,
              87.5,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(125,
              50,
              125,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(162.5,
              50,
              162.5,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(200,
              50,
              200,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(237.5,
              50,
              237.5,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(275,
              50,
              275,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(312.5,
              50,
              312.5,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(350,
              50,
              350,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 68.75, 45)
     v0.add(
         String(-6.665,
                -10,
                'Jan',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 106.25, 45)
     v0.add(
         String(-7.5,
                -10,
                'Feb',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 143.75, 45)
     v0.add(
         String(-8.33,
                -10,
                'Mar',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 181.25, 45)
     v0.add(
         String(-7.775,
                -10,
                'Apr',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 218.75, 45)
     v0.add(
         String(-9.165,
                -10,
                'May',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 256.25, 45)
     v0.add(
         String(-6.945,
                -10,
                'Jun',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 293.75, 45)
     v0.add(
         String(-5.835,
                -10,
                'Jul',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 331.25, 45)
     v0.add(
         String(-8.61,
                -10,
                'Aug',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         Line(50,
              50,
              50,
              175,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              50,
              45,
              50,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              81.25,
              45,
              81.25,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              112.5,
              45,
              112.5,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              143.75,
              45,
              143.75,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              175,
              45,
              175,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 50)
     v0.add(
         String(-5,
                -4,
                '0',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 81.25)
     v0.add(
         String(-10,
                -4,
                '15',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 112.5)
     v0.add(
         String(-10,
                -4,
                '30',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 143.75)
     v0.add(
         String(-10,
                -4,
                '45',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 175)
     v0.add(
         String(-10,
                -4,
                '60',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
Example #22
0
 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(
         Polygon(points=[
             108.3032, 252.9412, 200, 288.2353, 291.6968, 252.9412,
             306.9796, 138.2353, 200, 58.82353, 93.02039, 138.2353,
             108.3032, 252.9412
         ],
                 fillColor=Color(1, .752941, .796078, 1),
                 fillOpacity=None,
                 strokeColor=None,
                 strokeWidth=0,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             85.37899, 266.1765, 200, 252.9412, 261.1312, 235.2941, 276.414,
             155.8824, 200, 94.11765, 131.2274, 160.2941, 85.37899, 266.1765
         ],
                 fillColor=Color(.678431, .847059, .901961, 1),
                 fillOpacity=None,
                 strokeColor=None,
                 strokeWidth=0,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             138.8688, 235.2941, 200, 261.7647, 261.1312, 235.2941,
             329.9038, 125, 200, 164.7059, 108.3032, 147.0588, 138.8688,
             235.2941
         ],
                 fillColor=Color(.596078, .984314, .596078, 1),
                 fillOpacity=None,
                 strokeColor=None,
                 strokeWidth=0,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         PolyLine(points=[
             108.3032, 252.9412, 200, 288.2353, 291.6968, 252.9412,
             306.9796, 138.2353, 200, 58.82353, 93.02039, 138.2353,
             108.3032, 252.9412
         ],
                  strokeColor=Color(1, 0, 0, 1),
                  strokeWidth=1,
                  strokeLineCap=0,
                  strokeLineJoin=0,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None))
     self.add(
         PolyLine(points=[
             85.37899, 266.1765, 200, 252.9412, 261.1312, 235.2941, 276.414,
             155.8824, 200, 94.11765, 131.2274, 160.2941, 85.37899, 266.1765
         ],
                  strokeColor=Color(0, 0, 1, 1),
                  strokeWidth=1,
                  strokeLineCap=0,
                  strokeLineJoin=0,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None))
     self.add(
         PolyLine(points=[
             138.8688, 235.2941, 200, 261.7647, 261.1312, 235.2941,
             329.9038, 125, 200, 164.7059, 108.3032, 147.0588, 138.8688,
             235.2941
         ],
                  strokeColor=Color(0, .501961, 0, 1),
                  strokeWidth=1,
                  strokeLineCap=0,
                  strokeLineJoin=0,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None))
     self.add(
         Line(200,
              200,
              200,
              350,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(200,
              200,
              329.9038,
              275,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(200,
              200,
              329.9038,
              125,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(200,
              200,
              200,
              50,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(200,
              200,
              70.09619,
              125,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(200,
              200,
              70.09619,
              275,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Polygon(points=[
             197, 288.2353, 200, 291.2353, 203, 288.2353, 200, 285.2353
         ],
                 fillColor=Color(1, .752941, .796078, 1),
                 fillOpacity=None,
                 strokeColor=Color(1, 0, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             288.6968, 252.9412, 291.6968, 255.9412, 294.6968, 252.9412,
             291.6968, 249.9412
         ],
                 fillColor=Color(1, .752941, .796078, 1),
                 fillOpacity=None,
                 strokeColor=Color(1, 0, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             303.9796, 138.2353, 306.9796, 141.2353, 309.9796, 138.2353,
             306.9796, 135.2353
         ],
                 fillColor=Color(1, .752941, .796078, 1),
                 fillOpacity=None,
                 strokeColor=Color(1, 0, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             197, 58.82353, 200, 61.82353, 203, 58.82353, 200, 55.82353
         ],
                 fillColor=Color(1, .752941, .796078, 1),
                 fillOpacity=None,
                 strokeColor=Color(1, 0, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             90.02039, 138.2353, 93.02039, 141.2353, 96.02039, 138.2353,
             93.02039, 135.2353
         ],
                 fillColor=Color(1, .752941, .796078, 1),
                 fillOpacity=None,
                 strokeColor=Color(1, 0, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             105.3032, 252.9412, 108.3032, 255.9412, 111.3032, 252.9412,
             108.3032, 249.9412
         ],
                 fillColor=Color(1, .752941, .796078, 1),
                 fillOpacity=None,
                 strokeColor=Color(1, 0, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Circle(200,
                252.9412,
                2.5,
                fillColor=Color(1, 1, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.5,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(261.1312,
                235.2941,
                2.5,
                fillColor=Color(1, 1, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.5,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(276.414,
                155.8824,
                2.5,
                fillColor=Color(1, 1, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.5,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(200,
                94.11765,
                2.5,
                fillColor=Color(1, 1, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.5,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(131.2274,
                160.2941,
                2.5,
                fillColor=Color(1, 1, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.5,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(85.37899,
                266.1765,
                2.5,
                fillColor=Color(1, 1, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.5,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Polygon(points=[
             197, 261.7647, 200, 264.7647, 203, 261.7647, 200, 258.7647
         ],
                 fillColor=Color(.596078, .984314, .596078, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, .501961, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             258.1312, 235.2941, 261.1312, 238.2941, 264.1312, 235.2941,
             261.1312, 232.2941
         ],
                 fillColor=Color(.596078, .984314, .596078, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, .501961, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             326.9038, 125, 329.9038, 128, 332.9038, 125, 329.9038, 122
         ],
                 fillColor=Color(.596078, .984314, .596078, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, .501961, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             197, 164.7059, 200, 167.7059, 203, 164.7059, 200, 161.7059
         ],
                 fillColor=Color(.596078, .984314, .596078, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, .501961, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             105.3032, 147.0588, 108.3032, 150.0588, 111.3032, 147.0588,
             108.3032, 144.0588
         ],
                 fillColor=Color(.596078, .984314, .596078, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, .501961, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Polygon(points=[
             135.8688, 235.2941, 138.8688, 238.2941, 141.8688, 235.2941,
             138.8688, 232.2941
         ],
                 fillColor=Color(.596078, .984314, .596078, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, .501961, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 200, 357.5)
     v0.add(
         String(-3.61,
                -4,
                'U',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 336.399, 278.75)
     v0.add(
         String(-3.61,
                -4,
                'V',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 336.399, 121.25)
     v0.add(
         String(-4.72,
                -4,
                'W',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 200, 42.5)
     v0.add(
         String(-3.61,
                -4,
                'X',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 63.601, 121.25)
     v0.add(
         String(-3.61,
                -4,
                'Y',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 63.601, 278.75)
     v0.add(
         String(-3.055,
                -4,
                'Z',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 200, 283.2353)
     v0.add(
         String(-8.605,
                -4,
                'zero',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 287.3667, 250.4412)
     v0.add(
         String(-7.22,
                -4,
                'one',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 200, 63.82353)
     v0.add(
         String(-13.885,
                -4,
                'special',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 200, 247.9412)
     v0.add(
         String(-10.83,
                -4,
                'Earth',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 325.5737, 127.5)
     v0.add(
         String(-10.275,
                -4,
                'Mars',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
Example #23
0
#  绘制折线  其实就是使用对象PolyLine 这个类来绘制折线
from reportlab.graphics.shapes import Drawing, PolyLine

from reportlab.graphics import renderPDF

d = Drawing(400, 400)
# 通过点生成需要绘制的线。  里面的都是点  坐标的方向是  竖直y  向上越大   水平x  向右越大
lines = PolyLine([(100, 100), (200, 0), (200, 200)])
d.add(lines)

renderPDF.drawToFile(d, "line4.pdf", " line  file")
Example #24
0
    def draw(self):
        # normalize slice data
        g = self.makeBackground() or Group()

        xradius = self.width/2.0
        yradius = self.height/2.0
        self._radius = radius = min(xradius, yradius)
        cx = self.x + xradius
        cy = self.y + yradius

        data = self.normalizeData()

        self._seriesCount = len(data)
        n = len(data[0])

        #labels
        if self.labels is None:
            labels = [''] * n
        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.
            i = n-len(labels)
            if i>0:
                labels = labels + ['']*i

        S = []
        STRANDS = []
        STRANDAREAS = []
        syms = []
        labs = []
        csa = []
        angle = self.startAngle*pi/180
        direction = self.direction == "clockwise" and -1 or 1
        angleBetween = direction*(2 * pi)/float(n)
        spokes = self.spokes
        spokeLabels = self.spokeLabels
        for i in xrange(n):
            car = cos(angle)*radius
            sar = sin(angle)*radius
            csa.append((car,sar,angle))
            si = self.spokes[i]
            if si.visible:
                spoke = Line(cx, cy, cx + car, cy + sar, strokeWidth = si.strokeWidth, strokeColor=si.strokeColor, strokeDashArray=si.strokeDashArray)
            S.append(spoke)
            sli = spokeLabels[i]
            text = sli._text
            if not text: text = labels[i]
            if text:
                S.append(_setupLabel(WedgeLabel, text, si.labelRadius, cx, cy, angle, car, sar, sli))
            angle += angleBetween

        # now plot the polygons
        rowIdx = 0
        strands = self.strands
        strandLabels = self.strandLabels
        for row in data:
            # series plot
            rsty = strands[rowIdx]
            points = []
            car, sar = csa[-1][:2]
            r = row[-1]
            points.append(cx+car*r)
            points.append(cy+sar*r)
            for i in xrange(n):
                car, sar, angle = csa[i]
                r = row[i]
                points.append(cx+car*r)
                points.append(cy+sar*r)
                L = self._innerDrawLabel(strandLabels[(rowIdx,i)], r, cx, cy, angle, car, sar, labelClass=StrandLabel)
                if L: labs.append(L)
                sty = strands[(rowIdx,i)]
                uSymbol = sty.symbol

                # put in a marker, if it needs one
                if uSymbol:
                    s_x =  cx+car*r
                    s_y = cy+sar*r
                    s_fillColor = sty.fillColor
                    s_strokeColor = sty.strokeColor
                    s_strokeWidth = sty.strokeWidth
                    s_angle = 0
                    s_size = sty.symbolSize
                    if type(uSymbol) is type(''):
                        symbol = makeMarker(uSymbol,
                                    size = s_size,
                                    x =  s_x,
                                    y = s_y,
                                    fillColor = s_fillColor,
                                    strokeColor = s_strokeColor,
                                    strokeWidth = s_strokeWidth,
                                    angle = s_angle,
                                    )
                    else:
                        symbol = uSymbol2Symbol(uSymbol,s_x,s_y,s_fillColor)
                        for k,v in (('size', s_size), ('fillColor', s_fillColor),
                                    ('x', s_x), ('y', s_y),
                                    ('strokeColor',s_strokeColor), ('strokeWidth',s_strokeWidth),
                                    ('angle',s_angle),):
                            if getattr(symbol,k,None) is None:
                                try:
                                    setattr(symbol,k,v)
                                except:
                                    pass
                    syms.append(symbol)

            # make up the 'strand'
            if rsty.fillColor:
                strand = Polygon(points)
                strand.fillColor = rsty.fillColor
                strand.strokeColor = None
                strand.strokeWidth = 0
                STRANDAREAS.append(strand)
            if rsty.strokeColor and rsty.strokeWidth:
                strand = PolyLine(points)
                strand.strokeColor = rsty.strokeColor
                strand.strokeWidth = rsty.strokeWidth
                strand.strokeDashArray = rsty.strokeDashArray
                STRANDS.append(strand)
            rowIdx += 1

        map(g.add,STRANDAREAS+STRANDS+syms+S+labs)
        return g
#ファイル名Chapter21/polyline.py
from reportlab.graphics.shapes import Drawing, String, PolyLine
from reportlab.graphics import renderPDF

# d = Drawing(300, 300)
# p = PolyLine([(0, 0), (100, 100), (100, 0), (0, 100)])
# d.add(p)
# renderPDF.drawToFile(d, 'polyline.pdf', 'polyline pdf file')

d = Drawing(200, 200)
p = PolyLine([(50, 50), (150, 150), (150, 50), (50, 150)])
d.add(p)
renderPDF.drawToFile(d, 'polyline.pdf', 'polyline pdf file')
Example #26
0
def path(points, color):
    return PolyLine(points, strokeColor=color, strokeWidth=0.5)
Example #27
0
    def makeLines(self):
        g = Group()

        labelFmt = self.lineLabelFormat
        P = list(range(len(self._positions)))
        if self.reversePlotOrder: P.reverse()
        inFill = self.inFill
        if inFill:
            inFillY = self.categoryAxis._y
            inFillX0 = self.valueAxis._x
            inFillX1 = inFillX0 + self.categoryAxis._length
            inFillG = getattr(self,'_inFillG',g)

        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            styleCount = len(self.lines)
            styleIdx = rowNo % styleCount
            rowStyle = self.lines[styleIdx]
            rowColor = rowStyle.strokeColor
            dash = getattr(rowStyle, 'strokeDashArray', None)

            if hasattr(self.lines[styleIdx], 'strokeWidth'):
                strokeWidth = self.lines[styleIdx].strokeWidth
            elif hasattr(self.lines, 'strokeWidth'):
                strokeWidth = self.lines.strokeWidth
            else:
                strokeWidth = None

            # Iterate over data columns.
            if self.joinedLines:
                points = []
                for colNo in range(len(row)):
                    points += row[colNo]
                if inFill:
                    points = points + [inFillX1,inFillY,inFillX0,inFillY]
                    inFillG.add(Polygon(points,fillColor=rowColor,strokeColor=rowColor,strokeWidth=0.1))
                else:
                    line = PolyLine(points,strokeColor=rowColor,strokeLineCap=0,strokeLineJoin=1)
                    if strokeWidth:
                        line.strokeWidth = strokeWidth
                    if dash:
                        line.strokeDashArray = dash
                    g.add(line)

            if hasattr(self.lines[styleIdx], 'symbol'):
                uSymbol = self.lines[styleIdx].symbol
            elif hasattr(self.lines, 'symbol'):
                uSymbol = self.lines.symbol
            else:
                uSymbol = None

            if uSymbol:
                for colNo in range(len(row)):
                    x1, y1 = row[colNo]
                    symbol = uSymbol2Symbol(uSymbol,x1,y1,rowStyle.strokeColor)
                    if symbol: g.add(symbol)

            # Draw item labels.
            for colNo in range(len(row)):
                x1, y1 = row[colNo]
                self.drawLabel(g, rowNo, colNo, x1, y1)

        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(
         PolyLine(points=[42.5, 40, 87.5, 55, 132.5, 70, 177.5, 85],
                  strokeColor=None,
                  strokeWidth=1,
                  strokeLineCap=0,
                  strokeLineJoin=1,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None))
     self.add(
         Line(42.5,
              25,
              42.5,
              34,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(37.5,
              25,
              47.5,
              25,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(42.5,
              49,
              42.5,
              55,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(37.5,
              55,
              47.5,
              55,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(32.5,
              34,
              20,
              15,
              rx=0,
              ry=0,
              fillColor=Color(1, .752941, .796078, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(32.5,
              40,
              52.5,
              40,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(87.5,
              40,
              87.5,
              49,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(82.5,
              40,
              92.5,
              40,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(87.5,
              64,
              87.5,
              70,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(82.5,
              70,
              92.5,
              70,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(77.5,
              49,
              20,
              15,
              rx=0,
              ry=0,
              fillColor=Color(1, .752941, .796078, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(77.5,
              55,
              97.5,
              55,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(132.5,
              55,
              132.5,
              64,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(127.5,
              55,
              137.5,
              55,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(132.5,
              79,
              132.5,
              85,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(127.5,
              85,
              137.5,
              85,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(122.5,
              64,
              20,
              15,
              rx=0,
              ry=0,
              fillColor=Color(1, .752941, .796078, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(122.5,
              70,
              142.5,
              70,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(177.5,
              70,
              177.5,
              79,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(172.5,
              70,
              182.5,
              70,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(177.5,
              94,
              177.5,
              100,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(172.5,
              100,
              182.5,
              100,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(167.5,
              79,
              20,
              15,
              rx=0,
              ry=0,
              fillColor=Color(1, .752941, .796078, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(167.5,
              85,
              187.5,
              85,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(20,
              20,
              200,
              20,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(20,
              20,
              20,
              15,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(65,
              20,
              65,
              15,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(110,
              20,
              110,
              15,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(155,
              20,
              155,
              15,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(200,
              20,
              200,
              15,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(20,
              20,
              20,
              105,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(20,
              25,
              15,
              25,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(20,
              40,
              15,
              40,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(20,
              55,
              15,
              55,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(20,
              70,
              15,
              70,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(20,
              85,
              15,
              85,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(20,
              100,
              15,
              100,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 15, 25)
     v0.add(
         String(-10,
                -4,
                '90',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 15, 40)
     v0.add(
         String(-15,
                -4,
                '100',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 15, 55)
     v0.add(
         String(-15,
                -4,
                '110',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 15, 70)
     v0.add(
         String(-15,
                -4,
                '120',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 15, 85)
     v0.add(
         String(-15,
                -4,
                '130',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 15, 100)
     v0.add(
         String(-15,
                -4,
                '140',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
Example #29
0
    def makeLines(self):
        g = Group()

        labelFmt = self.lineLabelFormat
        P = list(range(len(self._positions)))
        if self.reversePlotOrder: P.reverse()
        inFill = self.inFill
        if inFill:
            inFillY = self.categoryAxis._y
            inFillX0 = self.valueAxis._x
            inFillX1 = inFillX0 + self.categoryAxis._length
            inFillG = getattr(self,'_inFillG',g)
        yzero = self._yzero

        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            styleCount = len(self.lines)
            styleIdx = rowNo % styleCount
            rowStyle = self.lines[styleIdx]
            rowColor = rowStyle.strokeColor
            dash = getattr(rowStyle, 'strokeDashArray', None)
            lineStyle = getattr(rowStyle,'lineStyle',None)

            if hasattr(rowStyle, 'strokeWidth'):
                strokeWidth = rowStyle.strokeWidth
            elif hasattr(self.lines, 'strokeWidth'):
                strokeWidth = self.lines.strokeWidth
            else:
                strokeWidth = None

            # Iterate over data columns.
            if lineStyle=='bar':
                barWidth = getattr(rowStyle,'barWidth',Percentage(50))
                fillColor = getattr(rowStyle,'fillColor',rowColor)
                if isinstance(barWidth,Percentage):
                    hbw = self._hngs*barWidth*0.01
                else:
                    hbw = barWidth*0.5
                for colNo in range(len(row)):
                    x,y = row[colNo]
                    g.add(Rect(x-hbw,min(y,yzero),2*hbw,abs(y-yzero),strokeWidth=strokeWidth,strokeColor=rowColor,fillColor=fillColor))
            elif self.joinedLines or lineStyle=='joinedLine':
                points = []
                for colNo in range(len(row)):
                    points += row[colNo]
                if inFill:
                    points = points + [inFillX1,inFillY,inFillX0,inFillY]
                    inFillG.add(Polygon(points,fillColor=rowColor,strokeColor=rowColor,strokeWidth=0.1))
                else:
                    line = PolyLine(points,strokeColor=rowColor,strokeLineCap=0,strokeLineJoin=1)
                    if strokeWidth:
                        line.strokeWidth = strokeWidth
                    if dash:
                        line.strokeDashArray = dash
                    g.add(line)

            if hasattr(rowStyle, 'symbol'):
                uSymbol = rowStyle.symbol
            elif hasattr(self.lines, 'symbol'):
                uSymbol = self.lines.symbol
            else:
                uSymbol = None

            if uSymbol:
                for colNo in range(len(row)):
                    x1, y1 = row[colNo]
                    symbol = uSymbol2Symbol(uSymbol,x1,y1,rowStyle.strokeColor)
                    if symbol: g.add(symbol)

            # Draw item labels.
            for colNo in range(len(row)):
                x1, y1 = row[colNo]
                self.drawLabel(g, rowNo, colNo, x1, y1)

        return g
Example #30
0
from reportlab.lib import colors
from reportlab.graphics.shapes import Drawing, String, PolyLine
from reportlab.graphics import renderPDF

data = [
    #    Year  Month  Predicted  High  Low
    (2007, 8, 113.2, 114.2, 112.2),
    (2007, 9, 112.8, 115.8, 109.8),
    (2007, 10, 111.0, 116.0, 106.0),
    (2007, 11, 109.8, 116.8, 102.8),
    (2007, 12, 107.3, 115.3, 99.3),
    (2008, 1, 105.2, 114.2, 96.2),
    (2008, 2, 104.1, 114.1, 94.1),
    (2008, 3, 99.9, 110.9, 88.9),
    (2008, 4, 94.8, 106.8, 82.8),
    (2008, 5, 91.2, 104.2, 78.2),
    (2008, 6, 39.2, 104.2, 78.2)
]

drawing = Drawing(200, 150)
pred = [row[2] - 40 for row in data]
high = [row[3] - 40 for row in data]
low = [row[4] - 40 for row in data]
times = [((row[0] + row[1] / 12.0) - 2007) * 200 - 110 for row in data]

drawing.add(PolyLine(zip(times, pred), strokeColor=colors.blue))
drawing.add(PolyLine(zip(times, high), strokeColor=colors.red))
drawing.add(PolyLine(zip(times, low), strokeColor=colors.green))
drawing.add(String(65, 115, 'hello', fontSize=18, fillColor=colors.red))

renderPDF.drawToFile(drawing, 'hello.pdf', 'A Simple PDF file')
Example #31
0
    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
Example #32
0
    def makeLines(self):
        g = Group()

        labelFmt = self.lineLabelFormat
        P = range(len(self._positions))
        if self.reversePlotOrder: P.reverse()
        inFill = self.inFill
        if inFill:
            inFillY = self.categoryAxis._y
            inFillX0 = self.valueAxis._x
            inFillX1 = inFillX0 + self.categoryAxis._length
            inFillG = getattr(self, '_inFillG', g)

        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            styleCount = len(self.lines)
            styleIdx = rowNo % styleCount
            rowStyle = self.lines[styleIdx]
            rowColor = rowStyle.strokeColor
            dash = getattr(rowStyle, 'strokeDashArray', None)

            if hasattr(self.lines[styleIdx], 'strokeWidth'):
                strokeWidth = self.lines[styleIdx].strokeWidth
            elif hasattr(self.lines, 'strokeWidth'):
                strokeWidth = self.lines.strokeWidth
            else:
                strokeWidth = None

            # Iterate over data columns.
            if self.joinedLines:
                points = []
                for colNo in range(len(row)):
                    points += row[colNo]
                if inFill:
                    points = points + [inFillX1, inFillY, inFillX0, inFillY]
                    inFillG.add(
                        Polygon(points,
                                fillColor=rowColor,
                                strokeColor=rowColor,
                                strokeWidth=0.1))
                else:
                    line = PolyLine(points,
                                    strokeColor=rowColor,
                                    strokeLineCap=0,
                                    strokeLineJoin=1)
                    if strokeWidth:
                        line.strokeWidth = strokeWidth
                    if dash:
                        line.strokeDashArray = dash
                    g.add(line)

            if hasattr(self.lines[styleIdx], 'symbol'):
                uSymbol = self.lines[styleIdx].symbol
            elif hasattr(self.lines, 'symbol'):
                uSymbol = self.lines.symbol
            else:
                uSymbol = None

            if uSymbol:
                for colNo in range(len(row)):
                    x1, y1 = row[colNo]
                    symbol = uSymbol2Symbol(uSymbol, x1, y1,
                                            rowStyle.strokeColor)
                    if symbol: g.add(symbol)

            # Draw item labels.
            for colNo in range(len(row)):
                x1, y1 = row[colNo]
                self.drawLabel(g, rowNo, colNo, x1, y1)

        return g
    def makeLines(self):
        g = Group()
        yA = self.yValueAxis
        xA = self.xValueAxis
        bubblePlot = getattr(self,'_bubblePlot',None)
        if bubblePlot:
            bubbleR = min(yA._bubbleRadius,xA._bubbleRadius)
            bubbleMax = xA._bubbleMax

        labelFmt = self.lineLabelFormat

        P = list(range(len(self._positions)))
        if self.reversePlotOrder: P.reverse()
        inFill = getattr(self,'_inFill',None)
        lines = self.lines
        styleCount = len(lines)
        if inFill or [rowNo for rowNo in P if getattr(lines[rowNo%styleCount],'inFill',False)]:
            inFillY = getattr(inFill,'yValue',None)
            if inFillY is None:
                inFillY = xA._y
            else:
                inFillY = yA.scale(inFillY)
            inFillX0 = yA._x
            inFillX1 = inFillX0 + xA._length
            inFillG = getattr(self,'_inFillG',g)
        lG = getattr(self,'_lineG',g)
        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            styleRowNo = rowNo % styleCount
            rowStyle = lines[styleRowNo]
            rowColor = getattr(rowStyle,'strokeColor',None)
            dash = getattr(rowStyle, 'strokeDashArray', None)

            if hasattr(rowStyle, 'strokeWidth'):
                width = rowStyle.strokeWidth
            elif hasattr(lines, 'strokeWidth'):
                width = lines.strokeWidth
            else:
                width = None

            # Iterate over data columns.
            if self.joinedLines:
                points = []
                for xy in row:
                    points += [xy[0], xy[1]]
                if inFill or getattr(rowStyle,'inFill',False):
                    fpoints = [inFillX0,inFillY] + points + [inFillX1,inFillY]
                    filler = getattr(rowStyle, 'filler', None)
                    if filler:
                        filler.fill(self,inFillG,rowNo,rowColor,fpoints)
                    else:
                        inFillG.add(Polygon(fpoints,fillColor=rowColor,strokeColor=rowColor,strokeWidth=width or 0.1))
                if inFill in (None,0,2):
                    line = PolyLine(points,strokeColor=rowColor,strokeLineCap=0,strokeLineJoin=1)
                    if width:
                        line.strokeWidth = width
                    if dash:
                        line.strokeDashArray = dash
                    lG.add(line)

            if hasattr(rowStyle, 'symbol'):
                uSymbol = rowStyle.symbol
            elif hasattr(lines, 'symbol'):
                uSymbol = lines.symbol
            else:
                uSymbol = None

            if uSymbol:
                if bubblePlot: drow = self.data[rowNo]
                for j,xy in enumerate(row):
                    if (styleRowNo,j) in lines._children:
                        juSymbol = getattr(lines[styleRowNo,j],'symbol',uSymbol)
                    else:
                        juSymbol = uSymbol
                    if juSymbol is uSymbol:
                        symbol = uSymbol
                        symColor = rowColor
                    else:
                        symbol = juSymbol
                        symColor = getattr(symbol,'fillColor',rowColor)
                    symbol = uSymbol2Symbol(symbol,xy[0],xy[1],symColor)
                    if symbol:
                        if bubblePlot:
                            symbol.size = bubbleR*(drow[j][2]/bubbleMax)**0.5
                        g.add(symbol)
            else:
                if bubblePlot: drow = self.data[rowNo]
                for j,xy in enumerate(row):
                    juSymbol = getattr(lines[styleRowNo,j],'symbol',None)
                    if not juSymbol: continue
                    symColor = getattr(juSymbol,'fillColor',getattr(juSymbol,'strokeColor',rowColor))
                    symbol = uSymbol2Symbol(juSymbol,xy[0],xy[1],symColor)
                    if symbol:
                        if bubblePlot:
                            symbol.size = bubbleR*(drow[j][2]/bubbleMax)**0.5
                        g.add(symbol)

            # Draw data labels.
            for colNo in range(len(row)):
                x1, y1 = row[colNo]
                self.drawLabel(g, rowNo, colNo, x1, y1)

            shader = getattr(rowStyle, 'shader', None)
            if shader: shader.shade(self,g,rowNo,rowColor,row)

        return g
Example #34
0
 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(
         Line(90,
              100,
              110,
              100,
              strokeColor=Color(0, .501961, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(100,
              90,
              100,
              110,
              strokeColor=Color(0, .501961, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Circle(100,
                100,
                10,
                fillColor=Color(1, 0, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.526316,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Ellipse(96.66667,
                 103.3333,
                 .666667,
                 2,
                 fillColor=Color(0, 0, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.526316,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Ellipse(103.3333,
                 103.3333,
                 .666667,
                 2,
                 fillColor=Color(0, 0, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.526316,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         PolyLine(points=[
             93.73538, 97.71987, 93.77613, 97.61088, 93.81877, 97.50262,
             93.8633, 97.39513, 93.9097, 97.28842, 93.95795, 97.18254,
             94.00804, 97.07753, 94.05996, 96.9734, 94.11368, 96.87019,
             94.1692, 96.76794, 94.2265, 96.66667, 94.28555, 96.56641,
             94.34635, 96.4672, 94.40886, 96.36907, 94.47308, 96.27205,
             94.53899, 96.17616, 94.60655, 96.08143, 94.67576, 95.9879,
             94.74659, 95.89559, 94.81903, 95.80453, 94.89304, 95.71475,
             94.9686, 95.62627, 95.0457, 95.53913, 95.12431, 95.45334,
             95.2044, 95.36894, 95.28595, 95.28595, 95.36894, 95.2044,
             95.45334, 95.12431, 95.53913, 95.0457, 95.62627, 94.9686,
             95.71475, 94.89304, 95.80453, 94.81903, 95.89559, 94.74659,
             95.9879, 94.67576, 96.08143, 94.60655, 96.17616, 94.53899,
             96.27205, 94.47308, 96.36907, 94.40886, 96.4672, 94.34635,
             96.56641, 94.28555, 96.66667, 94.2265, 96.76794, 94.1692,
             96.87019, 94.11368, 96.9734, 94.05996, 97.07753, 94.00804,
             97.18254, 93.95795, 97.28842, 93.9097, 97.39513, 93.8633,
             97.50262, 93.81877, 97.61088, 93.77613, 97.71987, 93.73538,
             97.82955, 93.69654, 97.93989, 93.65962, 98.05086, 93.62463,
             98.16242, 93.59159, 98.27454, 93.56049, 98.38719, 93.53136,
             98.50033, 93.5042, 98.61392, 93.47902, 98.72794, 93.45582,
             98.84235, 93.43461, 98.9571, 93.41541, 99.07218, 93.39821,
             99.18754, 93.38303, 99.30314, 93.36985, 99.41896, 93.3587,
             99.53496, 93.34957, 99.65109, 93.34247, 99.76734, 93.33739,
             99.88365, 93.33435, 100, 93.33333, 100.1163, 93.33435,
             100.2327, 93.33739, 100.3489, 93.34247, 100.465, 93.34957,
             100.581, 93.3587, 100.6969, 93.36985, 100.8125, 93.38303,
             100.9278, 93.39821, 101.0429, 93.41541, 101.1577, 93.43461,
             101.2721, 93.45582, 101.3861, 93.47902, 101.4997, 93.5042,
             101.6128, 93.53136, 101.7255, 93.56049, 101.8376, 93.59159,
             101.9491, 93.62463, 102.0601, 93.65962, 102.1705, 93.69654,
             102.2801, 93.73538, 102.3891, 93.77613, 102.4974, 93.81877,
             102.6049, 93.8633, 102.7116, 93.9097, 102.8175, 93.95795,
             102.9225, 94.00804, 103.0266, 94.05996, 103.1298, 94.11368,
             103.2321, 94.1692, 103.3333, 94.2265, 103.4336, 94.28555,
             103.5328, 94.34635, 103.6309, 94.40886, 103.728, 94.47308,
             103.8238, 94.53899, 103.9186, 94.60655, 104.0121, 94.67576,
             104.1044, 94.74659, 104.1955, 94.81903, 104.2853, 94.89304,
             104.3737, 94.9686, 104.4609, 95.0457, 104.5467, 95.12431,
             104.6311, 95.2044, 104.714, 95.28595, 104.7956, 95.36894,
             104.8757, 95.45334, 104.9543, 95.53913, 105.0314, 95.62627,
             105.107, 95.71475, 105.181, 95.80453, 105.2534, 95.89559,
             105.3242, 95.9879, 105.3934, 96.08143, 105.461, 96.17616,
             105.5269, 96.27205, 105.5911, 96.36907, 105.6537, 96.4672,
             105.7144, 96.56641, 105.7735, 96.66667, 105.8308, 96.76794,
             105.8863, 96.87019, 105.94, 96.9734, 105.992, 97.07753,
             106.0421, 97.18254, 106.0903, 97.28842, 106.1367, 97.39513,
             106.1812, 97.50262, 106.2239, 97.61088, 106.2646, 97.71987
         ],
                  strokeColor=Color(0, 0, 0, 1),
                  strokeWidth=.526316,
                  strokeLineCap=0,
                  strokeLineJoin=0,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None,
                  fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (2, 0, 0, 2, 100, -100)
     v0.add(
         Line(90,
              100,
              110,
              100,
              strokeColor=Color(0, .501961, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     v0.add(
         Line(100,
              90,
              100,
              110,
              strokeColor=Color(0, .501961, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     v0.add(
         Circle(100,
                100,
                10,
                fillColor=Color(0, 0, 1, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=.526316,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     v0.add(
         Ellipse(96.66667,
                 103.3333,
                 .666667,
                 2,
                 fillColor=Color(0, 0, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.526316,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     v0.add(
         Ellipse(103.3333,
                 103.3333,
                 .666667,
                 2,
                 fillColor=Color(0, 0, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=.526316,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     v0.add(
         PolyLine(points=[
             93.73538, 97.71987, 93.77613, 97.61088, 93.81877, 97.50262,
             93.8633, 97.39513, 93.9097, 97.28842, 93.95795, 97.18254,
             94.00804, 97.07753, 94.05996, 96.9734, 94.11368, 96.87019,
             94.1692, 96.76794, 94.2265, 96.66667, 94.28555, 96.56641,
             94.34635, 96.4672, 94.40886, 96.36907, 94.47308, 96.27205,
             94.53899, 96.17616, 94.60655, 96.08143, 94.67576, 95.9879,
             94.74659, 95.89559, 94.81903, 95.80453, 94.89304, 95.71475,
             94.9686, 95.62627, 95.0457, 95.53913, 95.12431, 95.45334,
             95.2044, 95.36894, 95.28595, 95.28595, 95.36894, 95.2044,
             95.45334, 95.12431, 95.53913, 95.0457, 95.62627, 94.9686,
             95.71475, 94.89304, 95.80453, 94.81903, 95.89559, 94.74659,
             95.9879, 94.67576, 96.08143, 94.60655, 96.17616, 94.53899,
             96.27205, 94.47308, 96.36907, 94.40886, 96.4672, 94.34635,
             96.56641, 94.28555, 96.66667, 94.2265, 96.76794, 94.1692,
             96.87019, 94.11368, 96.9734, 94.05996, 97.07753, 94.00804,
             97.18254, 93.95795, 97.28842, 93.9097, 97.39513, 93.8633,
             97.50262, 93.81877, 97.61088, 93.77613, 97.71987, 93.73538,
             97.82955, 93.69654, 97.93989, 93.65962, 98.05086, 93.62463,
             98.16242, 93.59159, 98.27454, 93.56049, 98.38719, 93.53136,
             98.50033, 93.5042, 98.61392, 93.47902, 98.72794, 93.45582,
             98.84235, 93.43461, 98.9571, 93.41541, 99.07218, 93.39821,
             99.18754, 93.38303, 99.30314, 93.36985, 99.41896, 93.3587,
             99.53496, 93.34957, 99.65109, 93.34247, 99.76734, 93.33739,
             99.88365, 93.33435, 100, 93.33333, 100.1163, 93.33435,
             100.2327, 93.33739, 100.3489, 93.34247, 100.465, 93.34957,
             100.581, 93.3587, 100.6969, 93.36985, 100.8125, 93.38303,
             100.9278, 93.39821, 101.0429, 93.41541, 101.1577, 93.43461,
             101.2721, 93.45582, 101.3861, 93.47902, 101.4997, 93.5042,
             101.6128, 93.53136, 101.7255, 93.56049, 101.8376, 93.59159,
             101.9491, 93.62463, 102.0601, 93.65962, 102.1705, 93.69654,
             102.2801, 93.73538, 102.3891, 93.77613, 102.4974, 93.81877,
             102.6049, 93.8633, 102.7116, 93.9097, 102.8175, 93.95795,
             102.9225, 94.00804, 103.0266, 94.05996, 103.1298, 94.11368,
             103.2321, 94.1692, 103.3333, 94.2265, 103.4336, 94.28555,
             103.5328, 94.34635, 103.6309, 94.40886, 103.728, 94.47308,
             103.8238, 94.53899, 103.9186, 94.60655, 104.0121, 94.67576,
             104.1044, 94.74659, 104.1955, 94.81903, 104.2853, 94.89304,
             104.3737, 94.9686, 104.4609, 95.0457, 104.5467, 95.12431,
             104.6311, 95.2044, 104.714, 95.28595, 104.7956, 95.36894,
             104.8757, 95.45334, 104.9543, 95.53913, 105.0314, 95.62627,
             105.107, 95.71475, 105.181, 95.80453, 105.2534, 95.89559,
             105.3242, 95.9879, 105.3934, 96.08143, 105.461, 96.17616,
             105.5269, 96.27205, 105.5911, 96.36907, 105.6537, 96.4672,
             105.7144, 96.56641, 105.7735, 96.66667, 105.8308, 96.76794,
             105.8863, 96.87019, 105.94, 96.9734, 105.992, 97.07753,
             106.0421, 97.18254, 106.0903, 97.28842, 106.1367, 97.39513,
             106.1812, 97.50262, 106.2239, 97.61088, 106.2646, 97.71987
         ],
                  strokeColor=Color(0, 0, 0, 1),
                  strokeWidth=.526316,
                  strokeLineCap=0,
                  strokeLineJoin=0,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None,
                  fillColor=Color(0, 0, 0, 1)))