I'm trying to show the label and the percentage in the Qchart but it show me only one of them
Is there a way to show both of them
This is my function that run the QtChart
def charts_jr_acte(self):# pushButton_123
rightseries = QPieSeries()
rightseries.setLabelsVisible(True)
rightseries.setLabelsPosition(QPieSlice.LabelInsideHorizontal)
for C_acte, montant in rows:
rightseries.append(C_acte, montant)
slice = QPieSlice()
slice = rightseries.slices() [2]
slice.setExploded(True)
slice.setPen(QtGui.QPen(Qt.darkBlue))
for slice in rightseries.slices():
slice.setLabel("{:.2f}%".format(100 * slice.percentage()))
rightchart = QChart()
rightchart.createDefaultAxes()
rightchart.addSeries(rightseries)
rightchart.setTitle("total journalier de chaque Acte")
rightchart.setAnimationOptions(QChart.SeriesAnimations)
rightchart.legend().setVisible(True)
rightchart.legend().setAlignment(Qt.AlignBottom)
rightchart.legend().markers(rightseries)[1].setLabel(lab)
rightseries.setLabelsVisible()
rightseries.setLabelsPosition(QtChart.QPieSlice.LabelInsideHorizontal)
self.graphicsView_4.setChart(rightchart)
` and this is an example of the result
i find a way to make it work
def charts_jr_acte(self):# pushButton_123
rightseries = QPieSeries()
rightseries.setLabelsVisible(True)
for C_acte, montant in rows:
rightseries.append(C_acte, montant)
slice = QPieSlice()
slice = rightseries.slices() [2]
slice.setExploded(True)
slice.setPen(QtGui.QPen(Qt.darkBlue))
for slice in rightseries.slices():
slice.setLabelVisible()
oldLabel=slice.label()
slice.setLabel((oldLabel+": %.1f%%" %(slice.percentage()*100) ))
rightchart = QChart()
rightchart.createDefaultAxes()
rightchart.addSeries(rightseries)
rightchart.setTitle("total journalier de chaque Acte")
rightchart.setAnimationOptions(QChart.SeriesAnimations)
rightchart.legend().setVisible(True)
self.graphicsView_4.setChart(rightchart)
this how it look like