def createAreaChart(self):
        chart = QChart()
        chart.setTitle("Area chart")

        # The lower series is initialized to zero values.
        lowerSeries = None
        y_points = []

        for i, data_list in enumerate(self.m_dataTable):
            upperSeries = QLineSeries(chart)
            for j, (value, _) in enumerate(data_list):
                y = value.y()

                if lowerSeries is None:
                    upperSeries.append(QPointF(j, y))
                    y_points.append(y)
                else:
                    new_y = y_points[i] + y
                    upperSeries.append(QPointF(j, new_y))
                    y_points[j] += new_y

            area = QAreaSeries(upperSeries, lowerSeries)
            area.setName("Series " + str(i))
            chart.addSeries(area)
            lowerSeries = upperSeries

        chart.createDefaultAxes()

        return chart
    def createScatterChart(self):
        chart = QChart()
        chart.setTitle("Scatter chart")

        for i, data_list in enumerate(self.m_dataTable):
            series = QScatterSeries(chart)
            for value, _ in data_list:
                series.append(value)

            series.setName("Series " + str(i))
            chart.addSeries(series)

        chart.createDefaultAxes()

        return chart
Esempio n. 3
0
    def createScatterChart(self):
        chart = QChart()
        chart.setTitle("Scatter chart")

        for i, data_list in enumerate(self.m_dataTable):
            series = QScatterSeries(chart)
            for value, _ in data_list:
                series.append(value)

            series.setName("Series " + str(i))
            chart.addSeries(series)

        chart.createDefaultAxes()

        return chart
Esempio n. 4
0
	def make_cake( self ):
		score_1 = self.players[ 0 ].score
		score_2 = self.players[ 1 ].score
		series = QPieSeries()
		free_score = 120 - score_1 - score_2
		series.append( f"{free_score}", free_score )
		series.append( f"{score_1}", score_1 )
		series.append( f"{score_2}", score_2 )
		series.setPieStartAngle( 3 * score_2 )
		series.setPieEndAngle( 3 * score_2 + 360 )

		slices = series.slices()
		for slice in slices:
			slice.setLabelVisible( True )
			if slice.angleSpan() < 45:
				slice.setLabelPosition( QPieSlice.LabelPosition.LabelInsideNormal )
			elif slice.angleSpan() < 90:
				slice.setLabelPosition( QPieSlice.LabelPosition.LabelInsideTangential )
			else:
				slice.setLabelPosition( QPieSlice.LabelPosition.LabelInsideHorizontal )
			slice.setLabelColor( QColor( "#00000" ) )
			slice.setLabelFont( QFont( "Fira Sans", 60, weight=QFont.Weight.Black ) )
			slice.setBorderWidth( 0 )

		slices[ 0 ].setLabelPosition( QPieSlice.LabelPosition.LabelInsideHorizontal )
		if score_1 < 10:
			slices[ 1 ].setLabelFont( QFont( "Fira Sans", score_1 * 6, weight=QFont.Weight.Black ) )
		if score_2 < 10:
			slices[ 2 ].setLabelFont( QFont( "Fira Sans", score_2 * 6, weight=QFont.Weight.Black ) )

		slices[ 0 ].setLabelColor( QColor( "#FFFFFF" ) )
		slices[ 0 ].setColor( remaining_points_color )
		slices[ 1 ].setColor( player_1.color )
		slices[ 2 ].setColor( player_2.color )

		chart = QChart()
		chart.legend().hide()
		chart.addSeries( series )
		chart.createDefaultAxes()
		chart.setBackgroundVisible( False )

		chart.setContentsMargins( -120, -120, -120, -120 )
		chart.layout().setContentsMargins( 0, 0, 0, 0 )

		chart_view = QChartView( chart )
		chart_view.setRenderHint( QPainter.Antialiasing )

		return chart_view
Esempio n. 5
0
    def rewrite_data(self, args):

        self.layout = QVBoxLayout()
        self.grid.addLayout(self.layout, 0, 0, 1, 1)
        for key, value in self.data[args].items():
            chart = QChart()
            chart_view = QChartView(chart)
            series = QLineSeries()
            series.setName(key)

            for i in value:
                series.append(QPointF(i[0], i[1]))

            chart.addSeries(series)
            chart.createDefaultAxes()
            self.layout.addWidget(chart_view)
Esempio n. 6
0
    def run_app(self):

        chart = QChart()
        chart.addSeries(self.series)  # candle

        chart.createDefaultAxes()
        chart.legend().hide()

        chart.axisX(self.series).setCategories(self.tm)

        chart_view = QChartView(chart)

        self.win.setGeometry(50, 50, 800, 500)
        self.win.setCentralWidget(chart_view)
        self.win.show()
        sys.exit(self.app.exec_())
Esempio n. 7
0
    def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)
        self.resize(400, 300)
        # 抗锯齿
        self.setRenderHint(QPainter.Antialiasing)

        # 图表
        chart = QChart()
        self.setChart(chart)
        # 设置标题
        chart.setTitle('Simple splinechart example')
        # 添加Series
        self.getSeries(chart)
        # 创建默认xy轴
        chart.createDefaultAxes()
        chart.legend().setVisible(False)
    def createLineChart(self):
        chart = QChart()
        chart.setTitle("Line chart")

        for i, data_list in enumerate(self.m_dataTable):
            series = QLineSeries(chart)
            for value, _ in data_list:
                series.append(value)

            series.setName("Series " + str(i))
            series.setUseOpenGL(True)
            chart.addSeries(series)

        chart.createDefaultAxes()

        return chart
Esempio n. 9
0
class MainWindow(ChartViewToolTips):
    def __init__(self):
        super().__init__()

        series = QLineSeries()
        series.setPointsVisible(True)
        series.setPointLabelsVisible(True)
        series.setPointLabelsFormat("(@xPoint, @yPoint)")
        series.hovered.connect(self.show_series_tooltip)

        series.append(0, 6)
        series.append(2, 4)
        series.append(3, 8)
        series.append(7, 4)
        series.append(10, 5)

        self._chart = QChart()
        self._chart.setMinimumSize(640, 480)
        self._chart.setTitle("Line Chart Example")
        self._chart.setAnimationOptions(QChart.SeriesAnimations)
        self._chart.legend().hide()
        self._chart.addSeries(series)
        self._chart.createDefaultAxes()

        self.setChart(self._chart)

    def show_series_tooltip(self, point, state: bool):
        if not self._tooltip:
            self._tooltip = Callout(self._chart)

        if state:
            distance = 0.5
            for series in self._chart.series():
                for p in series.pointsVector():
                    current_distance = math.sqrt((p.x() - point.x()) *
                                                 (p.x() - point.x()) +
                                                 (p.y() - point.y()) *
                                                 (p.y() - point.y()))
                    if current_distance < distance:
                        self._tooltip.setText("X: {}\nY: {}".format(
                            p.x(), p.y()))
                        self._tooltip.setAnchor(p)
                        self._tooltip.setZValue(11)
                        self._tooltip.updateGeometry()
                        self._tooltip.show()
        else:
            self._tooltip.hide()
Esempio n. 10
0
class DemoWindow(QMainWindow):
    def __init__(self, parent=None):
        super(DemoWindow, self).__init__(parent=parent)

        self.plotChart = QChart()
        self.plotChart.legend().hide()

        self.plotView = QChartView(self.plotChart)
        self.setCentralWidget(self.plotView)

        self.plotCurve = QLineSeries()
        self.plotCurve.setUseOpenGL(True)
        self.plotCurve.pen().setColor(Qt.red)
        self.plotChart.addSeries(self.plotCurve)

        self.plotChart.createDefaultAxes()
        self.plotChart.axisX().setLabelFormat('%d')

        self.RecvData = array.array('f')  # 存储接收到的传感器数据
        self.RecvIndx = 0

        self.tmrData = QTimer()  # 模拟传感器传送过来数据
        self.tmrData.setInterval(3)
        self.tmrData.timeout.connect(self.on_tmrData_timeout)
        self.tmrData.start()

        self.tmrPlot = QTimer()
        self.tmrPlot.setInterval(100)
        self.tmrPlot.timeout.connect(self.on_tmrPlot_timeout)
        self.tmrPlot.start()

    def on_tmrData_timeout(self):
        val = math.sin(2 * 3.14 / 500 * self.RecvIndx)
        self.RecvData.append(val)

        self.RecvIndx += 1

    def on_tmrPlot_timeout(self):
        self.RecvData = self.RecvData[-1000:]

        plotData = []
        for i, val in enumerate(self.RecvData):
            plotData.append(QPointF(i, val))

        self.plotCurve.replace(plotData)
        self.plotChart.axisX().setMax(len(plotData))
        self.plotChart.axisY().setRange(min(self.RecvData), max(self.RecvData))
Esempio n. 11
0
    def trigger_stage_4(self):
        # self.get_column_data()
        self.content_1.setVisible(False)
        self.content_2.setVisible(False)
        self.content_3.setVisible(False)
        self.content_4.setVisible(True)
        self.progressBar.setValue(99)
        self.stage_1.setChecked(False)
        self.stage_1.setEnabled(False)
        self.stage_2.setChecked(False)
        self.stage_2.setEnabled(False)
        self.stage_3.setChecked(False)
        self.stage_3.setEnabled(False)
        self.stage_4.setChecked(True)
        self.stage_4.setEnabled(True)

        series = QLineSeries(self)
        series.append(0, 6)
        series.append(2, 4)
        series.append(3, 8)
        series.append(7, 4)
        series.append(10, 5)
        series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2)
        chart = QChart()
        #
        chart.addSeries(series)
        chart.createDefaultAxes()
        chart.setAnimationOptions(QChart.SeriesAnimations)
        chart.setTitle(self.chosenColumn[0])
        #
        chart.legend().setVisible(True)


        # chart.legend().setAlignment(Qt.AlignBottom)
        #
        chartview = QChartView(chart)
        chartview.setRenderHint(QPainter.Antialiasing)

        self.content_4.layout = QtWidgets.QVBoxLayout(self)
        self.content_4.layout.addWidget(chartview)

        # layout = QtGui.QVBoxLayout()
        # layout.addWidget(self.content_4)
        # self.setLayout(layout)

        self.setCentralWidget(chartview)
Esempio n. 12
0
    def createBarChart(self, valueCount):
        chart = QChart()
        chart.setTitle("Bar chart")

        series = QStackedBarSeries(chart)

        for i, data_list in enumerate(self.m_dataTable):
            set = QBarSet("Bar set " + str(i))
            for value, _ in data_list:
                set << value.y()

            series.append(set)

        chart.addSeries(series)
        chart.createDefaultAxes()

        return chart
    def createBarChart(self, valueCount):
        chart = QChart()
        chart.setTitle("Bar chart")

        series = QStackedBarSeries(chart)

        for i, data_list in enumerate(self.m_dataTable):
            set = QBarSet("Bar set " + str(i))
            for value, _ in data_list:
                set << value.y()

            series.append(set)

        chart.addSeries(series)
        chart.createDefaultAxes()

        return chart
Esempio n. 14
0
    def _create_revision_count_graph(self):
        stats = CollectionStats(self.col)

        categories_labels = list(range(-30, 1, 1))
        data = stats.revision_count_stats()
        data = self._transform_first_column_to_key(data)
        data = self._add_default_value_for_missing_keys(
            data, [0, 0, 0, 0, 0], categories_labels)

        series = QStackedBarSeries(self)
        setLearning = QBarSet("Learning", self)
        [setLearning.append(row[0]) for row in data]
        setYoung = QBarSet("Young", self)
        [setYoung.append(row[1]) for row in data]
        setMature = QBarSet("Mature", self)
        [setMature.append(row[2]) for row in data]
        setLapse = QBarSet("Lapse", self)
        [setLapse.append(row[3]) for row in data]
        setEarly = QBarSet("Early", self)
        [setEarly.append(row[4]) for row in data]

        categories = QBarCategoryAxis()
        categories.setCategories([str(-i) for i in categories_labels])

        series.append(setLearning)
        series.append(setYoung)
        series.append(setMature)
        series.append(setLapse)
        series.append(setEarly)

        chart = QChart()
        chart.addSeries(series)
        chart.createDefaultAxes()
        chart.setAxisX(categories, series)

        chart.setAnimationOptions(QChart.SeriesAnimations)
        chart.setTitle("Number of cards reviewed recently")

        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignBottom)

        chartview = QChartView(chart)
        chartview.setRenderHint(QPainter.Antialiasing)

        self.layout.addWidget(chartview)
Esempio n. 15
0
    def _create_reviews_due_chart(self):
        ## TODO: later replace by date selector
        start, end, chunk = 0, 31, 1
        stats = CollectionStats(self.col)

        ## TODO: refactor stats._due
        categories_labels = list(range(0, 31, 1))
        data = stats.due(start, end, chunk)
        data = self._transform_first_column_to_key(data)
        data = self._add_default_value_for_missing_keys(
            data, [0, 0, 0, 0], categories_labels)

        series = QStackedBarSeries(self)
        setYoung = QBarSet("Young", self)
        [setYoung.append(row[0]) for row in data]
        setAdolescent = QBarSet("Adolescent", self)
        [setAdolescent.append(row[1]) for row in data]
        setMature = QBarSet("Mature", self)
        [setMature.append(row[2]) for row in data]
        setOld = QBarSet("Old", self)
        [setOld.append(row[3]) for row in data]

        categories = QBarCategoryAxis()
        categories.setCategories([str(i) for i in categories_labels])

        series.append(setOld)
        series.append(setMature)
        series.append(setAdolescent)
        series.append(setYoung)

        chart = QChart()
        chart.addSeries(series)
        chart.createDefaultAxes()
        chart.setAxisX(categories, series)

        chart.setAnimationOptions(QChart.SeriesAnimations)
        chart.setTitle("Forecast: the number of reviews due in the future")

        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignBottom)

        chartview = QChartView(chart)
        chartview.setRenderHint(QPainter.Antialiasing)

        self.layout.addWidget(chartview)
Esempio n. 16
0
class OpenIMUBarGraphView(QChartView):
    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.chart = QChart()
        self.setChart(self.chart)
        self.chart.legend().setVisible(True)
        self.chart.legend().setAlignment(Qt.AlignBottom)
        self.series = QBarSeries(self)
        self.categoryAxis = QBarCategoryAxis(self)
        self.build_style()

    def build_style(self):
        self.setStyleSheet("QLabel{color:blue;}")
        self.chart.setTheme(QChart.ChartThemeBlueCerulean)
        self.setBackgroundBrush(QBrush(Qt.darkGray))
        self.chart.setPlotAreaBackgroundBrush(QBrush(Qt.black))
        self.chart.setPlotAreaBackgroundVisible(True)
        self.chart.setAnimationOptions(QChart.SeriesAnimations)

    def set_title(self, title):
        # print('Setting title: ', title)
        self.chart.setTitle(title)

    def set_category_axis(self, categories):
        self.categoryAxis.append(categories)

    def add_set(self, label, values):
        # print('adding bar set')
        my_set = QBarSet(label, self)
        my_set.append(values)
        self.series.append(my_set)

    def update(self):
        self.chart.addSeries(self.series)
        self.chart.createDefaultAxes()
        self.chart.setAxisX(self.categoryAxis, self.series)

    def add_test_data(self):
        print('adding test data series')
        self.set_title('Testing bars')
        self.set_category_axis(['A', 'B', 'C', 'D'])
        self.add_set('Test1', [0.1, 2, 3, 4])
        self.add_set('Test2', [3, 2, 1, 4])
        self.add_set('Test3', [4, 1, 3, 2])
        self.update()
Esempio n. 17
0
def main():
    import sys
    from PyQt5.QtChart import QChart, QChartView
    from PyQt5.QtCore import Qt
    from PyQt5.QtGui import QPainter
    from PyQt5.QtWidgets import QApplication, QMainWindow

    app = QApplication(sys.argv)

    data = dict()
    data["Jane"] = [1, 2, 3, 4, 5, 6]
    # data["John"] = [5, 0, 0, 4, 0, 7]
    # data["Axel"] = [3, 5, 6, 7, 2, 2]
    # data["Mary"] = [3, 5, 7, 2, 3, 5]
    # data["Tony"] = [3, 0, 9, 3 ,1, 2]

    # series=XDictSet(data, key_order=['Jane', 'John', 'Axel', 'Mary', 'Tony'])
    series = XDictSet(data)
    lineseries = XLineSeries(data);
    print(lineseries)

    chart = QChart()
    chart.addSeries(series)
    chart.addSeries(lineseries[0])
    chart.setTitle("Simple horizontal barchart example")
    chart.setAnimationOptions(QChart.SeriesAnimations)

    categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
    axis = QBarCategoryAxis()
    axis.append(categories)
    chart.createDefaultAxes()
    chart.setAxisX(axis, series)

    chart.legend().setVisible(True)
    chart.legend().setAlignment(Qt.AlignBottom)

    chartView = QChartView(chart)
    chartView.setRenderHint(QPainter.Antialiasing)

    window = QMainWindow()
    window.setCentralWidget(chartView)
    window.resize(800, 600)
    window.show()

    sys.exit(app.exec_())
Esempio n. 18
0
 def create_piechart(self, names, appendList, rg, title):
     self.w = Window2()
     self.w.show()
     series = QPieSeries()
     print(names, appendList)
     for x in range(rg):
         series.append(names[x], appendList[x])
     chart = QChart()
     chart.legend().hide()
     chart.addSeries(series)
     chart.createDefaultAxes()
     chart.setAnimationOptions(QChart.SeriesAnimations)
     chart.setTitle(title)
     chart.legend().setVisible(True)
     chart.legend().setAlignment(Qt.AlignBottom)
     chartview = QChartView(chart)
     chartview.setRenderHint(QPainter.Antialiasing)
     self.w.setCentralWidget(chartview)
Esempio n. 19
0
    def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)
        self.resize(400, 300)
        # 抗锯齿
        self.setRenderHint(QPainter.Antialiasing)

        # 图表
        chart = QChart()
        self.setChart(chart)
        # 设置标题
        chart.setTitle('Simple areachart example')
        # 添加Series
        chart.addSeries(self.getSeries())
        # 创建默认轴线
        chart.createDefaultAxes()
        # 设置xy轴的范围
        chart.axisX().setRange(0, 20)
        chart.axisY().setRange(0, 10)
Esempio n. 20
0
    def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)
        self.resize(400, 300)
        # 抗锯齿
        self.setRenderHint(QPainter.Antialiasing)
        # 生成模拟数据
        self.m_dataTable = self.generateRandomData(3, 10, 7)

        # 图表
        chart = QChart()
        self.setChart(chart)
        # 设置标题
        chart.setTitle('Scatter chart')
        # 添加Series
        self.getSeries(chart)
        # 创建默认xy轴
        chart.createDefaultAxes()
        chart.legend().setVisible(False)
Esempio n. 21
0
    def create_bar(self):
        #The QBarSet class represents a set of bars in the bar chart.
        # It groups several bars into a bar set

        set0 = QBarSet("Parwiz")
        set1 = QBarSet("Bob")
        set2 = QBarSet("Tom")
        set3 = QBarSet("Logan")
        set4 = QBarSet("Karim")

        set0 << 1 << 2 << 3 << 4 << 5 << 6
        set1 << 5 << 0 << 0 << 4 << 0 << 7
        set2 << 3 << 5 << 8 << 13 << 8 << 5
        set3 << 5 << 6 << 7 << 3 << 4 << 5
        set4 << 9 << 7 << 5 << 3 << 1 << 2

        series = QPercentBarSeries()
        series.append(set0)
        series.append(set1)
        series.append(set2)
        series.append(set3)
        series.append(set4)

        chart = QChart()
        chart.addSeries(series)
        chart.setTitle("Percent Example")
        chart.setAnimationOptions(QChart.SeriesAnimations)

        categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
        axis = QBarCategoryAxis()
        axis.append(categories)
        chart.createDefaultAxes()
        chart.setAxisX(axis, series)

        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignBottom)

        chartView = QChartView(chart)
        chartView.setRenderHint(QPainter.Antialiasing)
        #chartView.setRubberBand(QChartView.HorizontalRubberBand) # Включение масштабирования
        #chartView.setRubberBand(QChartView.RectangleRubberBand) # Включение масштабирования

        self.setCentralWidget(chartView)
Esempio n. 22
0
    def create_line(self, param):
        series = QLineSeries()
        for point in self.connect(param):
            series.append(float(point['phase']), point['value'])

        chart = QChart()

        chart.addSeries(series)
        chart.createDefaultAxes()
        chart.setAnimationOptions(QChart.SeriesAnimations)
        chart.setTitle("Parameter " + param)

        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignBottom)

        chartview = QChartView(chart)
        chartview.setRenderHint(QPainter.Antialiasing)

        self.setCentralWidget(chartview)
Esempio n. 23
0
    def grafica_circular(self):
        #Gráfica circular

        #Grátfica
        grafica = QChart()
        grafica.setTitle("Segmento de categorías")

        datos = [("Abarrotes", 13.23), ("Nutrición", 15.2), ("Infántil", 8.42),
                 ("Cremería", 2.3), ("Cámara Fría", 6.4), ("Papelería", 2.344)]

        series = QPieSeries(grafica)

        for etiqueta, valor in datos:
            slice = series.append(etiqueta, valor)

        grafica.addSeries(series)
        grafica.createDefaultAxes()

        return grafica
Esempio n. 24
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.seriesmap = {}  # map items to series
        # create widgets
        self.stat_list = QListWidget(self)
        chart = QChart()
        self.chart_view = QChartView(chart, self)

        for i in range(30):
            series = QLineSeries(self)
            for j in range(20):
                series.append(j, i * 3 + j)

            item = QListWidgetItem()
            item.setData(Qt.DisplayRole, str(i))
            item.setData(Qt.UserRole, i)

            if i < 10:
                item.setData(Qt.CheckStateRole, Qt.Checked)
            else:
                item.setData(Qt.CheckStateRole, Qt.Unchecked)
                series.hide()

            chart.addSeries(series)
            self.stat_list.addItem(item)
            self.seriesmap[i] = series

        # create layout
        layout = QHBoxLayout(self)
        layout.addWidget(self.stat_list)
        layout.addWidget(self.chart_view)
        layout.setStretchFactor(self.chart_view, 3)

        # configure widgets
        chart.legend().hide()
        chart.createDefaultAxes()
        chart.setTitle("Daily aggregated stats of your school")
        self.chart_view.setRenderHint(QPainter.Antialiasing)
        self.retranslateUi()

        # connect signals
        self.stat_list.itemClicked.connect(self.on_stat_clicked)
Esempio n. 25
0
    def createGraphicCircular(self):
        response = request("World")
        graphic = QChart()
        graphic.setTitle("World Corona Status")
        cases = float(response[0].strip().replace(",", ""))
        deaths = float(response[1].strip().replace(",", ""))
        recovered = float(response[2].strip().replace(",", ""))

        data_list = [("Cases:" + response[0], cases),
                     ("Deaths:" + response[1], deaths),
                     ("Recovered:" + response[2], recovered)]

        series = QPieSeries(graphic)
        for tag, valor in data_list:
            series.append(tag, valor)

        graphic.addSeries(series)
        graphic.createDefaultAxes()

        return graphic
Esempio n. 26
0
    def crearGraficoCircular(self):
        """Una serie de sectores consiste en segmentos que se definen como objetos QPieSlice.
           Los segmentos pueden tener cualquier valor, ya que el objeto QPieSeries calcula el
           porcentaje de un segmento en comparación con la suma de todos los segmentos de la
           serie para determinar el tamaño real del segmento en el gráfico."""

        grafico = QChart()
        grafico.setTitle("Lenguajes de programación más usados (TIOBE)")

        lista_datos = [("Java", 17.801), ("C", 15.376), ("C++", 7.593),
                       ("Python", 7.156), ("Visual Basic .NET", 5.884)]

        series = QPieSeries(grafico)
        for etiqueta, valor in lista_datos:
            slice = series.append(etiqueta, valor)

        grafico.addSeries(series)
        grafico.createDefaultAxes()

        return grafico
    def create_QChartView(self) -> QChartView:
        series = QLineSeries()
        series.append(0, 6)
        series.append(2, 4)
        series.append(3, 8)
        series.append(7, 4)
        series.append(10, 5)

        chart = QChart()
        chart.setTitle("Line Chart Example")
        chart.setAnimationOptions(QChart.SeriesAnimations)
        chart.legend().hide()
        chart.addSeries(series)
        chart.createDefaultAxes()

        chart_view = QChartView()
        chart_view.setChart(chart)
        chart_view.setRenderHint(QPainter.Antialiasing)

        return chart_view
Esempio n. 28
0
def main():
    import sys

    app = QApplication(sys.argv)

    series0 = QLineSeries()
    series1 = QLineSeries()

    series0 << QPointF(1, 5) << QPointF(3, 7) << QPointF(7, 6) << QPointF(
        9, 7) << QPointF(12, 6) << QPointF(16, 7) << QPointF(18, 5)
    series1 << QPointF(1, 3) << QPointF(3, 4) << QPointF(7, 3) << QPointF(
        8, 2) << QPointF(12, 3) << QPointF(16, 4) << QPointF(18, 3)

    series = QAreaSeries(series0, series1)
    series.setName("Batman")
    pen = QPen(0x059605)
    pen.setWidth(3)
    series.setPen(pen)

    gradient = QLinearGradient(QPointF(0, 0), QPointF(0, 1))
    gradient.setColorAt(0.0, QColor(0x3CC63C))
    gradient.setColorAt(1.0, QColor(0x26F626))
    gradient.setCoordinateMode(QGradient.ObjectBoundingMode)
    series.setBrush(gradient)

    chart = QChart()
    chart.addSeries(series)
    chart.setTitle("Simple areachart example")
    chart.createDefaultAxes()
    chart.axes(Qt.Horizontal)[0].setRange(0, 20)
    chart.axes(Qt.Vertical)[0].setRange(0, 10)

    chartView = QChartView(chart)
    chartView.setRenderHint(QPainter.Antialiasing)

    window = QMainWindow()
    window.setCentralWidget(chartView)
    window.resize(400, 300)
    window.show()

    sys.exit(app.exec_())
Esempio n. 29
0
    def setupUi(self, Form):
        Form.resize(800, 600)
        Form.setWindowTitle("Analytics")
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("assets/FaceAttend2.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        Form.setWindowIcon(icon)
        self.Calculate()
        low = QBarSet("Short")
        high = QBarSet("Clear")
        soshort = QBarSet("So Short")

        low << self.Low[0] << self.Low[1] << self.Low[2] << self.Low[3] << self.Low[4] << self.Low[5] << self.Low[6]
        soshort << self.SoShort[0] << self.SoShort[1] << self.SoShort[2] << self.SoShort[3] << self.SoShort[4] << self.SoShort[5] << self.SoShort[6]
        # high <<40 << -50 << -45.3 << -37.0 << -25.6 << -8.0 << -6.0
        high << self.High[0] << self.High[1] << self.High[2] << self.High[3] << self.High[4] << self.High[5] << self.High[6]

        series = QStackedBarSeries()
        series.append(low)
        series.append(high)
        series.append(soshort)

        chart = QChart()
        chart.addSeries(series)
        chart.setTitle("Attendance Graph")
        chart.setAnimationOptions(QChart.SeriesAnimations)

        categories = [self.Subjects[0],self.Subjects[1],self.Subjects[2],self.Subjects[3],self.Subjects[4],self.Subjects[5],self.Subjects[6]]

        axis = QBarCategoryAxis()
        axis.append(categories)
        axis.setTitleText("Month")
        chart.createDefaultAxes()
        chart.setAxisX(axis, series)
        chart.axisY(series).setRange(0, 100)
        chart.axisY(series).setTitleText("Percentage (%)")

        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignBottom)

        chartView = QChartView(chart)
        Form.setCentralWidget(chartView)
    def __init__(self):
        super().__init__()

        series = QLineSeries()
        series.append(0, 6)
        series.append(2, 4)
        series.append(3, 8)
        series.append(7, 4)
        series.append(10, 5)

        chart = QChart()
        chart.setTitle("Line Chart Example")
        chart.setAnimationOptions(QChart.SeriesAnimations)
        chart.legend().hide()
        chart.addSeries(series)
        chart.createDefaultAxes()

        chart_view = QChartView()
        chart_view.setChart(chart)
        chart_view.setRenderHint(QPainter.Antialiasing)

        self.setCentralWidget(chart_view)
Esempio n. 31
0
class OpenIMUBarGraphView(QChartView):
    def __init__(self, parent=None):
        super(QChartView, self).__init__(parent=parent)
        self.chart = QChart()
        self.setChart(self.chart)
        self.chart.legend().setVisible(True)
        self.chart.legend().setAlignment(Qt.AlignBottom)
        self.chart.setAnimationOptions(QChart.SeriesAnimations)
        self.series = QBarSeries(self)
        self.categoryAxis = QBarCategoryAxis(self)
        self.setMinimumHeight(400)
        self.setMinimumWidth(400)

    def set_title(self, title):
        #print('Setting title: ', title)
        self.chart.setTitle(title)

    def set_category_axis(self, categories):
        self.categoryAxis.append(categories)

    def add_set(self, label, values):
        #print('adding bar set')
        my_set = QBarSet(label, self)
        my_set.append(values)
        self.series.append(my_set)

    def update(self):
        self.chart.addSeries(self.series)
        self.chart.createDefaultAxes()
        self.chart.setAxisX(self.categoryAxis, self.series)

    def add_test_data(self):
        print('adding test data series')
        self.set_title('Testing bars')
        self.set_category_axis(['A', 'B', 'C', 'D'])
        self.add_set('Test1', [0.1, 2, 3, 4])
        self.add_set('Test2', [3, 2, 1, 4])
        self.add_set('Test3', [4, 1, 3, 2])
        self.update()
    def create_bar_chart(self):
        set0 = QBarSet('投料')
        set1 = QBarSet('不良回收')
        series = QBarSeries()
        axis = QBarCategoryAxis()
        chart = QChart()

        categories = [
            '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00',
            '16:00', '17:00'
        ]

        set0.append([1, 2, 3, 4, 5, 6, 7, 8, 9])
        set1.append([5, 0, 0, 4, 0, 7, 13, 8, 7])
        series.append(set0)
        series.append(set1)
        chart.addSeries(series)
        axis.append(categories)

        chart.setTitle('柱状图学习测试')
        chart.createDefaultAxes()
        chart.setAxisX(axis, series)
        return chart
Esempio n. 33
0
    def create_linechart(self):
        series = QLineSeries(self)
        series.append(0, 6)
        series.append(2, 4)
        series.append(3, 8)
        series.append(7, 4)
        series.append(10, 5)

        series << QPointF(11, 1) << QPointF(13, 3) << QPointF(
            17, 6) << QPointF(18, 3) << QPointF(20, 2)

        chart = QChart()

        chart.addSeries(series)
        chart.createDefaultAxes()
        chart.setAnimationOptions(QChart.SeriesAnimations)
        chart.setTitle("Line Chart Example")

        chart.legend().setVisible(True)

        chartview = QChartView(chart)
        chartview.setRenderHint(QPainter.Antialiasing)
        self.layout.addWidget(chartview, 0, 1, 5, 1)