def setupUi(self, Form): Form.setObjectName("Form") Form.resize(1550, 750) Form.setMinimumSize(QtCore.QSize(1550, 750)) self.gridLayout = QtWidgets.QGridLayout(Form) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setObjectName("gridLayout") self.chart1 = QtChart.QChart() self.chart1.setBackgroundVisible(False) self.chartView = QtChart.QChartView(self.chart1) self.gridLayout.addWidget(self.chartView, 0, 0, 1, 1) self.chart2 = QtChart.QChart() self.chart2.setBackgroundVisible(False) self.chartView2 = QtChart.QChartView(self.chart2) self.gridLayout.addWidget(self.chartView2, 0, 1, 1, 1) self.chart3 = QtChart.QChart() self.chart3.setBackgroundVisible(False) self.chartView3 = QtChart.QChartView(self.chart3) self.gridLayout.addWidget(self.chartView3, 1, 0, 1, 1) self.chart4 = QtChart.QChart() self.chart4.setBackgroundVisible(False) self.chartView4 = QtChart.QChartView(self.chart4) self.gridLayout.addWidget(self.chartView4, 1, 1, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def calculate_graph(self): """ Calculate the Bar graph for the selected SKU's from database. """ if self.show_graph: bar_set_1, bar_set_2 = self.get_graph_point() series = QtChart.QStackedBarSeries() series.append(bar_set_1) series.append(bar_set_2) chart = QtChart.QChart() chart.setTitle("Good and Bad") chart.addSeries(series) chart.setAnimationOptions(QtChart.QChart.SeriesAnimations) x_axis = QtChart.QBarCategoryAxis() x_axis.append(constants.TIME_VALUES[:-1]) chart.addAxis(x_axis, QtCore.Qt.AlignBottom) series.attachAxis(x_axis) y_axis = QtChart.QValueAxis() chart.addAxis(y_axis, QtCore.Qt.AlignLeft) series.attachAxis(y_axis) chart.legend().setVisible(True) chart.legend().setAlignment(QtCore.Qt.AlignBottom) chart_view = QtChart.QChartView(chart) chart_view.setRenderHint(QtGui.QPainter.Antialiasing) return chart_view
def __init__(self,data): QtWidgets.QWidget.__init__(self) self.model = CustomTableModel(data) self.table_view = QtWidgets.QTableView() self.table_view.setModel(self.model) self.horizontal_header = self.table_view.horizontalHeader() self.vertical_header = self.table_view.verticalHeader() self.horizontal_header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) self.vertical_header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) self.horizontal_header.setStretchLastSection(True) self.chart = QtChart.QChart() self.chart.setAnimationOptions(QtChart.QChart.AllAnimations) self.add_series("Magnitude (Column 1)",[0,1]) self.chart_view = QtChart.QChartView(self.chart) self.chart_view.setRenderHint(QtGui.QPainter.Antialiasing) self.main_layout = QtWidgets.QHBoxLayout() size = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) size.setHorizontalStretch(1) self.table_view.setSizePolicy(size) self.main_layout.addWidget(self.table_view) size.setHorizontalStretch(4) self.chart_view.setSizePolicy(size) self.main_layout.addWidget(self.chart_view) self.setLayout(self.main_layout)
def __init__(self): self.W = QtWidgets.QDoubleSpinBox(Form) self.H = QtWidgets.QDoubleSpinBox(Form) self.label_25 = QtWidgets.QLabel(Form) self.label_24 = QtWidgets.QLabel(Form) self.label_23 = QtWidgets.QLabel(Form) self.label_22 = QtWidgets.QLabel(Form) self.dY = QtWidgets.QDoubleSpinBox(Form) self.mu = QtWidgets.QDoubleSpinBox(Form) self.label_21 = QtWidgets.QLabel(Form) self.dX = QtWidgets.QDoubleSpinBox(Form) self.label_20 = QtWidgets.QLabel(Form) self.label_19 = QtWidgets.QLabel(Form) self.label_18 = QtWidgets.QLabel(Form) self.label_17 = QtWidgets.QLabel(Form) self.label_16 = QtWidgets.QLabel(Form) self.M = QtWidgets.QDoubleSpinBox(Form) self.k4 = QtWidgets.QDoubleSpinBox(Form) self.label_15 = QtWidgets.QLabel(Form) self.m = QtWidgets.QDoubleSpinBox(Form) self.label_14 = QtWidgets.QLabel(Form) self.label_13 = QtWidgets.QLabel(Form) self.label_12 = QtWidgets.QLabel(Form) self.label_11 = QtWidgets.QLabel(Form) self.label_10 = QtWidgets.QLabel(Form) self.k3 = QtWidgets.QDoubleSpinBox(Form) self.label_9 = QtWidgets.QLabel(Form) self.label_8 = QtWidgets.QLabel(Form) self.k2 = QtWidgets.QDoubleSpinBox(Form) self.label_7 = QtWidgets.QLabel(Form) self.label_6 = QtWidgets.QLabel(Form) self.label_5 = QtWidgets.QLabel(Form) self.k1 = QtWidgets.QDoubleSpinBox(Form) self.label_4 = QtWidgets.QLabel(Form) self.btn_pause = QtWidgets.QPushButton(Form) self.btn_start = QtWidgets.QPushButton(Form) self.btn_hide = QtWidgets.QPushButton(Form) self.chartView = QtChart.QChartView(Form) self.chartView.setRenderHint(QtGui.QPainter.Antialiasing) self.chart = self.chartView.chart() self.chart.legend().setVisible(False) self.axisX = QtChart.QValueAxis() self.axisY = QtChart.QValueAxis() self.mass_series = QtChart.QScatterSeries() self.trajectory_series = QtChart.QLineSeries() self.box_series = QtChart.QLineSeries() self.s1_series = QtChart.QLineSeries() self.s2_series = QtChart.QLineSeries() self.s3_series = QtChart.QLineSeries() self.s4_series = QtChart.QLineSeries() self.timer = QtCore.QTimer() self.timer.setInterval(10) self.total_time = .0 self.runge_kutta = ode(self.f) self.runge_kutta.set_integrator('dopri5')
def __init__(self, data): self.data = data self.app = QApplication(sys.argv) self.series = QtChart.QCandlestickSeries() self.series.setDecreasingColor(Qt.red) self.series.setIncreasingColor(Qt.green) self.ma5 = qc.QLineSeries() self.tm = [] for num, o, h, l, c, m in self.data: self.series.append(QtChart.QCandlestickSet(o, h, l, c)) self.ma5.append(QPointF(num, m)) self.tm.append(str(num)) self.chart = QtChart.QChart() self.chart.addSeries(self.series) # candle self.chart.addSeries(self.ma5) # ma5 line self.chart.createDefaultAxes() self.chart.legend().hide() self.chart.axisX(self.series).setCategories(self.tm) self.chart.axisX(self.ma5).setVisible(False) self.chartview = QtChart.QChartView(self.chart) self.ui = QMainWindow() self.ui.setGeometry(50, 50, 500, 300) self.ui.setCentralWidget(self.chartview) self.ui.show() sys.exit(self.app.exec_())
def create_chart(percent): """Создает диаграмму""" # ядро диаграммы series = QtChart.QPieSeries() series.append("Верные", percent) series.append('Неверные', 100 - percent) series.setPieSize(30) # анимация диаграммы chart = QtChart.QChart() chart.addSeries(series) chart.setAnimationOptions(QtChart.QChart.SeriesAnimations) chart.setAnimationDuration(3000) chart.setTitle('Соотношение ответов') # шрифт диаграммы font = QtGui.QFont() font.setFamily('PT Sans') font.setPointSize(18) chart.setFont(font) chart.setTitleFont(font) # виджет диаграммы chartview = QtChart.QChartView(chart) chartview.setRenderHint(QtGui.QPainter.Antialiasing) dialog.fails_table.setMinimumWidth(434) dialog.diagram_frame.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) dialog.verticalLayout_7.addWidget(chartview)
def __init__(self, baseWidget): self.chartView = QtChart.QChartView(baseWidget) self.chartView.setGeometry(0, 0, baseWidget.width(), baseWidget.height()) self.chartView.setRubberBand(QtChart.QChartView.HorizontalRubberBand) self.chartView.rubberBandChanged.connect( self.slot_rubberBandChangedFun)
def __init__(self): self.check_box = QtWidgets.QCheckBox() self.check_box.setCheckState(QtCore.Qt.Checked) self.check_box.stateChanged.connect(self._check_changed) self.scaling_spin_box = QtWidgets.QDoubleSpinBox() # TODO: set a useful width without limiting the range # self.scaling_spin_box.setRange(-math.inf, math.inf) self.scaling_spin_box.setRange(-100000, 100000) self.scaling_spin_box.setDecimals(3) self.scaling_spin_box.setValue(1) self.scaling_spin_box.valueChanged.connect(self.scaling_changed) self.chart = QtChart.QChart() self.series = QtChart.QLineSeries() self.chart.addSeries(self.series) self.chart.createDefaultAxes() # self.chart.plotAreaChanged.connect(self._plot_area_changed) self.original_area = None self.view = QtChart.QChartView(self.chart) self.view_filters = make_chart_view_zoomable(self.view) reference_height = self.check_box.minimumSizeHint().height() reference_height += self.scaling_spin_box.minimumSizeHint().height() self.view.setMinimumHeight(6 * reference_height) view_size_policy = self.view.sizePolicy() view_size_policy.setVerticalPolicy(view_size_policy.Minimum) self._name = None self.name = "<unnamed>" self.data = ()
def __init__(self): self.check_box = QtWidgets.QCheckBox() self.check_box.setCheckState(QtCore.Qt.Checked) self.check_box.stateChanged.connect(self._check_changed) self.scaling_spin_box = QtWidgets.QDoubleSpinBox() # TODO: set a useful width without limiting the range # self.scaling_spin_box.setRange(-math.inf, math.inf) self.scaling_spin_box.setRange(-100000, 100000) self.scaling_spin_box.setDecimals(3) self.scaling_spin_box.setValue(1) self.scaling_spin_box.valueChanged.connect(self.scaling_changed) self.chart = QtChart.QChart() self.series = QtChart.QLineSeries() self.chart.addSeries(self.series) self.chart.createDefaultAxes() # self.chart.plotAreaChanged.connect(self._plot_area_changed) self.original_area = None self.view = QtChart.QChartView(self.chart) self.view_filters = make_chart_view_zoomable(self.view) self._name = None self.name = '<unnamed>' self.data = ()
def __init__(self): super().__init__() self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0))) self.setBackgroundRoundness(0) self.setMargins(QtCore.QMargins(0, 0, 0, 0)) self.layout().setContentsMargins(0, 0, 0, 0) self.legend().hide() chartFont = QtGui.QFont(self.font()) chartFont.setPixelSize(9) self.setFont(chartFont) self.IndicatorName = QtWidgets.QGraphicsSimpleTextItem(self) self.IndicatorName.setBrush(QtGui.QBrush(QtGui.QColor(255, 255, 255))) self.IndicatorName.setOpacity(1.0) self.IndicatorName.setPos(0, 0) indicatorView = QtChart.QChartView(self) indicatorView.setRenderHint(QtGui.QPainter.Antialiasing) indicatorLayout = QtWidgets.QVBoxLayout() indicatorLayout.setSpacing(0) indicatorLayout.setContentsMargins(0, 0, 0, 0) indicatorLayout.addWidget( DoubleLineSeparator(orientation='horizontal', linecolor=COLOR_SEPARATOR, spacecolor='rgb(0,0,0)', stroke=1, width=3)) indicatorLayout.addWidget(indicatorView) self.frame = QtWidgets.QFrame() self.frame.setLayout(indicatorLayout)
def __init__(self): # основной конструктор self.label = QtWidgets.QLabel( Form) # создаем элементы подписи размерностей у полей self.label_2 = QtWidgets.QLabel(Form) self.label_3 = QtWidgets.QLabel(Form) self.label_4 = QtWidgets.QLabel(Form) self.label_5 = QtWidgets.QLabel(Form) self.label_6 = QtWidgets.QLabel(Form) self.t = QtWidgets.QDoubleSpinBox( Form) # созда ем элементы числовых полей для ввода значений self.k = QtWidgets.QDoubleSpinBox(Form) self.N = QtWidgets.QDoubleSpinBox(Form) self.F = QtWidgets.QDoubleSpinBox(Form) self.fi = QtWidgets.QDoubleSpinBox(Form) self.w = QtWidgets.QDoubleSpinBox(Form) self.btn_pause = QtWidgets.QPushButton(Form) # создаем кнопку паузы self.btn_start = QtWidgets.QPushButton(Form) # создаем кнопку старт self.chartView = QtChart.QChartView(Form) # создаем поле для графиков self.chart = self.chartView.chart( ) # получаем ссылку на график из chartView self.axisX = QtChart.QValueAxis() # создаем ось Х self.axisY = QtChart.QValueAxis() # создаем ось У
def __init__(self): self.r = QtWidgets.QDoubleSpinBox(Form) self.label_4 = QtWidgets.QLabel(Form) self.label_3 = QtWidgets.QLabel(Form) self.L = QtWidgets.QDoubleSpinBox(Form) self.btn_pause = QtWidgets.QPushButton(Form) self.btn_start = QtWidgets.QPushButton(Form) self.label_2 = QtWidgets.QLabel(Form) self.R = QtWidgets.QDoubleSpinBox(Form) self.label = QtWidgets.QLabel(Form) self.M = QtWidgets.QDoubleSpinBox(Form) self.chartView = QtChart.QChartView(Form) self.chartView.setRenderHint(QtGui.QPainter.Antialiasing) self.chart = self.chartView.chart() self.chart.legend().setVisible(False) self.axisX = QtChart.QValueAxis() self.axisY = QtChart.QValueAxis() self.axis_series = QtChart.QLineSeries() self.ring_series = QtChart.QLineSeries() self.rope_series = QtChart.QLineSeries() self.dot_series = QtChart.QScatterSeries() self.timer = QtCore.QTimer() self.timer.setInterval(100) self.total_time = .0 self.runge_kutta = ode(self.f) self.runge_kutta.set_integrator('dopri5') self.dest = +1 self.flag = True
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.main_layout = QtWidgets.QHBoxLayout(self) self.box = QtWidgets.QComboBox(self) self.box.currentTextChanged.connect(self.change_y) self.main_layout.addWidget(self.box) self.chart_view = QtChart.QChartView(self) self.main_layout.addWidget(self.chart_view)
def showBewertungsScreen(self, bewertungen, maxWert): # Andere Fenster schließen self.LoginWindow.close() self.VorlesungWindow.close() # Vorlesungsfenster erstellen self.BewertungsWindow.setMinimumHeight(480) self.BewertungsWindow.setMinimumWidth(800) self.BewertungsWindow.showFullScreen() #Layout festlegen layout = QtWidgets.QGridLayout() #Sets erstellen (unterteilt nach Noten) self.set = QtChart.QBarSet('Gut') self.set1 = QtChart.QBarSet('Okay') self.set2 = QtChart.QBarSet('Zu Langsam') self.set3 = QtChart.QBarSet('Zu Schnell') self.set4 = QtChart.QBarSet('Zu Kompliziert') self.set.append(bewertungen[0]) self.set1.append(bewertungen[1]) self.set2.append(bewertungen[2]) self.set3.append(bewertungen[3]) self.set4.append(bewertungen[4]) #Einzelne Graphen erstellen und mit Sets verknüpfen self.series = QtChart.QBarSeries() self.series.append(self.set) self.series.append(self.set1) self.series.append(self.set2) self.series.append(self.set3) self.series.append(self.set4) #Chart initialiseren und Start Animation festlegen self.chart = QtChart.QChart() self.chart.addSeries(self.series) self.chart.setTitle("Bewertungen") self.chart.setAnimationOptions(QtChart.QChart.SeriesAnimations) #Achsen erstellen und formatieren achseX = QtChart.QBarCategoryAxis() achseY = QtChart.QValueAxis() achseY.setRange(0, maxWert) #Ansicht zusammenstellen und anzeigen self.chart.addAxis(achseX, QtCore.Qt.AlignBottom) self.chart.addAxis(achseY, QtCore.Qt.AlignLeft) self.chart.legend().setVisible(True) self.chart.legend().setAlignment(QtCore.Qt.AlignBottom) chartView = QtChart.QChartView(self.chart) layout.addWidget(chartView) self.BewertungsWindow.setLayout(layout) self.BewertungsWindow.show() self.logikReThread = LogikRestart() self.logikReThread.signalRestart.connect(self.showLoginScreen) self.logikReThread.start()
def create_pie(self): pie = QtChart.QPieSeries() pie.append('1', 10) pie.append('2', 20) chart = QtChart.QChart() chart.addSeries(pie) #chart.setAnimationOptions(QtChart.SeriesAnimation) chartview = QtChart.QChartView(chart)
def init_graph(self): if self.ui.acc_graph_placeholder.layout() is None: acc_chart_Layout = QtWidgets.QVBoxLayout() loss_chart_Layout = QtWidgets.QVBoxLayout() self.ui.acc_graph_placeholder.setLayout(acc_chart_Layout) self.ui.loss_graph_placeholder.setLayout(loss_chart_Layout) acc_chart = QtChart.QChart() loss_chart = QtChart.QChart() self.acc_chart_view = QtChart.QChartView(acc_chart) self.acc_chart_view.setRenderHint(QtGui.QPainter.Antialiasing) self.loss_chart_view = QtChart.QChartView(loss_chart) self.loss_chart_view.setRenderHint(QtGui.QPainter.Antialiasing) acc_chart_Layout.addWidget(self.acc_chart_view) loss_chart_Layout.addWidget(self.loss_chart_view) self.acc_chart_view.show() self.loss_chart_view.show() else: acc_chart = self.acc_chart_view.chart() loss_chart = self.loss_chart_view.chart() self.acc_serie = QtChart.QLineSeries() self.acc_serie.setName("train_acc") self.val_acc_serie = QtChart.QLineSeries() self.val_acc_serie.setName("val_acc") self.loss_serie = QtChart.QLineSeries() self.loss_serie.setName("loss") self.val_loss_serie = QtChart.QLineSeries() self.val_loss_serie.setName("val_loss") acc_chart.addSeries(self.acc_serie) acc_chart.addSeries(self.val_acc_serie) loss_chart.addSeries(self.loss_serie) loss_chart.addSeries(self.val_loss_serie) acc_chart.createDefaultAxes() loss_chart.createDefaultAxes() acc_chart.axisX().setRange(0, self.current_epoch) loss_chart.axisX().setRange(0, self.current_epoch)
def plot_clicked(self): """ :return: """ if self.__data is None: QtWidgets.QMessageBox.critical(self, "Error Plotting Data", "Need to import data first.") return psi_series = QtChart.QLineSeries() psi_series.setName("Pressure") for ts, p in self.__data.pressure.iteritems(): psi_series.append(time.mktime(ts.timetuple()) * 1000, p) temp_series = QtChart.QLineSeries() temp_series.setName("Temperature") for ts, t in self.__data.temperature.iteritems(): temp_series.append(time.mktime(ts.timetuple()) * 1000, t) chart = QtChart.QChart() chart.addSeries(psi_series) chart.addSeries(temp_series) x_axis = QtChart.QDateTimeAxis() x_axis.setTickCount(10) x_axis.setFormat("HH:mm:ss") x_axis.setTitleText("Time") chart.addAxis(x_axis, QtCore.Qt.AlignBottom) psi_series.attachAxis(x_axis) psi_axis = QtChart.QValueAxis() psi_axis.setLabelFormat("%i") psi_axis.setTitleText("Pressure (psi)") chart.addAxis(psi_axis, QtCore.Qt.AlignLeft) psi_series.attachAxis(psi_axis) temp_axis = QtChart.QValueAxis() temp_axis.setLabelFormat("%.2f") temp_axis.setTitleText("Temperature (C)") chart.addAxis(temp_axis, QtCore.Qt.AlignLeft) temp_series.attachAxis(temp_axis) chart.setTitle("Pressure Test %s" % (self.testReportLineEdit.text())) view = QtChart.QChartView(chart) view.setRenderHint(QtGui.QPainter.Antialiasing) dialog = QtWidgets.QDialog(self) layout = QtWidgets.QVBoxLayout() layout.addWidget(view) dialog.setLayout(layout) dialog.resize(1000, 800) dialog.show()
def run(self): # 2. Implement run() ui = Ui_MainWindow() window = QMainWindow() version = self.build_settings['version'] ui.setupUi(window) window.setWindowTitle("HotelManagementSystem v" + version) #Setup Charts for isolated UI editing ui.chartView = QtChart.QChartView(window) ui.chartView_2 = QtChart.QChartView(window) ui.gridLayout_3 = QtWidgets.QGridLayout(ui.groupBox_2) ui.gridLayout_3.addWidget(ui.chartView, 0, 0, 1, 1) ui.gridLayout_4 = QtWidgets.QGridLayout(ui.groupBox_3) ui.gridLayout_4.addWidget(ui.chartView_2, 0, 0, 1, 1) window.showMaximized() #Database connection, instead of sqlite3 db = QSqlDatabase('QSQLITE') db.setDatabaseName(self.get_resource('hotel.db')) model = QSqlTableModel(self.app, db) #Threading thrd = QThreadPool().globalInstance() thrd.setExpiryTimeout(5) hlist = ['Reserv. ID','Customer ID','Room #','From','To','Discount','Extension','Net Total'] worker = TableWorker(update_table("CurrentReservation", hlist, ui.current_res, db, model)) #We pass a function for the worker to execute thrd.tryStart(worker) #Setup Signals ui.newRes.triggered.connect(lambda: self.new_res_dialog(db, ui, model)) ui.newRoom.triggered.connect(lambda: self.new_room_dialog(db)) ui.newService.triggered.connect(lambda: self.new_srv_dialog(db)) ui.newCustomer.triggered.connect(lambda: self.new_customer_dialog(db)) ui.cancelRes.triggered.connect(lambda: self.new_cancel_dialog(window, db, ui.current_res.currentIndex(), thrd, model, hlist, ui.current_res)) #TODO Add new dialog for adding/deleting services to a current Reservation ui.current_res.doubleClicked.connect(lambda: self.new_addservice_dialog(window, db, ui.current_res.currentIndex(), thrd)) return self.app.exec_() # 3. End run() with this line
def __init__(self, port, baud=115200, samples=255, min_value=0, max_value=1023, **kwargs): super(SerialPlotter, self).__init__(**kwargs) self._serial_port = port self._serial_port_baud = baud self.samples = samples self.series = [] self.data = [] # set up chart self.setWindowTitle('Serial Plotter') self.setContentsMargins(0, 0, 0, 0) self.chart = QtChart.QChart() self.chart.setTheme(QtChart.QChart.ChartThemeDark) # remove the annoying white border self.chart.layout().setContentsMargins(0, 0, 0, 0) self.chart.setBackgroundRoundness(0) # set up chart view self.chart_view = QtChart.QChartView(self.chart) self.chart_view.setRenderHint(QtGui.QPainter.Antialiasing) self.chart_view.setMinimumSize(800, 600) # set up axis self.x_axis = QtChart.QValueAxis() self.x_axis.setRange(0, self.samples) self.x_axis.setTitleText('Samples') self.x_axis.setLabelFormat('%i') self.y_axis = QtChart.QValueAxis() self.y_axis.setRange(min_value, max_value) self.y_axis.setTitleText('Values') self.chart.addAxis(self.x_axis, Qt.AlignBottom) self.chart.addAxis(self.y_axis, Qt.AlignLeft) self.setCentralWidget(self.chart_view) # Setup the serial port self.serial = QtSerialPort.QSerialPort( self._serial_port, baudRate=self._serial_port_baud, readyRead=self.on_serial_ready_read, ) if not self.serial.open(QtCore.QIODevice.ReadWrite): print('can\'t open serial port') sys.exit(1) self.show()
def __init__(self): super().__init__() self._chart = QtChart.QChart() self._chart.legend().hide() self._chart.layout().setContentsMargins(0, 0, 0, 0) self._chart.setBackgroundRoundness(0) self._chart.setBackgroundVisible(False) self._chart.setMargins(QtCore.QMargins(0, 0, 0, 0)) self._xAxis = QtChart.QValueAxis() self._xAxis.setTickCount(3) self._xAxis.setMinorTickCount(4) self._xAxis.setLabelFormat("%.3f mm") self._chart.addAxis(self._xAxis, QtCore.Qt.AlignBottom) self._yAxis = QtChart.QValueAxis() self._yAxis.setTickCount(2) self._yAxis.setMinorTickCount(3) self._yAxis.setLabelFormat("%.2g Ohm") self._chart.addAxis(self._yAxis, QtCore.Qt.AlignLeft) self._line = QtChart.QLineSeries() self._line.setColor(QtGui.QColor('magenta')) self._chart.addSeries(self._line) self._line.attachAxis(self._xAxis) self._line.attachAxis(self._yAxis) self._series = QtChart.QScatterSeries() self._series.setName("R") self._series.setMarkerSize(3) self._series.setBorderColor(QtGui.QColor('red')) self._series.setColor(QtGui.QColor('red')) self._chart.addSeries(self._series) self._series.attachAxis(self._xAxis) self._series.attachAxis(self._yAxis) self._marker = QtChart.QScatterSeries() self._marker.setMarkerSize(9) self._marker.setBorderColor(QtGui.QColor('red')) self._marker.setColor(QtGui.QColor('red')) self._chart.addSeries(self._marker) self._marker.attachAxis(self._xAxis) self._marker.attachAxis(self._yAxis) self.qt.setMinimumSize(160, 60) self._view = QtChart.QChartView(self._chart) self.qt.layout().setContentsMargins(0, 0, 0, 0) self.qt.layout().addWidget(self._view)
def __init__(self, project): super().__init__() self.ui = Ui_Prepare() self.ui.setupUi(self) self.project = project self.last_hotword_index = 0 self.main_dataset = DataSet() # Init hotword list self.hotwords = self.project.project_info['hotwords'] for hotword in self.hotwords: self.ui.current_hotword.addItem(hotword) self.sample_classes = [None] + self.hotwords # Init directory list self.folder_list_layout = QtWidgets.QVBoxLayout() self.folder_list = [[] for i in range(len(self.hotwords) + 1)] self.pie_slices = [QtChart.QPieSlice("non-hotword ()", 0)] self.pie_slices.extend([QtChart.QPieSlice("{} ()".format(name), 0) for name in self.hotwords]) self.display_selected_directories(0) # Pie chart self.pie_series = QtChart.QPieSeries() for pie_slice in self.pie_slices: self.pie_series.append(pie_slice) self.pie_series.setHoleSize(0) self.pie_view = QtChart.QChartView() self.pie_view.setRenderHint(QtGui.QPainter.Antialiasing) self.pie_view.chart().layout().setContentsMargins(0,0,0,0) self.pie_view.chart().setMargins(QtCore.QMargins(0,0,0,0)) self.pie_view.chart().legend().setAlignment(QtCore.Qt.AlignRight) self.pie_view.chart().addSeries(self.pie_series) layout = QtWidgets.QVBoxLayout() layout.addWidget(self.pie_view) self.ui.graph_placeholder.setLayout(layout) #Connects self.ui.current_hotword.currentIndexChanged.connect(self.display_selected_directories) self.ui.add_folder_button.clicked.connect(self.add_folder) self.ui.test_subset_CB.stateChanged.connect(self.ui.test_subset_percent.setEnabled) self.ui.val_on_test_set_CB.stateChanged.connect(self.disable_validation_set) self.ui.training_percent.valueChanged.connect(self.on_trainsample_update) self.ui.validation_percent.valueChanged.connect(self.on_valsample_update) self.ui.test_percent.valueChanged.connect(self.on_testsample_update) self.ui.done_button.clicked.connect(self.on_done_clicked) self.ui.add_set_PB.clicked.connect(self.add_set)
def ballance_ui(self): g_box = QtWidgets.QGridLayout() self.total_balance = QtWidgets.QLabel("Toplam") self.checking_account = QtWidgets.QLabel("Vadesiz Hesap") self.deposit_account = QtWidgets.QLabel("Vadeli eHesap") self.total_balance_amount = QtWidgets.QLabel("{}".format(self.account.deposit_account+self.account.checking_account)) self.checking_account_amount = QtWidgets.QLabel("{}".format(self.account.checking_account)) self.deposit_account_amount = QtWidgets.QLabel("{}".format(self.account.deposit_account)) series = QtChart.QPieSeries() series.setHoleSize(0.35) series.append("Vadeli",self.account.deposit_account) series.append("Vadesiz",self.account.checking_account) chart = QtChart.QChart() chart.legend().hide() chart.addSeries(series) chart.createDefaultAxes() chart.setAnimationOptions(QtChart.QChart.SeriesAnimations) chart.legend().setVisible(True) chart.legend().setAlignment(QtCore.Qt.AlignLeft) chartview = QtChart.QChartView(chart) chartview.setRenderHint(QtGui.QPainter.Antialiasing) self.withdrawing_buton = QtWidgets.QPushButton("Para Çekme") self.bank_buton = QtWidgets.QPushButton("Para Yatırma") g_box.addWidget(self.total_balance,0,0) g_box.addWidget(self.checking_account,1,0) g_box.addWidget(self.deposit_account,2,0) g_box.addWidget(self.total_balance_amount,0,1) g_box.addWidget(self.checking_account_amount,1,1) g_box.addWidget(self.deposit_account_amount,2,1) g_box.addWidget(self.bank_buton,0,2) g_box.addWidget(self.withdrawing_buton,1,2) v_box = QtWidgets.QVBoxLayout() v_box.addWidget(chartview) v_box.addLayout(g_box) self.withdrawing_buton.clicked.connect(self.withdrawing) self.bank_buton.clicked.connect(self.bank) self.setLayout(v_box)
def __init__(self): QtWidgets.QWidget.__init__(self) self.setWindowTitle(self.tr('Chart Printing')) self.chart = QtChart.QChart() self.chart_view = QtChart.QChartView(self.chart) self.chart_view.setRenderHint(QtGui.QPainter.Antialiasing) self.buttonPreview = QtWidgets.QPushButton('Preview', self) self.buttonPreview.clicked.connect(self.handle_preview) self.buttonPrint = QtWidgets.QPushButton('Print', self) self.buttonPrint.clicked.connect(self.handle_print) layout = QtWidgets.QGridLayout(self) layout.addWidget(self.chart_view, 0, 0, 1, 2) layout.addWidget(self.buttonPreview, 1, 0) layout.addWidget(self.buttonPrint, 1, 1) self.create_chart()
def __init__(self, *args, **kwargs): super(BuyTimelineChartCont, self).__init__(*args, **kwargs) # chart self.chart = qtchart.QChart() # self.chart.legend().hide() self.chart.legend().setAlignment(qt.AlignRight) self.chart.legend().setLabelColor( style.myStyle.getQColor("TEXT_NORMAL")) self.chart.setBackgroundVisible(False) # date axis self.xAxis = qtchart.QDateTimeAxis() self.xAxis.setTickCount(10) self.xAxis.setFormat("dd MM yy") self.xAxis.setGridLineColor( style.myStyle.getQColor("BACKGROUND_BITDARK")) self.xAxis.setLinePenColor( style.myStyle.getQColor("BACKGROUND_BITDARK")) self.xAxis.setLabelsColor(style.myStyle.getQColor("TEXT_NORMAL")) self.chart.addAxis(self.xAxis, qt.AlignBottom) # balance axis self.yAxisBalance = qtchart.QValueAxis() self.yAxisBalance.setLabelFormat("%.2f") self.yAxisBalance.setGridLineColor( style.myStyle.getQColor("BACKGROUND_BITDARK")) self.yAxisBalance.setLinePenColor( style.myStyle.getQColor("BACKGROUND_BITDARK")) self.chart.addAxis(self.yAxisBalance, qt.AlignLeft) # price axis self.yAxisPrice = qtchart.QValueAxis() self.yAxisPrice.setLabelFormat("%.2f") self.yAxisPrice.setGridLineColor( style.myStyle.getQColor("BACKGROUND_BITDARK")) self.yAxisPrice.setLinePenColor( style.myStyle.getQColor("BACKGROUND_BITDARK")) self.chart.addAxis(self.yAxisPrice, qt.AlignRight) # chartview self.chartView = qtchart.QChartView(self.chart) self.chartView.setRenderHint(qtgui.QPainter.Antialiasing) self.layout = qtwidgets.QHBoxLayout(self) self.layout.addWidget(self.chartView) self.layout.setContentsMargins(0, 0, 0, 0)
def __init__(self): super(CandleChartWidget, self).__init__() self.setContentsMargins(0, 0, 0, 0) palette = QtGui.QPalette() palette.setColor(QtGui.QPalette.Background, QtCore.Qt.black) self.setAutoFillBackground(True) self.setPalette(palette) self.candleGraph = CandleChart() chartView = QtChart.QChartView(self.candleGraph) chartView.setRenderHint(QtGui.QPainter.Antialiasing) self.mainLayout = QtWidgets.QVBoxLayout(self) self.mainLayout.setSpacing(0) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.addWidget(chartView, stretch=4)
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(741, 379) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.buttonHistogram = QtWidgets.QPushButton(self.centralwidget) self.buttonHistogram.setGeometry(QtCore.QRect(180, 0, 86, 32)) self.buttonHistogram.setObjectName("buttonHistogram") self.buttonHistogram.clicked.connect(self.setHistogram) self.buttonLoad = QtWidgets.QPushButton(self.centralwidget) self.buttonLoad.setGeometry(QtCore.QRect(0, 0, 86, 32)) self.buttonLoad.setObjectName("buttonLoad") self.buttonLoad.clicked.connect(self.loadImage) self.buttonGrayscale = QtWidgets.QPushButton(self.centralwidget) self.buttonGrayscale.setGeometry(QtCore.QRect(90, 0, 86, 32)) self.buttonGrayscale.setObjectName("buttonGrayscale") self.buttonGrayscale.clicked.connect(self.setGrayscale) self.buttonCDF = QtWidgets.QPushButton(self.centralwidget) self.buttonCDF.setGeometry(QtCore.QRect(270, 0, 86, 32)) self.buttonCDF.setObjectName("buttonCDF") self.buttonPDF = QtWidgets.QPushButton(self.centralwidget) self.buttonPDF.setGeometry(QtCore.QRect(360, 0, 86, 32)) self.buttonPDF.setObjectName("buttonPDF") self.graphicsView = QtWidgets.QGraphicsView(self.centralwidget) self.graphicsView.setGeometry(QtCore.QRect(0, 40, 371, 311)) self.graphicsView.setObjectName("graphicsView") self.chartview = QtChart.QChartView(self.centralwidget) self.chartview.setGeometry(QtCore.QRect(370, 40, 371, 311)) self.chartview.setObjectName("chartview") MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def show_chart(self, col): ''' 1.QChartView : 是一个可以显示图表(chart)的独立部件。 2.QChart : 用于创建图表。 3.series : 被词典翻译为 串联;级数;系列,连续; 这里我理解为存储的一系列坐标; 4.QValueAxis : 继承自QAbstractAxis,用于对坐标轴进行操作。 流程: 坐标附加到series然后使用addSeries方法把series载入ChartView。 ''' if not self.data_isValid: return # creating LineSeries data = self.dataList[0] len = data.shape[0] series = QtChart.QLineSeries() series.setName(col) for idx in data.index: series.append(idx, data.loc[idx,col]) print(data.index.min(), data.index.max()) # define x/y axis x_axis = QtChart.QValueAxis() x_axis.setRange(data.index.min(), data.index.max()) x_axis.setLabelFormat("%0.1f") # 设置坐标轴的显示方式,精确到小数点后1位 x_axis.setTickCount(len) x_axis.setMinorTickCount(1) # 设置每个单元格有几个小的分级 y_axis = QtChart.QValueAxis() y_axis.setRange(data[col].min(), data[col].max()) y_axis.setLabelFormat("%0.2f") # 设置坐标轴的显示方式,精确到小数点后2位 y_axis.setTickCount(10) y_axis.setMinorTickCount(0) # 设置每个单元格有几个小的分级 # Creating QChartQview self.chartView = QtChart.QChartView() self.chartView.resize(800,600) self.ui_moveCenter(self.chartView) chart = QtChart.QChart() chart.addSeries(series) chart.setAxisX(x_axis) # 设置x轴属性 chart.setAxisY(y_axis) # 设置y轴属性 # chart.createDefaultAxes() # 使用默认坐标系 chart.setTitle("数据列显示:%s" % col) # 设置标题 self.chartView.setChart(chart) self.chartView.show()
def init_graph(self): self.pieSlices = [] for hw in self.project.project_info['hotwords'] + ['non-hotword']: self.pieSlices.append(QtChart.QPieSlice("{} ()".format(hw), 0)) self.pie_series = QtChart.QPieSeries() for pie_slice in self.pieSlices: self.pie_series.append(pie_slice) self.pie_series.setHoleSize(0) self.pie_view = QtChart.QChartView() self.pie_view.setRenderHint(QtGui.QPainter.Antialiasing) self.pie_view.chart().layout().setContentsMargins(0,0,0,0) self.pie_view.chart().setMargins(QtCore.QMargins(0,0,0,0)) self.pie_view.chart().legend().setAlignment(QtCore.Qt.AlignBottom) self.pie_view.chart().addSeries(self.pie_series) layout = QtWidgets.QVBoxLayout() layout.addWidget(self.pie_view) self.ui.graph_placeholder.setLayout(layout)
def _load_graph(self, stats, min_w, max_w): if self.ui.histo_widget.layout() is None: layout = QtWidgets.QVBoxLayout() self.ui.histo_widget.setLayout(layout) chart = QtChart.QChart() chart.setBackgroundBrush( QtGui.QBrush(self.palette().color(self.backgroundRole()))) self._chart_view = QtChart.QChartView(chart) layout.addWidget(self._chart_view) self._serie = QtChart.QLineSeries() self._serie.setName("Word count") chart.addSeries(self._serie) chart.createDefaultAxes() self._chart_view.show() self._serie.clear() max_s = max([v for v in stats.values()]) for i in range(min_w, max_w): self._serie.append(i, stats.get(i, 0)) self._chart_view.chart().axisX().setRange(min_w - 1, max_w + 1) self._chart_view.chart().axisY().setRange(0, max_s + 1)
def _chartView(self): self.chart = QtChart.QChart() axisX = QtChart.QCategoryAxis(labelsPosition=QtChart.QCategoryAxis.AxisLabelsPositionOnValue, startValue=900.0) axisX.setTitleText("Wavelength (nm)") axisX.setRange(900, 1700) axisX.setTickCount(9) axisX.setLabelsFont(QtGui.QFont("Times", 12)) axisX.append("900", 900.0) axisX.append("1000", 1000) axisX.append("1100", 1100) axisX.append("1200", 1200) axisX.append("1300", 1300) axisX.append("1400", 1400) axisX.append("1500", 1500) axisX.append("1600", 1600) axisX.append("1700", 1700) self.chart.addAxis(axisX, QtCore.Qt.AlignBottom) self.axisY = QtChart.QValueAxis() self.axisY.setTitleText("Absorbance") self.axisY.setLabelFormat("%.2f") self.axisY.setRange(-5, 5) self.axisY.setLabelsFont(QtGui.QFont("Times", 12)) self.chart.addAxis(self.axisY, QtCore.Qt.AlignLeft) self.chart.legend().setVisible(False) self.chartView = QtChart.QChartView(self.widget_plot) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.chartView.sizePolicy().hasHeightForWidth()) self.chartView.setSizePolicy(sizePolicy) self.chartView.setMinimumSize(680, 480) self.chartView.setMouseTracking(True) self.chartView.setAcceptDrops(False) self.chartView.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContentsOnFirstShow) self.chartView.setObjectName("chartView") self.chartView.setChart(self.chart)