Пример #1
0
 def analyseProcess(self):
     absc = []
     ordo = []
     absc.clear()
     ordo.clear()
     for tabrow in range(self.tableWidget.rowCount()):
         abscitem = self.tableWidget.item(tabrow,
                                          self.comboBoxabsc.currentIndex())
         ordoitem = self.tableWidget.item(tabrow,
                                          self.comboBoxordo.currentIndex())
         absc.append(int(abscitem.text()))
         ordo.append(str(ordoitem.text()))
     df = pd.DataFrame({'data': absc})
     df.index = ordo
     df = df.sort_values(by='data', ascending=False)
     df["cumpercentage"] = df["data"].cumsum() / df["data"].sum() * 100
     self.figure.clear()
     plt.ion()
     ax = self.figure.add_subplot()
     ax.bar(df.index, df["data"], color="C0")
     ax2 = ax.twinx()
     ax2.plot(df.index, df["cumpercentage"], color="C1", marker="D", ms=7)
     ax2.yaxis.set_major_formatter(PercentFormatter())
     ax.tick_params(axis="y", colors="C0")
     ax2.tick_params(axis="y", colors="C1")
     self.canvas.draw()
     # donutchart***********************************
     self.m_donuts = []
     self.chartView3.setRenderHint(QPainter.Antialiasing)
     self.chart3 = self.chartView3.chart()
     self.chart3.legend().setVisible(True)
     self.chart3.setTitle("Nested donuts Chart")
     self.chart3.setAnimationOptions(QChart.AllAnimations)
     minSize3 = 0.1
     maxSize3 = 0.9
     donutCount3 = 5
     for i in range(donutCount3):
         donut = QPieSeries()
         sliceCount = random.randrange(3, 6)
         # print(sliceCount)
         for j in range(sliceCount):
             value3 = random.randrange(0, 50)
             slice_ = QPieSlice(str(value3), value3)
             slice_.setLabelVisible(True)
             slice_.setLabelColor(Qt.white)
             slice_.setLabelPosition(QPieSlice.LabelInsideTangential)
             slice_.hovered[bool].connect(
                 functools.partial(self.explodeSlice, slice_=slice_))
             donut.append(slice_)
             donut.setHoleSize(minSize3 + i *
                               (maxSize3 - minSize3) / donutCount3)
             donut.setPieSize(minSize3 + (i + 1) *
                              (maxSize3 - minSize3) / donutCount3)
         self.m_donuts.append(donut)
         self.chartView3.chart().addSeries(donut)
     self.updateTimer = QTimer(self)
     self.updateTimer.timeout.connect(self.updateRotation)
     self.updateTimer.start(1250)
     self.tabWidget.setCurrentIndex(2)
Пример #2
0
        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)
Пример #3
0
    def create(self):
        '''
        Creates Chart Data and returns
        '''
        slices = QPieSlice()
        for x in range(0, len(self.chartseries.slices())):
            slices = self.chartseries.slices()[x]
            slices.setLabelVisible()
            slices.setLabel(str(slices.label()) + " : " + str(slices.value()))

        chart = QChart()
        chart.addSeries(self.chartseries)
        chart.setAnimationOptions(QChart.SeriesAnimations)
        chart.setTitle(self.title)
        # chart.setTheme(5)
        chart.legend().setVisible(False)
        chart.legend().attachToChart()
        return chart
Пример #4
0
    def updateValues(self):
        try:

            counter_books = book_session.query(Book).count()

            genres = book_session.query(Genre).all()
            self.genre_series.clear()
            for genre in genres:
                genre_books = book_session.query(Book).filter_by(
                    genre_id=genre.id).count()
                self.genre_series.append(genre.name,
                                         genre_books / counter_books)

            for i in range(len(self.genre_series)):
                slice = QPieSlice()
                slice = self.genre_series.slices()[i]
                slice.setLabelVisible(True)

            authors = book_session.query(Author).all()
            self.author_series.clear()
            for author in authors:
                author_books = book_session.query(Book).filter_by(
                    author_id=author.id).count()
                self.author_series.append(author.name + " " + author.surname,
                                          author_books / counter_books)

            for i in range(len(self.author_series)):
                slice = QPieSlice()
                slice = self.author_series.slices()[i]
                slice.setLabelVisible(True)

            self.status_series.clear()
            all_status = book_session.query(BookStatus).all()
            counter_status = {}
            for status in all_status:
                book_status = book_session.query(Book).filter_by(
                    status_id=status.id).count()
                self.status_series.append(status.name,
                                          book_status / counter_books)

            for i in range(len(self.status_series)):
                slice = QPieSlice()
                slice = self.status_series.slices()[i]
                slice.setLabelVisible(True)
                if slice.label() == 'Not readed':
                    slice.setColor(QColor(255, 0, 0))
                elif slice.label() == 'In progress':
                    slice.setColor(QColor(0, 0, 255))
                elif slice.label() == 'Readed':
                    slice.setColor(QColor(0, 100, 0))

        except ZeroDivisionError:
            home_window = self.parent().findChild(QWidget, 'home_window')
            self.parent().setCurrentWidget(home_window)
            openDialog(QMessageBox.Critical, 'Insufficient data for chart',
                       'Error')
    def updateValues(self):
        try:
            counter_movies = movie_session.query(Movie).count()

            genres = movie_session.query(Genre).all()
            self.genre_series.clear()
            for genre in genres:
                genre_movies = movie_session.query(Movie).filter_by(genre_id=genre.id).count()
                self.genre_series.append(genre.name, genre_movies/counter_movies)

            for i in range(len(self.genre_series)):
                slice = QPieSlice()
                slice = self.genre_series.slices()[i]
                slice.setLabelVisible(True)

            film_directors = movie_session.query(Film_director).all()
            self.filmDirector_series.clear()
            for film_director in film_directors:
                filmDirector_movie = movie_session.query(Movie).filter_by(film_director_id=film_director.id).count()
                self.filmDirector_series.append(film_director.name + " " + film_director.surname, filmDirector_movie/counter_movies)

            for i in range(len(self.filmDirector_series)):
                slice = QPieSlice()
                slice = self.filmDirector_series.slices()[i]
                slice.setLabelVisible(True)

            self.status_series.clear()
            all_status = movie_session.query(MovieStatus).all()
            counter_status = {}
            for status in all_status:
                movie_status = movie_session.query(Movie).filter_by(status_id = status.id).count()
                self.status_series.append(status.name, movie_status/counter_movies)

            for i in range(len(self.status_series)):
                slice = QPieSlice()
                slice = self.status_series.slices()[i]
                slice.setLabelVisible(True)
                if slice.label() == 'Not watched':
                    slice.setColor(QColor(255, 0, 0))
                elif slice.label() == 'Watched':
                    slice.setColor(QColor(0, 100, 0))
        
        except ZeroDivisionError:
            home_window = self.parent().findChild(QWidget, 'home_window')
            self.parent().setCurrentWidget(home_window)
            openDialog(QMessageBox.Critical, 'Insufficient data for chart', 'Error')

            
Пример #6
0
    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()
Пример #7
0
    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
Пример #8
0
    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
Пример #9
0
    def selectionChange(self):
        pilih_pantai = str(self.comboBox.currentText())
        if pilih_pantai == '-Pilih-':
            self.ALL()
            return
        gf = Grafik(pilih_pantai)
        hasil = gf.hasil_grafik()
        hasil_dayatarik = hasil[0]
        hasil_aksesbilitas = hasil[1]
        hasil_kebersihan = hasil[2]
        hasil_fasilitas = hasil[3]
        total_pantai = hasil[4]
        daya_tarik = (hasil_dayatarik / total_pantai) * 100
        aksesbilitas = (hasil_aksesbilitas / total_pantai) * 100
        kebersihan = (hasil_kebersihan / total_pantai) * 100
        fasilitas = (hasil_fasilitas / total_pantai) * 100
        nilai = {
            'Daya Tarik': daya_tarik,
            'Aksesbilitas': aksesbilitas,
            'Kebersihan': kebersihan,
            'Fasilitas': fasilitas
        }
        maks = max(nilai['Daya Tarik'], nilai['Aksesbilitas'],
                   nilai['Kebersihan'], nilai['Fasilitas'])
        for i in nilai:
            if maks == nilai[i]:
                print(i)
        set0 = QBarSet(pilih_pantai)
        set0 << daya_tarik << aksesbilitas << kebersihan << fasilitas
        series = QBarSeries()
        series.append(set0)
        series.setLabelsVisible(True)
        chart = QChart()
        chart.addSeries(series)
        chart.setTitle('Pantai ' + str(pilih_pantai))

        labelnya = ["Daya Tarik", "Aksesbilitas", "Kebersihan", "Fasilitas"]

        series = QPieSeries()
        series.append("dt", daya_tarik)
        series.append("ak", aksesbilitas)
        series.append("keb", kebersihan)
        series.append("fas", fasilitas)

        slice = QPieSlice()
        slice = series.slices()[0]
        slice.setExploded(False)
        slice.setLabelVisible(True)
        slice.setBrush(QtGui.QColor("blue"))

        slice = QPieSlice()
        slice = series.slices()[1]
        slice.setExploded(False)
        slice.setLabelVisible(True)
        slice.setBrush(QtGui.QColor("red"))

        slice = QPieSlice()
        slice = series.slices()[2]
        slice.setExploded(False)
        slice.setLabelVisible(True)
        slice.setBrush(QtGui.QColor("green"))

        slice = QPieSlice()
        slice = series.slices()[3]
        slice.setExploded(False)
        slice.setLabelVisible(True)
        slice.setBrush(QtGui.QColor("orange"))
        i = 0
        for slice in series.slices():
            slice.setLabel(labelnya[i] +
                           "  {:.1f}%".format(100 * slice.percentage()))
            i = i + 1

        chart = QChart()
        chart.legend().hide()
        chart.addSeries(series)
        chart.createDefaultAxes()
        chart.setAnimationOptions(QChart.SeriesAnimations)
        self.graphicsView.setChart(chart)