def load_slices(self): series = QPieSeries() for i in EXTENSHIONS.keys(): slice = QPieSlice(i, EXTENSHIONS[i][0]) v = EXTENSHIONS[i][1] slice.setPen(QPen(Qt.black, 2)) slice.hovered[bool].connect(functools.partial(self.explodeSlice, slice_=slice, v=v)) series.append(slice) return series
def show_proportional_chart(self): type_diagram = self.pushButton_3.text() self.group_diagram_window.hide() if type_diagram == "Отобразить диаграмму в пропорциях": group = self.label_4.text() session = self.label_7.text() period = self.label_8.text() control = Control() result: np.ndarray = control.analysis_group_proportional( self.session, group, session, period) r_len = len(result) set0 = QBarSet('0-24') set1 = QBarSet('25-49') set2 = QBarSet('50-74') set3 = QBarSet('75-100') if r_len == 4: set0 << int(result[0][1]) << int(result[1][1]) << int( result[2][1]) << int(result[3][1]) set1 << int(result[0][2]) << int(result[1][2]) << int( result[2][2]) << int(result[3][2]) set2 << int(result[0][3]) << int(result[1][3]) << int( result[2][3]) << int(result[3][3]) set3 << int(result[0][4]) << int(result[1][4]) << int( result[2][4]) << int(result[3][4]) elif r_len == 3: set0 << int(result[0][1]) << int(result[1][1]) << int( result[2][1]) set1 << int(result[0][2]) << int(result[1][2]) << int( result[2][2]) set2 << int(result[0][3]) << int(result[1][3]) << int( result[2][3]) set3 << int(result[0][4]) << int(result[1][4]) << int( result[2][4]) elif r_len == 2: set0 << int(result[0][1]) << int(result[1][1]) set1 << int(result[0][2]) << int(result[1][2]) set2 << int(result[0][3]) << int(result[1][3]) set3 << int(result[0][4]) << int(result[1][4]) else: set0 << int(result[0][1]) set1 << int(result[0][2]) set2 << int(result[0][3]) set3 << int(result[0][4]) cat = [] for i in result: cat.append(i[0]) series = QPercentBarSeries() series.append(set0) series.append(set1) series.append(set2) series.append(set3) chart = QChart() chart.addSeries(series) chart.setAnimationOptions(QChart.SeriesAnimations) axis = QBarCategoryAxis() axis.append(cat) chart.createDefaultAxes() chart.setAxisX(axis, series) chart.legend().setVisible(True) chart.legend().setAlignment(Qt.AlignBottom) centralwidget = self.centralwidget self.chartview = QChartView(chart, centralwidget) self.chartview.setGeometry(QtCore.QRect(10, 110, 880, 371)) else: series = QPieSeries() for i in self.data: value = str(i[0]) + " / " + str(i[1]) series.append(value, int(i[1])) # adding slice slice = QPieSlice() slice = series.slices()[0] slice.setExploded(True) slice.setLabelVisible(True) slice.setPen(QPen(Qt.darkGreen, 2)) slice.setBrush(Qt.green) chart = QChart() chart.legend().hide() chart.addSeries(series) chart.createDefaultAxes() chart.setAnimationOptions(QChart.SeriesAnimations) chart.legend().setVisible(True) chart.legend().setAlignment(Qt.AlignBottom) centralwidget = self.centralwidget self.chartview = QChartView(chart, centralwidget) self.chartview.setGeometry(QtCore.QRect(10, 110, 880, 371)) self.pushButton_3.hide() self.group_diagram_window.show()
def dunya(self): if self.bilgiEkran == "dunya": series = QPieSeries() series.append("Hasta", float(self.hasta)) series.append("Olu", float(self.olum)) series.append("Kurtulan", float(self.kurtulan)) #kurtulan slice = QPieSlice() slice = series.slices()[2] slice.setExploded(True) slice.setLabelVisible(True) slice.setPen(QPen(Qt.darkGreen, 2)) slice.setBrush(Qt.green) #olü slice = QPieSlice() sliceozel = series.slices()[1] sliceozel.setExploded(False) sliceozel.setLabelVisible(True) sliceozel.setPen(QPen(Qt.black, 2)) sliceozel.setBrush(Qt.black) #hasta slice = QPieSlice() slice = series.slices()[0] slice.setExploded(False) slice.setLabelVisible(True) slice.setPen(QPen(Qt.darkGray, 2)) slice.setBrush(Qt.gray) chart = QChart() chart.legend().hide() chart.addSeries(series) chart.createDefaultAxes() chart.setAnimationOptions(QChart.AllAnimations) chart.setTitle("Dünya Geneli COVID-19") chart.setTitleFont(QFont("Berlin Sans FB Demi", 22)) chart.legend().setVisible(True) chart.legend().setAlignment(Qt.AlignTop) chart.legend().setFont(QFont("Berlin Sans FB Demi", 16)) chartview = QChartView(chart) chartview.setRenderHint(QPainter.Antialiasing) return chartview elif self.bilgiEkran == "en": series = QPieSeries() series.append("Hasta", float(self.hastaEn)) series.append("Olu", float(self.olumEn)) series.append("Kurtulan", float(self.kurtulanEn)) #kurtulan slice = QPieSlice() slice = series.slices()[2] slice.setExploded(True) slice.setLabelVisible(True) slice.setPen(QPen(Qt.darkGreen, 2)) slice.setBrush(Qt.green) #olü slice = QPieSlice() sliceozel = series.slices()[1] sliceozel.setExploded(False) sliceozel.setLabelVisible(True) sliceozel.setPen(QPen(Qt.black, 2)) sliceozel.setBrush(Qt.black) #hasta slice = QPieSlice() slice = series.slices()[0] slice.setExploded(False) slice.setLabelVisible(True) slice.setPen(QPen(Qt.darkGray, 2)) slice.setBrush(Qt.gray) chart = QChart() chart.legend().hide() chart.addSeries(series) chart.createDefaultAxes() chart.setAnimationOptions(QChart.AllAnimations) chart.setTitle("İngiltere Geneli COVID-19") chart.setTitleFont(QFont("Berlin Sans FB Demi", 22)) chart.legend().setVisible(True) chart.legend().setAlignment(Qt.AlignTop) chart.legend().setFont(QFont("Berlin Sans FB Demi", 16)) chartview = QChartView(chart) chartview.setRenderHint(QPainter.Antialiasing) return chartview else: series = QPieSeries() series.append("Hasta", float(self.hastaTr)) series.append("Olu", float(self.olumTr)) series.append("Kurtulan", float(self.kurtulanTr)) #kurtulan slice = QPieSlice() slice = series.slices()[2] slice.setExploded(True) slice.setLabelVisible(True) slice.setPen(QPen(Qt.darkGreen, 2)) slice.setBrush(Qt.green) #olü slice = QPieSlice() sliceozel = series.slices()[1] sliceozel.setExploded(False) sliceozel.setLabelVisible(True) sliceozel.setPen(QPen(Qt.black, 2)) sliceozel.setBrush(Qt.black) #hasta slice = QPieSlice() slice = series.slices()[0] slice.setExploded(False) slice.setLabelVisible(True) slice.setPen(QPen(Qt.darkGray, 2)) slice.setBrush(Qt.gray) chart = QChart() chart.legend().hide() chart.addSeries(series) chart.createDefaultAxes() chart.setAnimationOptions(QChart.AllAnimations) chart.setTitle("Türkiye Geneli COVID-19") chart.setTitleFont(QFont("Berlin Sans FB Demi", 22)) chart.legend().setVisible(True) chart.legend().setAlignment(Qt.AlignTop) chart.legend().setFont(QFont("Berlin Sans FB Demi", 16)) chartview = QChartView(chart) chartview.setRenderHint(QPainter.Antialiasing) return chartview
def create_piechart(self): Date = date.today() breakfastData = SQLStatements.getTotalBreakfastCalories( self.userID, Date) breakfastData = str(breakfastData) breakfastData = (breakfastData.replace("[", "")) breakfastData = (breakfastData.replace("]", "")) breakfastData = (breakfastData.replace("(", "")) breakfastData = (breakfastData.replace(")", "")) breakfastData = (breakfastData.replace(",", "")) breakfastData = int(breakfastData) lunchData = SQLStatements.getTotalLunchCalories(self.userID, Date) lunchData = str(lunchData) lunchData = (lunchData.replace("[", "")) lunchData = (lunchData.replace("]", "")) lunchData = (lunchData.replace("(", "")) lunchData = (lunchData.replace(")", "")) lunchData = (lunchData.replace(",", "")) lunchData = int(lunchData) dinnerData = SQLStatements.getTotalDinnerCalories(self.userID, Date) dinnerData = str(dinnerData) dinnerData = (dinnerData.replace("[", "")) dinnerData = (dinnerData.replace("]", "")) dinnerData = (dinnerData.replace("(", "")) dinnerData = (dinnerData.replace(")", "")) dinnerData = (dinnerData.replace(",", "")) dinnerData = int(dinnerData) snackData = SQLStatements.getTotalSnacksCalories(self.userID, Date) snackData = str(snackData) snackData = (snackData.replace("[", "")) snackData = (snackData.replace("]", "")) snackData = (snackData.replace("(", "")) snackData = (snackData.replace(")", "")) snackData = (snackData.replace(",", "")) snackData = int(snackData) series = QPieSeries() series.append("Breakfast calories", breakfastData) series.append("Lunch calories", lunchData) series.append("Dinner calories", dinnerData) series.append("Snack calories", snackData) labelFont = QFont("Sans Serif", ) labelFont.setPixelSize(16) slice = QPieSlice() slice.setLabelFont(labelFont) slice = series.slices()[0] slice.setExploded(True) slice.setLabelVisible(True) slice.setPen(QPen(Qt.green, 2)) slice.setBrush(Qt.green) slice = QPieSlice() slice.setLabelFont(labelFont) slice = series.slices()[1] slice.setExploded(True) slice.setLabelVisible(True) slice.setPen(QPen(Qt.white, 2)) slice.setBrush(Qt.white) slice = QPieSlice() slice.setLabelFont(labelFont) slice = series.slices()[2] slice.setExploded(True) slice.setLabelVisible(True) slice.setPen(QPen(Qt.yellow, 2)) slice.setBrush(Qt.yellow) slice = QPieSlice() slice.setLabelFont(labelFont) slice = series.slices()[3] slice.setExploded(True) slice.setLabelVisible(True) slice.setPen(QPen(Qt.yellow, 2)) slice.setBrush(Qt.yellow) chart = QChart() chart.legend().hide() chart.addSeries(series) chart.createDefaultAxes() chart.setAnimationOptions(QChart.SeriesAnimations) chart.setTitle("Daily Calories") chart.setTheme(QChart.ChartThemeBlueCerulean) chart.setBackgroundVisible(False) # Title Font size font = QFont("Sans Serif", ) font.setPixelSize(18) chart.setTitleFont(font) chart.legend().setVisible(True) chart.legend().setAlignment(Qt.AlignBottom) chartview = QChartView(chart) chartview.setRenderHint(QPainter.Antialiasing) return chartview
def create_chart(self): self.chart.setTitle( 'Grafiek aantal externe werken per status - opnameweek ' + jrwk) font = QFont("Sans Serif", 10) font.setWeight(QFont.Bold) self.chart.setTitleFont(font) series = QPieSeries() slice_ = QPieSlice() series.setUseOpenGL(enable=True) series.append('Status A = ' + str(rpr[0][2]), rpr[0][2]) series.append('Status B = ' + str(rpr[1][2]), rpr[1][2]) series.append('Status C = ' + str(rpr[2][2]), rpr[2][2]) series.append('Status D = ' + str(rpr[3][2]), rpr[3][2]) series.append('Status E = ' + str(rpr[4][2]), rpr[4][2]) series.append('Status F = ' + str(rpr[5][2]), rpr[5][2]) series.append('Status G = ' + str(rpr[6][2]), rpr[6][2]) series.append('Status H = ' + str(rpr[7][2]), rpr[7][2]) for i, slice_ in enumerate(series.slices()): slice_.setLabelVisible() #slice_.setLabelPosition(3) if i == 0: slice_.setPen(QPen(Qt.black, 2)) slice_.setBrush(Qt.green) elif i == 1: slice_.setPen(QPen(Qt.black, 2)) slice_.setBrush(Qt.red) elif i == 2: slice_.setExploded() slice_.setPen(QPen(Qt.black, 2)) slice_.setBrush(Qt.yellow) elif i == 3: slice_.setPen(QPen(Qt.black, 2)) slice_.setBrush(Qt.magenta) elif i == 4: slice_.setPen(QPen(Qt.black, 2)) slice_.setBrush(Qt.cyan) elif i == 5: slice_.setPen(QPen(Qt.black, 2)) slice_.setBrush(Qt.blue) elif i == 6: slice_.setPen(QPen(Qt.black, 2)) slice_.setBrush(Qt.darkYellow) elif i == 7: slice_.setPen(QPen(Qt.black, 2)) slice_.setBrush(Qt.darkRed) self.chart.addSeries(series)