def line_plot(final_dis_angle): drawing = Drawing() data = [final_dis_angle] lp = LinePlot() lp.x = 0 lp.y = -120 lp.height = 300 lp.width = 450 lp.data = data lp.joinedLines = 0 lp.lines[0].symbol = makeMarker('FilledCircle') lp.lines[1].symbol = makeMarker('Circle') lp.lineLabelFormat = '%2.0f' lp.strokeColor = colors.black # lp.xValueAxis.valueMin = 0 # lp.xValueAxis.valueMax = 5 # lp.xValueAxis.valueSteps = [1, 2, 2.5, 3, 4, 5] lp.xValueAxis.labelTextFormat = '%2.1f' # lp.yValueAxis.valueMin = 0 # lp.yValueAxis.valueMax = 7 # lp.yValueAxis.valueSteps = [1, 2, 3, 5, 6] drawing.add(lp) return drawing
def line_plot(O, xy_max, data, label_font_size): if (reportlab is None): return from reportlab.graphics.charts.lineplots import LinePlot from reportlab.graphics.widgets.markers import makeMarker from reportlab.lib import colors lp = LinePlot() lp.x = 40 lp.y = 40 lp.height = 120 lp.width = 120 lp.data = [[(0, 0), (xy_max, xy_max)], data] lp.lines[0].strokeColor = colors.Color(*[0.8] * 3) lp.lines[0].strokeWidth = 0.5 lp.lines[1].strokeColor = colors.white lp.lines[1].strokeWidth = 0 lp.lines[1].symbol = makeMarker("Circle") lp.lines[1].symbol.strokeWidth = 0.5 lp.joinedLines = 1 lp.strokeColor = colors.Color(*[0.8] * 3) lp.strokeWidth = 1 lp.xValueAxis.valueMin = 0 lp.xValueAxis.valueMax = xy_max lp.xValueAxis.valueSteps = range(xy_max + 1) lp.xValueAxis.strokeWidth = 1 lp.xValueAxis.tickDown = 3 lp.xValueAxis.labels.fontSize = label_font_size lp.yValueAxis.valueMin = 0 lp.yValueAxis.valueMax = xy_max lp.yValueAxis.valueSteps = range(xy_max + 1) lp.yValueAxis.strokeWidth = 1 lp.yValueAxis.tickLeft = 3 lp.yValueAxis.labels.fontSize = label_font_size return lp
def line_plot(O, xy_max, data, label_font_size): if (reportlab is None): return from reportlab.graphics.charts.lineplots import LinePlot from reportlab.graphics.widgets.markers import makeMarker from reportlab.lib import colors lp = LinePlot() lp.x = 40 lp.y = 40 lp.height = 120 lp.width = 120 lp.data = [[(0,0),(xy_max,xy_max)], data] lp.lines[0].strokeColor = colors.Color(*[0.8]*3) lp.lines[0].strokeWidth = 0.5 lp.lines[1].strokeColor = colors.white lp.lines[1].strokeWidth = 0 lp.lines[1].symbol = makeMarker("Circle") lp.lines[1].symbol.strokeWidth = 0.5 lp.joinedLines = 1 lp.strokeColor = colors.Color(*[0.8]*3) lp.strokeWidth = 1 lp.xValueAxis.valueMin = 0 lp.xValueAxis.valueMax = xy_max lp.xValueAxis.valueSteps = range(xy_max+1) lp.xValueAxis.strokeWidth = 1 lp.xValueAxis.tickDown = 3 lp.xValueAxis.labels.fontSize = label_font_size lp.yValueAxis.valueMin = 0 lp.yValueAxis.valueMax = xy_max lp.yValueAxis.valueSteps = range(xy_max+1) lp.yValueAxis.strokeWidth = 1 lp.yValueAxis.tickLeft = 3 lp.yValueAxis.labels.fontSize = label_font_size return lp
def drawrelationshipcs(can, resultsbuffer): can.setFont("Helvetica", 24) sec_title = "System Heat Balance" can.drawString(25, 750, sec_title) desc_text = "The following figure shows the relationship between the chilled water" \ " system operating efficiency and the cooling load. As the figure shows, with " \ "the Cooling load ranges between 800 RT to 1100 RT, the efficiency hovers between " \ "0.75/RT to 0.91KW/RT." stylesheet = getSampleStyleSheet() paragraph = Paragraph(desc_text, stylesheet['Normal']) aW, aH = 500, 600 w, h = paragraph.wrap(aW, aH) if w <= aW and h <= aH: paragraph.drawOn(can, 25, 700) drawing = Drawing(600, 400) data = [((801, 0.7), (903, 0.8), (799, 0.84), (1002, 0.97), (1101, 0.89)), ((987, 0.98), (1007, 1.1), (1102, 0.98), (987, 0.95), (908, 0.89))] lp = LinePlot() lp.x = 50 lp.y = 50 lp.height = 250 lp.width = 400 lp.data = data lp.joinedLines = 0 lp.lines.symbol = makeMarker('FilledCircle') # lp.lines.symbol = makeMarker('Circle') # lp.lines[1].symbol = makeMarker('Circle') lp.lineLabelFormat = '%2.0f' lp.strokeColor = colors.black lp.xValueAxis.valueMin = 0 lp.xValueAxis.valueMax = 1200 lp.xValueAxis.valueSteps = [ 0.00, 200.00, 400.00, 600.00, 800.00, 1000.00, 1200.00 ] lp.xValueAxis.labelTextFormat = '%2.1f' lp.yValueAxis.valueMin = 0 lp.yValueAxis.valueMax = 1.2 lp.yValueAxis.valueSteps = [ 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2 ] drawing.add(lp) drawing.drawOn(can, 50, 350) can.showPage()
def line_plot(data, elements): drawing = Drawing(0, 400) # for indices lp = LinePlot() lp.x = 0 lp.y = 50 lp.height = 300 lp.width = 600 lp.data = data lp.joinedLines = 1 lp.lines[0].symbol = makeMarker('FilledCircle') lp.lines[1].symbol = makeMarker('Circle') lp.lineLabelFormat = '%2.0f' lp.strokeColor = colors.black lp.xValueAxis.valueMin = 0 lp.xValueAxis.valueMax = 5 lp.xValueAxis.valueSteps = [1, 2, 2.5, 3, 4, 5] lp.xValueAxis.labelTextFormat = '%2.1f' lp.yValueAxis.valueMin = 0 lp.yValueAxis.valueMax = 7 lp.yValueAxis.valueSteps = [1, 2, 3, 5, 6] drawing.add(lp) elements.append(drawing)
def createTimeSeries(self,ser): if self.single_record: return # Time series are available for these quantities. The number indicates their position in the data string series = {'h':0, 'g':1, 'i10':2, 'i100':6, 'tori':3, 'Read10':7} # The time series plot will get added to the 'drawing' object drawing = Drawing(400, 200) # and it is of type 'LinePlot' lp = LinePlot() lp.x = 30 lp.y = 50 lp.height = 125 lp.width = 350 # Record the publication years, because these values will be used as x axis labels years = sorted(map(lambda b: int(b), filter(lambda a: a.isdigit(), self.data['metrics series'].keys()))) lp.data = [] series_data = [] # The maximum value will be used to scale the y axis max_value = 0 # This list will hold the data points for the histogram for year in years: values = map(lambda a: float(a),self.data['metrics series'][str(year)].split(':')) max_value = max(max_value,values[series[ser]]) if ser == 'read10' and year > 1995: series_data.append((year,values[series[ser]])) else: series_data.append((year,values[series[ser]])) lp.data.append(series_data) lp.joinedLines = 1 # Define the line color lp.lines[0].strokeColor = colors.orange # Actual data point will be marked by a filled circle lp.lines.symbol = makeMarker('FilledCircle') lp.strokeColor = colors.black # The extreme values for the x axis lp.xValueAxis.valueMin = years[0] lp.xValueAxis.valueMax = years[-1] # Proper label placement for years: shift by (-6, -6) in x and y to have labels positioned properly lp.xValueAxis.labels.dx = -6 lp.xValueAxis.labels.dy = -18 # and rotate the labels by 90 degrees lp.xValueAxis.labels.angle = 90 lp.xValueAxis.valueSteps = years # For both axes values will be displayed as integers lp.xValueAxis.labelTextFormat = '%2.0f' lp.yValueAxis.labelTextFormat = '%2.0f' # Define the maximum value of the y axis lp.yValueAxis.valueMax = int(math.ceil(float(max_value)/10.0))*10 # Depending on the range of values, set a value step for the y axis if max_value > 10000: lp.yValueAxis.valueStep = 1000 elif max_value > 1000: lp.yValueAxis.valueStep = 100 else: lp.yValueAxis.valueStep = 10 # The y axis always starts at 0 lp.yValueAxis.valueMin = 0 # Now add the line plot to the 'drawing' object drawing.add(lp) # Finally add the appropriate title to the plot drawing.add(String(200,190,"%s index time series" % ser, textAnchor="middle", fillColor='blue')) # Append the result to the 'story' self.story.append(drawing)
from reportlab.graphics.charts.piecharts import Pie from reportlab.graphics.charts.lineplots import LinePlot from reportlab.graphics.widgets.markers import makeMarker from reportlab.lib import colors drawing = Drawing(400, 200) data = [((1, 1), (2, 2), (2.5, 1), (3, 3), (4, 5)), ((1, 2), (2, 3), (2.5, 2), (3.5, 5), (4, 6))] lp = LinePlot() lp.x = 50 lp.y = 50 lp.height = 125 lp.width = 300 lp.data = data lp.joinedLines = 1 lp.lines[0].symbol = makeMarker('FilledCircle') lp.lines[1].symbol = makeMarker('Circle') lp.lineLabelFormat = '%2.0f' lp.strokeColor = colors.black lp.xValueAxis.valueMin = 0 lp.xValueAxis.valueMax = 5 lp.xValueAxis.valueSteps = [1, 2, 2.5, 3, 4, 5] lp.xValueAxis.labelTextFormat = '%2.1f' lp.yValueAxis.valueMin = 0 lp.yValueAxis.valueMax = 7 lp.yValueAxis.valueSteps = [1, 2, 3, 5, 6] drawing.add(lp) drawing.save(formats=['pdf'], outDir='./pdfs', fnRoot='chart') # c = canvas.Canvas('./pdfs/chart_canvas.pdf') # c.da
data = [ ((1,1), (2,2), (2.5,1), (3,3), (4,5)), ((1,2), (2,3), (2.5,2), (3.5,5), (4,6)) ] lp = LinePlot() lp.x = 50 lp.y = 50 lp.height = 125 lp.width = 300 lp.data = data lp.joinedLines = 1 lp.lines[0].symbol = makeMarker('FilledCircle') lp.lines[1].symbol = makeMarker('Circle') lp.lineLabelFormat = '%2.0f' lp.strokeColor = colors.black lp.xValueAxis.valueMin = 0 lp.xValueAxis.valueMax = 5 lp.xValueAxis.valueSteps = [1, 2, 2.5, 3, 4, 5] lp.xValueAxis.labelTextFormat = '%2.1f' lp.yValueAxis.valueMin = 0 lp.yValueAxis.valueMax = 7 lp.yValueAxis.valueSteps = [1, 2, 3, 5, 6] drawing.add(lp) draw(drawing, 'LinePlot sample') disc("")
def generate_certificate(elements): style = TableStyle([('TEXTALIGN', (0, 0), (-1, -1), 'CENTER'), ('TEXTCOLOR', (0, 0), (-1, -1), colors.red), ('VALIGN', (0, 0), (0, -1), 'TOP'), ('INNERGRID', (0, 0), (-1, -1), 0.50, colors.red), ('BOX', (0, 0), (-1, -1), 0.50, colors.green), ('BACKGROUND', (0, 0), (-1, -1), colors.blue), ]) s = getSampleStyleSheet() s = s["BodyText"] s.wordWrap = "RGB" styles = ParagraphStyle( name='Normal', fontName='Helvetica-Bold', fontSize=15, alignment=1, ) elements.append(Spacer(1, 0.5 * inch)) i = Paragraph(str("candidate performance vs average performance"), styles) elements.append(i) elements.append(Spacer(1, 0.1 * inch)) drawing = Drawing(0, 200) # for indices data = [ (13, 5, 20, 22, 37, 45, 19, 4), (14, 6, 21, 23, 38, 46, 20, 5) ] # data for drawing bar graphs bc = VerticalBarChart() bc.x = 0 # x,y define the left bottom of graph bc.y = 0 bc.height = 150 bc.width = 300 bc.data = data bc.strokeColor = colors.black bc.valueAxis.valueMin = 0 bc.valueAxis.valueMax = 50 bc.valueAxis.valueStep = 10 bc.categoryAxis.labels.boxAnchor = 'ne' bc.categoryAxis.labels.dx = 6 # next 3 lines is for naming indices bc.categoryAxis.labels.dy = -2 bc.categoryAxis.labels.angle = 60 bc.categoryAxis.categoryNames = ['Jan-99', 'Feb-99', 'Mar-99', 'Apr-99', 'May-99', 'Jun-99', 'Jul-99', 'Aug-99'] drawing.add(bc) elements.append(drawing) elements.append(Spacer(1, 0.5 * inch)) drawing = Drawing(0, 175) # for indices lc = HorizontalLineChart() lc.x = 0 lc.y = 10 lc.height = 150 lc.width = 300 lc.data = data lc.joinedLines = 1 catNames = 'Jan Feb Mar Apr May Jun Jul Aug'.split(' ') lc.categoryAxis.categoryNames = catNames lc.categoryAxis.labels.boxAnchor = 'n' lc.valueAxis.valueMin = 0 lc.valueAxis.valueMax = 60 lc.valueAxis.valueStep = 15 lc.lines[0].strokeWidth = 2 lc.lines[1].strokeWidth = 1.5 drawing.add(lc) elements.append(drawing) drawing = Drawing(0, 400) # for indices data = [ ((1, 1), (2, 2), (2.5, 1), (3, 3), (4, 5)), ((1, 2), (2, 3), (2.5, 2), (3.5, 5), (4, 6)) ] elements.append(Spacer(1, 0.1 * inch)) i = Paragraph(str("candidate performance vs average performance"), styles) elements.append(i) elements.append(Spacer(1, 0.1 * inch)) lp = LinePlot() lp.x = 0 lp.y = 50 lp.height = 300 lp.width = 600 lp.data = data lp.joinedLines = 1 lp.lines[0].symbol = makeMarker('FilledCircle') lp.lines[1].symbol = makeMarker('Circle') lp.lineLabelFormat = '%2.0f' lp.strokeColor = colors.black lp.xValueAxis.valueMin = 0 lp.xValueAxis.valueMax = 5 lp.xValueAxis.valueSteps = [1, 2, 2.5, 3, 4, 5] lp.xValueAxis.labelTextFormat = '%2.1f' lp.yValueAxis.valueMin = 0 lp.yValueAxis.valueMax = 7 lp.yValueAxis.valueSteps = [1, 2, 3, 5, 6] drawing.add(lp) elements.append(drawing) elements.append(Spacer(1, 0.1 * inch)) drawing = Drawing(100, 350) pc = Pie() pc.x = 65 pc.y = 15 pc.width = 300 pc.height = 300 pc.data = [10, 20, 30, 40, 50, 60] pc.labels = ['a', 'b', 'c', 'd', 'e', 'f'] pc.slices.strokeWidth = 0.5 pc.slices[3].popout = 10 pc.slices[3].strokeWidth = 2 pc.slices[3].strokeDashArray = [2, 2] pc.slices[3].labelRadius = 1.75 pc.slices[3].fontColor = colors.red drawing.add(pc) elements.append(drawing) elements.append(Spacer(1, 0.5 * inch)) return elements
def generatedReport(self, df, dirReport): #Valores de cajas de texto nom_empre = self.line_nom_empre.text() codigo_text = self.line_cod.text() #Image #pdfmetrics.registerFont(TTFont('chsFont', 'STHeiti Light.ttc')) stylesheet = getSampleStyleSheet() elements = [] try: base_path = sys._MEIPASS except Exception: base_path = os.path.abspath(".") fecha = str(datetime.today().strftime('%Y-%m-%d')) address = "Reporte_" + fecha + "_.pdf" path = os.path.join(dirReport, address) path2 = os.path.join(base_path, "cap.jpeg") doc = SimpleDocTemplate(path) #Imagen elements.append(Image(path2, width=1 * inch, height=1 * inch)) #Titulo elements.append( Paragraph('<font >REPORTE DE TEMPERATURA</font>', stylesheet['Title'])) #Descripcion elements.append( Paragraph('<font >DATOS GENERALES</font>', stylesheet['BodyText'])) elements.append( Paragraph( '<font >Empresa: ' + nom_empre + '</font> <font > Código: ' + codigo_text + '</font>', stylesheet['BodyText'])) elements.append( Paragraph('<font >Fecha: ' + fecha + '</font>', stylesheet['BodyText'])) elements.append(Paragraph('<font ></font>', stylesheet['BodyText'])) #Descripcion Ejes elements.append( Paragraph('<font >DESCRIPCIÓN GRÁFICO</font>', stylesheet['BodyText'])) elements.append( Paragraph( '<font > Eje Y = Grados Centigrados / Eje X = Tiempo Minutos</font>', stylesheet['BodyText'])) elements.append( Paragraph( '<font color=blue> -- Sensor #1 --</font> <font color=yellow>-- Sensor #2 --</font> <font color=red>-- Sensor #3 --</font> <font color=green>-- Sensor #4 --</font> <font color=brown>-- Promedio --</font>', stylesheet['BodyText'])) elements.append(Spacer(1, 1 * inch)) #Datos para el Gráfico lista_temp1 = [] lista_temp2 = [] lista_temp3 = [] lista_temp4 = [] lista_total = [] promedio_ = [] data_table = [] cabecera = [] cabecera.append('No') cabecera.append('Fecha') cabecera.append('Hora') cabecera.append('Temp 1') cabecera.append('Temp 2') cabecera.append('Temp 3') cabecera.append('Temp 4') cabecera.append('Tiempo / Minutos') cabecera.append('Promedio') data_table.append(cabecera) const = df['Hora'][0] format = '%H:%M:%S' for index, row in df.iterrows(): diff = (datetime.strptime(str(row['Hora']), format) - datetime.strptime(str(const), format)) / 60 total_minu = round(diff.total_seconds(), 1) var_promedio = (row['Temp1'] + row['Temp2'] + row['Temp3'] + row['Temp4']) / 4 round_promedio = round(var_promedio, 2) c_1 = (total_minu, row['Temp1']) c_2 = (total_minu, row['Temp2']) c_3 = (total_minu, row['Temp3']) c_4 = (total_minu, row['Temp4']) c_5 = (total_minu, round_promedio) lista_temp1.append(c_1) lista_temp2.append(c_2) lista_temp3.append(c_3) lista_temp4.append(c_4) promedio_.append(c_5) array_aux = [] array_aux.append(row['n']) array_aux.append(row['Fecha']) array_aux.append(row['Hora']) array_aux.append(row['Temp1']) array_aux.append(row['Temp2']) array_aux.append(row['Temp3']) array_aux.append(row['Temp4']) array_aux.append(total_minu) array_aux.append(round_promedio) data_table.append(array_aux) lista_total.append(lista_temp1) lista_total.append(lista_temp2) lista_total.append(lista_temp3) lista_total.append(lista_temp4) lista_total.append(promedio_) elements.append(Spacer(1, 1 * inch)) elements.append(Spacer(1, 1 * inch)) drawing = Drawing(400, 200) lp = LinePlot() lp.x = 100 lp.y = 100 lp.height = 300 lp.width = 300 lp.data = lista_total lp.joinedLines = 1 #lp.lineLabelFormat = '%2.0f' lp.strokeColor = colors.black lp.xValueAxis.valueMin = 0 lp.xValueAxis.valueMax = 100 lp.xValueAxis.valueStep = 10 #lp.xValueAxis.valueSteps =listHora_aux lp.xValueAxis.labelTextFormat = '%2.1f' lp.yValueAxis.valueMin = 0 lp.yValueAxis.valueMax = 180 lp.yValueAxis.valueStep = 5 lp.lines[0].strokeColor = colors.blue lp.lines[1].strokeColor = colors.yellow lp.lines[2].strokeColor = colors.red lp.lines[3].strokeColor = colors.green lp.lines[4].strokeColor = colors.brown drawing.add(lp) elements.append(drawing) #Tabla elements.append( Paragraph('<font >DESCRIPCIÓN TABLA</font>', stylesheet['BodyText'])) elements.append(Paragraph('<font ></font>', stylesheet['BodyText'])) style_table = TableStyle([ ('BACKGROUND', (0, 0), (8, 0), colors.green), ('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke), ('ALIGN', (0, 0), (8, 1000000), 'CENTER'), ('FONTNAME', (0, 0), (-1, 0), 'Courier-Bold') ]) table = Table(data_table) table.setStyle(style_table) elements.append(table) elements.append(Spacer(1, 1 * inch)) elements.append(Spacer(1, 1 * inch)) #Firma #elements.append(Paragraph('<font >Hola</font>', stylesheet['Title'])) elements.append(Spacer(1, 1 * inch)) doc.build(elements) msg = QMessageBox() msg.setWindowTitle("Alerta") msg.setText("Correcta Generación de Reporte !!!") x = msg.exec_()
def generate_certificate(elements): styles = ParagraphStyle( name='Normal', fontName='Helvetica-Bold', fontSize=15, alignment=1, ) elements.append(Spacer(1, 0.5 * inch)) i = Paragraph(str("candidate performance vs average performance"), styles) elements.append(i) elements.append(Spacer(1, 0.1 * inch)) drawing = Drawing(0, 200) # for indices data = [ (13, 5, 20, 22, 37, 45, 19, 4), (14, 6, 21, 23, 38, 46, 20, 5) ] # data for drawing bar graphs bc = VerticalBarChart() bc.x = 0 # x,y define the left bottom of graph bc.y = 0 bc.height = 150 bc.width = 300 bc.data = data bc.strokeColor = colors.black bc.valueAxis.valueMin = 0 bc.valueAxis.valueMax = 50 bc.valueAxis.valueStep = 10 bc.categoryAxis.labels.boxAnchor = 'ne' bc.categoryAxis.labels.dx = 6 # next 3 lines is for naming indices bc.categoryAxis.labels.dy = -2 bc.categoryAxis.labels.angle = 60 bc.categoryAxis.categoryNames = ['Jan-99', 'Feb-99', 'Mar-99', 'Apr-99', 'May-99', 'Jun-99', 'Jul-99', 'Aug-99'] drawing.add(bc) elements.append(drawing) elements.append(Spacer(1, 0.5 * inch)) drawing = Drawing(0, 175) # for indices lc = HorizontalLineChart() lc.x = 0 lc.y = 10 lc.height = 150 lc.width = 300 lc.data = data lc.joinedLines = 1 catnames = 'Jan Feb Mar Apr May Jun Jul Aug'.split(' ') lc.categoryAxis.categoryNames = catnames lc.categoryAxis.labels.boxAnchor = 'n' lc.valueAxis.valueMin = 0 lc.valueAxis.valueMax = 60 lc.valueAxis.valueStep = 15 lc.lines[0].strokeWidth = 2 lc.lines[1].strokeWidth = 1.5 drawing.add(lc) elements.append(drawing) drawing = Drawing(0, 400) # for indices data = [ ((1, 1), (2, 2), (2.5, 1), (3, 3), (4, 5)), ((1, 2), (2, 3), (2.5, 2), (3.5, 5), (4, 6)) ] elements.append(Spacer(1, 0.1 * inch)) i = Paragraph(str("candidate performance vs average performance"), styles) elements.append(i) elements.append(Spacer(1, 0.1 * inch)) lp = LinePlot() lp.x = 0 lp.y = 50 lp.height = 300 lp.width = 600 lp.data = data lp.joinedLines = 1 lp.lines[0].symbol = makeMarker('FilledCircle') lp.lines[1].symbol = makeMarker('Circle') lp.lineLabelFormat = '%2.0f' lp.strokeColor = colors.black lp.xValueAxis.valueMin = 0 lp.xValueAxis.valueMax = 5 lp.xValueAxis.valueSteps = [1, 2, 2.5, 3, 4, 5] lp.xValueAxis.labelTextFormat = '%2.1f' lp.yValueAxis.valueMin = 0 lp.yValueAxis.valueMax = 7 lp.yValueAxis.valueSteps = [1, 2, 3, 5, 6] drawing.add(lp) elements.append(drawing) elements.append(Spacer(1, 0.1 * inch)) drawing = Drawing(100, 350) pc = Pie() pc.x = 65 pc.y = 15 pc.width = 300 pc.height = 300 pc.data = [10, 20, 30, 40, 50, 60] pc.labels = ['a', 'b', 'c', 'd', 'e', 'f'] pc.slices.strokeWidth = 0.5 pc.slices[3].popout = 10 pc.slices[3].strokeWidth = 2 pc.slices[3].strokeDashArray = [2, 2] pc.slices[3].labelRadius = 1.75 pc.slices[3].fontColor = colors.red drawing.add(pc) elements.append(drawing) elements.append(Spacer(1, 0.7 * inch)) styles = ParagraphStyle( name='Normal', fontName='Helvetica', fontSize=15, alignment=0, ) elements.append(Spacer(1, 0.5* inch)) i = Paragraph(str("Please click on black square to play the video."), styles) elements.append(i) elements.append(platypus.flowables.Macro('canvas.saveState()')) elements.append(platypus.flowables.Macro('canvas.linkURL("fun.mp4",(400,510,410,500),relative=0,thickness=10)')) elements.append(platypus.flowables.Macro('canvas.restoreState()')) return elements