def mouseMoveEvent(self, event): ##Sets the place of the popup in the windows to avoid getout of the screen ##frmshow can be a frmShowCasilla or a frmShowFicha def placePopUp(): resultado=QPoint(event.x()+15, event.y()+15) if event.x()>self.width()-self.popup.width()-15: resultado.setX(event.x()-self.popup.width()-15) if event.y()>self.height()-self.popup.height()-15: resultado.setY(event.y()-self.popup.height()-15) return resultado def showCurrentPosition(): if hasattr(self, "qgstiCurrentX")==False: self.qgstiCurrentX=QGraphicsSimpleTextItem(self.chart()) self.qgstiCurrentY=QGraphicsSimpleTextItem(self.chart()) self.qgstiCurrentX.setPos(event.pos().x(), maxY-10) self.qgstiCurrentY.setPos(self.chart().size().width()-47, event.pos().y()) self.qgstiCurrentX.setText(str(epochms2dtaware(xVal).date())) self.qgstiCurrentY.setText(str(round(yVal,2))) # --------------------------------------- QChartView.mouseMoveEvent(self, event) xVal = self.chart().mapToValue(event.pos()).x() yVal = self.chart().mapToValue(event.pos()).y() maxX = self.axisX.max().toMSecsSinceEpoch() minX = self.axisX.min().toMSecsSinceEpoch() maxY = self.axisY.max() minY = self.axisY.min() if xVal <= maxX and xVal >= minX and yVal <= maxY and yVal >= minY: self.popup.move(self.mapToGlobal(placePopUp())) self.popup.refresh(self, xVal, yVal) showCurrentPosition() self.popup.show() else: self.popup.hide()
class TestWindow(QMainWindow): def __init__(self, parent=None): super(TestWindow, self).__init__(parent=parent) self.ncurves = 0 self.timer = QTimer(self) self.chart = QChart() self.chart.legend().hide() self.view = QChartView(self.chart) self.view.setRenderHint(QPainter.Antialiasing) self.setCentralWidget(self.view) self.count = 0. #self.timer.timeout.connect(functools.partial(self.update, a=1)) #self.timer.start(100) #def update(self, a): #print(self.chart.series) def set_title(self, title): self.chart.setTitle(title) def add_data(self, xdata, ydata, color=None): curve = QLineSeries() pen = curve.pen() if color is not None: pen.setColor(color) pen.setWidthF(.6) curve.setPen(pen) curve.setUseOpenGL(True) curve.append(series_to_polyline(xdata, ydata)) self.chart.addSeries(curve) self.chart.createDefaultAxes() self.ncurves += 1
class TestWindow(QMainWindow): def __init__(self, parent=None): super(TestWindow, self).__init__(parent=parent) self.ncurves = 0 self.chart = QChart() self.chart.legend().hide() self.view = QChartView(self.chart) self.view.setRenderHint(QPainter.Antialiasing) self.setCentralWidget(self.view) def set_title(self, title): self.chart.setTitle(title) def add_data(self, xdata, ydata, color=None): curve = QLineSeries() pen = curve.pen() if color is not None: pen.setColor(color) pen.setWidthF(2.0) curve.setPen(pen) curve.setUseOpenGL(True) curve.append(series_to_polyline(xdata, ydata)) self.chart.addSeries(curve) self.chart.createDefaultAxes() self.ncurves += 1
def chart(self): self.pieseries = QPieSeries() # 定义PieSeries self.pieseries.append("正常程序", 0.1) # 插入第一个元素 self.pieseries.append("恶意程序", 0.9) self.slice = self.pieseries.slices()[0] # 得到饼图的某一个元素切片,在这取得为第一个 #self.slice.setExploded() # 设置为exploded self.slice.setLabelVisible() # 设置Lable self.slice.setPen(QPen(Qt.darkGreen, 1)) # 设置画笔类型 self.slice.setBrush(Qt.green) # 设置笔刷 self.slice1 = self.pieseries.slices()[1] # 得到饼图的某一个元素切片,在这取得为第一个 self.slice1.setExploded() # 设置为exploded self.slice1.setLabelVisible() # 设置Lable self.slice1.setPen(QPen(Qt.darkRed, 1)) # 设置画笔类型 self.slice1.setBrush(Qt.red) # 设置笔刷 self.chart = QChart() # 定义QChart self.chart.addSeries(self.pieseries) # 将 pieseries添加到chart里 self.chart.setTitle("恶意程序预测结果饼状图") # 设置char的标题 self.chart.legend().hide() # 将char的legend设置为隐藏 self.charview = QChartView( self.chart, self.left_down_widget ) # 定义charView窗口,添加chart元素,设置主窗口为父窗体,既将chartView嵌入到父窗体 self.charview.setGeometry(0, 0, 800, 500) # 设置charview在父窗口的大小、位置 self.charview.setRenderHint(QPainter.Antialiasing) # 设置抗锯齿 self.charview.show() # 将CharView窗口显示出来
def setupUi(self, Monitor): Monitor.setObjectName("Monitor") Monitor.resize(1132, 595) Monitor.setMinimumSize(QtCore.QSize(1132, 595)) self.gridLayout_2 = QtWidgets.QGridLayout(Monitor) self.gridLayout_2.setObjectName("gridLayout_2") self.label = QtWidgets.QLabel(Monitor) self.label.setMinimumSize(QtCore.QSize(1091, 41)) self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setObjectName("label") self.gridLayout_2.addWidget(self.label, 0, 0, 1, 2) self.graphicsView = QChartView(Monitor) self.graphicsView.setMinimumSize(QtCore.QSize(761, 481)) self.graphicsView.setObjectName("graphicsView") self.gridLayout_2.addWidget(self.graphicsView, 1, 0, 1, 1) self.gridLayout = QtWidgets.QGridLayout() self.gridLayout.setObjectName("gridLayout") self.label_2 = QtWidgets.QLabel(Monitor) self.label_2.setMinimumSize(QtCore.QSize(91, 30)) self.label_2.setObjectName("label_2") self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1) self.comboBox = QtWidgets.QComboBox(Monitor) self.comboBox.setMinimumSize(QtCore.QSize(91, 30)) self.comboBox.setObjectName("comboBox") self.gridLayout.addWidget(self.comboBox, 0, 1, 1, 1) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem, 0, 2, 1, 1) self.label_3 = QtWidgets.QLabel(Monitor) self.label_3.setMinimumSize(QtCore.QSize(91, 30)) self.label_3.setObjectName("label_3") self.gridLayout.addWidget(self.label_3, 1, 0, 1, 1) self.lineEdit = QtWidgets.QLineEdit(Monitor) self.lineEdit.setMinimumSize(QtCore.QSize(191, 30)) self.lineEdit.setObjectName("lineEdit") self.gridLayout.addWidget(self.lineEdit, 1, 1, 1, 2) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem1, 2, 1, 1, 1) self.label_4 = QtWidgets.QLabel(Monitor) self.label_4.setMinimumSize(QtCore.QSize(301, 161)) self.label_4.setObjectName("label_4") self.gridLayout.addWidget(self.label_4, 3, 0, 1, 3) self.pushButton = QtWidgets.QPushButton(Monitor) self.pushButton.setMinimumSize(QtCore.QSize(91, 41)) self.pushButton.setObjectName("pushButton") self.gridLayout.addWidget(self.pushButton, 4, 0, 1, 1) self.pushButton_2 = QtWidgets.QPushButton(Monitor) self.pushButton_2.setMinimumSize(QtCore.QSize(91, 41)) self.pushButton_2.setObjectName("pushButton_2") self.gridLayout.addWidget(self.pushButton_2, 4, 1, 1, 1) spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem2, 4, 2, 1, 1) self.gridLayout_2.addLayout(self.gridLayout, 1, 1, 1, 1) self.retranslateUi(Monitor) self.comboBox.currentIndexChanged['int'].connect(Monitor.iface_changed) self.lineEdit.returnPressed.connect(Monitor.filter_changed) self.pushButton.clicked.connect(Monitor.start_on_clicked) self.pushButton_2.clicked.connect(Monitor.clear_on_clicked) QtCore.QMetaObject.connectSlotsByName(Monitor)
def __init__(self): self.model = QChart() self.view = QChartView() self.view.setChart(self.model) self.model.legend().setAlignment(Qt.AlignBottom) self.view.setRenderHint(QPainter.Antialiasing)
def init_graph(self): self.graph_chart = QChart(title="售出图") self.graph_chart.legend().setVisible(True) self.graph_chart.setAcceptHoverEvents(True) graph_view = QChartView(self.graph_chart) graph_view.setRenderHint(QPainter.Antialiasing) self.gridLayout_5.addWidget(graph_view)
def __init__(self, parent=None): super(TestWindow, self).__init__(parent=parent) self.ncurves = 0 self.chart = QChart() self.chart.legend().hide() self.view = QChartView(self.chart) self.view.setRenderHint(QPainter.Antialiasing) self.setCentralWidget(self.view)
def __init__(self): super().__init__() self.items = 0 self._data = { 'Phone bill': 50, "Gas": 30, "Rent": 1850, "Car Payment": 420.0 } #=============== left side ====================== self.table = QTableWidget() self.table.setColumnCount(2) self.table.setHorizontalHeaderLabels(('Description', 'price')) self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) #============== Chart widget ================= self.chartView = QChartView() self.chartView.setRenderHint(QPainter.Antialiasing) #=============== layout button and entry ================ self.layoutRight = QVBoxLayout() self.lineEditDescription = QLineEdit() self.lineEditPrice = QLineEdit() self.buttonAdd = QPushButton("Add") self.buttonClear = QPushButton("Clear") self.buttonQuit = QPushButton("Quit") self.buttonPlot = QPushButton("Plot") self.buttonAdd.setEnabled(False) # self.buttonAdd.hide() self.layoutRight.setSpacing(10) self.layoutRight.addWidget(QLabel("Description")) self.layoutRight.addWidget(self.lineEditDescription) self.layoutRight.addWidget(QLabel("Price")) self.layoutRight.addWidget(self.lineEditPrice) self.layoutRight.addWidget(self.buttonAdd) self.layoutRight.addWidget(self.buttonPlot) self.layoutRight.addWidget(self.chartView) self.layoutRight.addWidget(self.buttonClear) self.layoutRight.addWidget(self.buttonQuit) #================= connect function to button ===================== self.buttonAdd.clicked.connect(self.add_entry) self.buttonPlot.clicked.connect(self.graph_chart) self.buttonQuit.clicked.connect(lambda: app.quit()) self.layout = QHBoxLayout() self.layout.addWidget(self.table, 50) self.layout.addLayout(self.layoutRight, 50) # 50% proportional locaction self.setLayout(self.layout) self.lineEditDescription.textChanged[str].connect(self.check_disable) self.lineEditPrice.textChanged[str].connect(self.check_disable) self.fill_table() # upload data into table
def createBar(self): min_num, max_num = 0, 100 linked_bag_list = [] try: df = self.linked['Beam Diff'].dropna() linked_bag_list = df.values.tolist() min_num = int(min(linked_bag_list)) if min_num > 0: # check if greater than 0, set to 0 min_num = 0 max_num = int(max(linked_bag_list)) except AttributeError: self.statusbar.showMessage('Data not ready') count = [0] * (max_num + 1) # choose the largest num as length of count for num in linked_bag_list: count[int(num)] += 1 # update every number's count max_count = max(count) setBar = QBarSet('Beam Difference Occurrence') setBar.append(count) brush = QBrush(QColor(0x57B1FD)) pen = QPen(QColor(0x57B1FD)) pen.setWidth(2) setBar.setPen(pen) setBar.setBrush(brush) series = QBarSeries() series.append(setBar) chart = QChart() chart.setTheme(QChart.ChartThemeBlueIcy) font = QFont() font.setPixelSize(18) chart.setTitleFont(font) chart.setTitle('Linked Bins Histogram') chart.addSeries(series) chart.setAnimationOptions(QChart.SeriesAnimations) axisX = QValueAxis() axisX.setTitleText("Attenuation Window") axisX.setRange(min_num, max_num+20) chart.setAxisX(axisX, series) axisY = QValueAxis() axisY.setTitleText("Frequency") axisY.setRange(0, max_count+20) chart.setAxisY(axisY, series) chart.legend().hide() chartView = QChartView(chart) chartView.setRenderHint(QPainter.Antialiasing) return chartView
def build(self): self.setWindowTitle("Histogram - " + self.name) self.setMinimumSize(400, 300) # Close when ctrl+w is triggered QShortcut(QKeySequence("Ctrl+W"), self, self.close) # 2D array -> 1D array img = self.image.ravel() # Process histogram histogram, bin_edges = np.histogram(img, bins='auto') bar_series = QBarSeries() bar_ = QBarSet("") # Append values for val in histogram: bar_.append(val) pen = bar_.pen() pen.setColor(Qt.black) pen.setWidth(0.1) bar_.setPen(pen) # Append bar to the bar series bar_series.append(bar_) # Chart object chart = QChart() chart.addSeries(bar_series) # Active animation chart.setAnimationOptions(QChart.SeriesAnimations) # Do not show title chart.legend().setVisible(False) # Draw Axes, with [min, max] # Y axis h_max = histogram.max() axis_y = QValueAxis() axis_y.setRange(0, h_max) # X axis be_max = bin_edges.max() be_min = bin_edges.min() axis_x = QValueAxis() axis_x.setRange(be_min, be_max) # Add axis to chart + rendering chart.addAxis(axis_x, Qt.AlignBottom) chart.addAxis(axis_y, Qt.AlignLeft) view = QChartView(chart) view.setRenderHint(QPainter.Antialiasing) self.setCentralWidget(view)
def plot_candlechart(ohlc_data): app = ParaMakerApplication([]) #app.setStyleSheet("background-color:black;") series = QCandlestickSeries() series.setBodyOutlineVisible(False) series.setDecreasingColor(Qt.red) series.setIncreasingColor(Qt.green) rsi = qc.QLineSeries() # 5-days average data line rsi.append(QPointF(ohlc_data[300].timestamp, ohlc_data[300].closed)) rsi.append(QPointF(ohlc_data[700].timestamp, ohlc_data[700].closed)) #rsi.append(QPointF(ohlc_data[150].timestamp, ohlc_data[100].closed)) tm = [] # stores str type data # in a loop, series and rsi append corresponding data for candle in ohlc_data: series.append( QCandlestickSet(candle.opened, candle.high, candle.low, candle.closed)) #rsi.append(QPointF(num, m)) tm.append(str(candle.timestamp)) #rsi.append(str(candle.timestamp)) #rsi_values = calculate_rsi(14, ohlc_data) chart = QChart() chart.setBackgroundVisible(False) chart.setPlotAreaBackgroundVisible(False) chart.addSeries(series) # candle chart.addSeries(rsi) # rsi line #chart.axisX(rsi).setRange(ohlc_data[0].timestamp, ohlc_data[-1].timestamp) chart.createDefaultAxes() axisXRSI = QValueAxis() axisYRSI = QValueAxis() axisXRSI.setRange(ohlc_data[0].timestamp, ohlc_data[-1].timestamp) axisYRSI.setRange(ohlc_data[0].closed, ohlc_data[-1].closed) axisXRSI.setGridLineVisible(False) axisYRSI.setGridLineVisible(False) chart.setAxisX(axisXRSI, rsi) chart.setAxisY(axisYRSI, rsi) chart.legend().hide() chart.axisX(series).setCategories(tm) #chart.axisX(series).setGridLineVisible(False) #chart.axisY(series).setGridLineVisible(False) ###chart.axisX(rsi).setVisible(False) chartview = QChartView(chart) chartview.setRenderHint(QPainter.Antialiasing) ui = ParaMakerWindow() ui.setCentralWidget(chartview) sys.exit(app.exec_())
def build(self): self.setWindowTitle('Emoreco') self.setWindowIcon(QIcon(root + 'Logo.ico')) oImage = QImage(root + "Background.png") palette = QPalette() palette.setBrush(QPalette.Window, QBrush(oImage)) self.setPalette(palette) oImage = QPixmap(root + "Ok.png") palette = QPalette() palette.setBrush(self.OkButton.backgroundRole(), QBrush(oImage)) self.OkButton.setFlat(1) self.OkButton.setAutoFillBackground(1) self.OkButton.setPalette(palette) self.OkButton.clicked.connect(self.closeWindow) set_list = [ QBarSet('Circulatory'), QBarSet('Digestive'), QBarSet('Endocrine'), QBarSet('Integumentary'), QBarSet('Lymphatic'), QBarSet('Muscular'), QBarSet('Nervous'), QBarSet('Excretory'), QBarSet('Reproductive'), QBarSet('Respiratory'), QBarSet('Skeletal') ] categories = [''] series = QBarSeries() chart = QChart() axis = QBarCategoryAxis() for i in range(sys_n): set_list[i].append([dis_prediction[i]]) series.append(set_list[i]) chart.addSeries(series) axis.append(categories) chart.setTitle('Our prediction (%)') chart.createDefaultAxes() chart.setAxisX(axis, series) chart.legend().setAlignment(Qt.AlignLeft) chart.setBackgroundBrush(QColor(61, 56, 63, 0)) chartView = QChartView(chart) chartView.chart().setAnimationOptions(QChart.AllAnimations) base = self.gridLayout base.addWidget(chartView) self.show()
def initialize(self): self.tabWidget.setCurrentIndex(0) self.actionExit.triggered.connect(self.close) self.action_Plot.setEnabled(False) self.actionNext.setIcon( self.style().standardIcon( QtWidgets.QStyle.SP_ArrowForward)) self.actionPrevious.setIcon( self.style().standardIcon( QtWidgets.QStyle.SP_ArrowBack)) self.action_Open.setIcon( self.style().standardIcon( QtWidgets.QStyle.SP_DialogOpenButton)) self.actionSave.setIcon( self.style().standardIcon( QtWidgets.QStyle.SP_DriveFDIcon)) self.actionSave.triggered.connect(self.save) self.action_Open.triggered.connect(self.getOpenFilename) self.actionNext.triggered.connect(self.nextPacket) self.actionPrevious.triggered.connect(self.previousPacket) self.actionAbout.triggered.connect(self.about) self.actionPrevious.setEnabled(False) self.actionNext.setEnabled(False) self.actionSave.setEnabled(False) self.action_Plot.setEnabled(False) self.actionPaste.triggered.connect(self.onPasteTriggered) # self.actionLog.triggered.connect(self.dockWidget_2.show) self.actionSet_IDB.triggered.connect(self.onSetIDBClicked) self.plotButton.clicked.connect(self.onPlotButtonClicked) self.exportButton.clicked.connect(self.onExportButtonClicked) self.action_Plot.triggered.connect(self.onPlotActionClicked) self.actionLoad_mongodb.triggered.connect(self.onLoadMongoDBTriggered) self.mdb=None self.current_row = 0 self.data=[] self.x=[] self.y=[] self.xlabel='x' self.ylabel='y' self.chart = QChart() self.chart.layout().setContentsMargins(0,0,0,0) self.chart.setBackgroundRoundness(0) self.savePlotButton.clicked.connect(self.savePlot) self.chartView = QChartView(self.chart) self.gridLayout.addWidget(self.chartView, 1, 0, 1, 15) # IDB location self.settings = QtCore.QSettings('FHNW', 'stix_parser')
def mouseReleaseEvent(self, event): p1 = event.pos() p2 = self.mapToScene(p1) p3 = self.chart().mapFromScene(p2) p4 = self.chart().mapToValue(p3) if self.chart(): for serie in self.chart().series(): QApplication.postEvent(serie, ReleasePosEvent(p4)) QChartView.mouseReleaseEvent(self, event)
def initUI(self): comboBoxColor = QComboBox() comboBoxColor.addItems([ "Color del fondo del CharView", "Color del fondo del Chart", "Color del título del Chart", "Color de las etiquetas del eje X", "Color de las etiquetas del eje Y", "Color de las etiquetas de la leyenda" ]) checkBoxVisibilidadFondoChart = QCheckBox("Visibilidad fondo (chart)") checkBoxMargenesChart = QCheckBox("Margenes del chart") checkBoxEsquinasChart = QCheckBox("Esquinas del chart") buttonGuardar = QPushButton("Guardar gráfico") # Crear gráficos. self.vistaGrafico = QChartView(self.crearGraficoBarras()) self.vistaGrafico.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) self.vistaGrafico.setRenderHint(QPainter.Antialiasing, True) # ========================== DISEÑO ========================== disenioConfiguracion = QVBoxLayout() disenioConfiguracion.addWidget(QLabel("Cambiar colores:")) disenioConfiguracion.addWidget(comboBoxColor) disenioConfiguracion.addWidget(checkBoxVisibilidadFondoChart) disenioConfiguracion.addWidget(checkBoxMargenesChart) disenioConfiguracion.addWidget(checkBoxEsquinasChart) disenioConfiguracion.setSpacing(4) disenioConfiguracion.addStretch() disenioConfiguracion.addWidget(buttonGuardar) baseDisenio = QGridLayout() baseDisenio.addLayout(disenioConfiguracion, 0, 0, 0, 1) baseDisenio.addWidget(self.vistaGrafico, 0, 1, 0, 4) baseDisenio.setSpacing(10) baseDisenio.setContentsMargins(10, 10, 10, 10) self.setLayout(baseDisenio) # ===================== CONECTAR SEÑALES ===================== comboBoxColor.activated.connect(self.Color) checkBoxVisibilidadFondoChart.toggled.connect( self.visibilidadFondoChart) checkBoxMargenesChart.toggled.connect(self.margenesChart) checkBoxEsquinasChart.toggled.connect(self.esquinasChart) buttonGuardar.clicked.connect(self.Guardar) # Establecer los valores predeterminados comboBoxColor.setCurrentIndex(-1) checkBoxVisibilidadFondoChart.setChecked(True) checkBoxMargenesChart.setChecked(True) checkBoxEsquinasChart.setChecked(True)
def __init__(self, parent=None): super(anaxcelhandler, self).__init__(parent) if getattr(sys, 'frozen', False): self.frozen = 'ever so' self.bundle_dir = sys._MEIPASS else: self.bundle_dir = os.path.dirname(os.path.abspath(__file__)) self.setupUi(self) self.setWindowIcon(QtGui.QIcon(self.bundle_dir + '/icons/icon.png')) self.setStyleSheet(open("Dark/darkstyle.qss", "r").read()) self.listWidget.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection) self.pushButtonbrowse.clicked.connect(self.openFileNamesDialog) self.pushButtonclear.clicked.connect(self.clearwidget) self.pushButtonselall.clicked.connect(self.selectall) self.pushButtonload.clicked.connect(self.LoadProcess) self.statusbar.showMessage('V 0.1') self.actionExit.setShortcut('Ctrl+Q') self.actionExit.triggered.connect(self.close_application) self.actionExit.setStatusTip('Exit ') self.pixmaplab = QPixmap('icons/excel48.png') self.labelicon.setPixmap(self.pixmaplab) self.labelicon.show() self.label.setText("Loaded Excel File") self.comboBoxfiletype.addItems(['xls', ' xlsx']) self.pushButton_5.clicked.connect(self.analyseProcess) self.figure = plt.figure() self.canvas = FigureCanvas(self.figure) self.toolbar = NavigationToolbar(self.canvas, self) layoutx = QVBoxLayout() layoutx.addWidget(self.toolbar) layoutx.addWidget(self.canvas) self.tab_6.setLayout(layoutx) self.layoutdout = QGridLayout() self.tab_4.setLayout(self.layoutdout) self.chartView3 = QChartView() self.layoutdout.addWidget(self.chartView3) self.actionAdd_File.setShortcut('Ctrl+A') self.actionAdd_File.triggered.connect(self.openFileNamesDialog) self.actionAdd_File.setStatusTip('Add File ') self.actionClear.setShortcut('Ctrl+C') self.actionClear.triggered.connect(self.clearwidget) self.actionClear.setStatusTip('Clear ') self.actionSelect_All.setShortcut('Ctrl+S') self.actionSelect_All.triggered.connect(self.selectall) self.actionSelect_All.setStatusTip('Sellect All ') self.actionLoad.setShortcut('Ctrl+L') self.actionLoad.triggered.connect(self.LoadProcess) self.actionLoad.setStatusTip('Load ') self.actionAbout.setShortcut('Ctrl+I') self.actionAbout.triggered.connect(self.showAbout) self.actionAbout.setStatusTip('About ')
def __init__(self): super(GraphicsScene, self).__init__() self.line_series = QLineSeries() self.chart = QChart() self.chart_view = QChartView(self.chart) self.chart_view.setMinimumSize(640, 480) self.model = ItemModel() self.model.signal_update_models.connect(self.update_axes) self.table_view = TableView() self.table_view.setModel(self.model) self.table_view.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.table_view.verticalHeader().setSectionResizeMode( QHeaderView.Stretch) self.chart.setAnimationOptions(QChart.AllAnimations) self.chart.setAnimationDuration(2000) self.line_series.setName("Line 1") self.mapper = QVXYModelMapper(self) self.mapper.setXColumn(0) self.mapper.setYColumn(1) self.mapper.setSeries(self.line_series) self.mapper.setModel(self.model) self.chart.addSeries(self.line_series) seriesColorHex = self.line_series.pen().color().name() self.model.add_mapping(seriesColorHex, QRect(0, 0, 2, self.model.rowCount())) self.line_series2 = QLineSeries() self.line_series2.setName("Line 2") self.mapper2 = QVXYModelMapper(self) self.mapper2.setXColumn(2) self.mapper2.setYColumn(3) self.mapper2.setSeries(self.line_series2) self.mapper2.setModel(self.model) self.chart.addSeries(self.line_series2) seriesColorHex = self.line_series2.pen().color().name() self.model.add_mapping(seriesColorHex, QRect(2, 0, 2, self.model.rowCount())) self.chart.createDefaultAxes() self.chart_view.setRenderHint(QPainter.Antialiasing) self.chart.resize(500, 400) self.chart.setFlag(QGraphicsItem.ItemIsMovable) self.chart.setFlag(QGraphicsItem.ItemIsSelectable) self.addItem(self.chart)
def beforeDelay(self): print("in before delay bar") min_num, max_num = 0, 100 max_count = 0 total_stopped_time = [] try: total_stopped_time = self.tm.total_stopped_time max_num = max(total_stopped_time) except AttributeError: self.statusbar.showMessage('Data not ready') count = total_stopped_time count = [0] * (int(max_num) + 1 ) # choose the largest num as length of count for num in total_stopped_time: count[int(num)] += 1 # update every number's count max_count = max(count) print(len(total_stopped_time), max_count) setBar = QBarSet('stop time') setBar.append(count) brush = QBrush(QColor(0x57B1FD)) pen = QPen(QColor(0x57B1FD)) pen.setWidth(2) setBar.setPen(pen) setBar.setBrush(brush) series = QBarSeries() series.append(setBar) chart = QChart() font = QFont() font.setPixelSize(18) chart.setTitleFont(font) chart.setTitle('Stop time Histogram (before)') chart.addSeries(series) chart.setAnimationOptions(QChart.SeriesAnimations) axisX = QValueAxis() axisX.setRange(min_num, max_num + 20) chart.setAxisX(axisX, series) axisY = QValueAxis() axisY.setRange(0, max_count + 20) chart.setAxisY(axisY, series) chart.legend().setVisible(True) chart.legend().setAlignment(Qt.AlignBottom) chartView = QChartView(chart) chartView.setRenderHint(QPainter.Antialiasing) # MainWindow.setCentralWidget(chartView) return chartView
def mouseMoveEvent(self, event): if event.buttons() == Qt.LeftButton and self.chart(): newValue = self.mapToScene(event.pos()) delta = newValue - self.m_lastMousePos self.chart().scroll(-delta.x(), 0) self.m_lastMousePos = newValue QChartView.mouseMoveEvent(self, event)
def mouseMoveEvent(self, event: QMouseEvent): if event.buttons() & Qt.MiddleButton: dif_pos = event.pos() - self.__last_mouse_pos self.chart().scroll(-dif_pos.x(), dif_pos.y()) event.accept() self.__last_mouse_pos = event.pos() QChartView.mouseMoveEvent(self, event)
def setupgraph(self): self.chart = QChart() self.chart.createDefaultAxes() self.chart.setAnimationOptions(QChart.SeriesAnimations) self.chart.setTitle("Saldo vs Tiempo") self.chart.legend().setVisible(True) self.chart.legend().setAlignment(Qt.AlignBottom) self.chartview = QChartView(self.chart) self.chartview.setRenderHint(QPainter.Antialiasing) self._graphlayout.addWidget(self.chartview)
def __init__(self, data: Dict[str, float], title: str): """Constructor. Args: data (Dict[str, float]): [description] title (str): [description]""" pie_chart: QChart = EquityPieFrame.PieChartView.PieChart( data=data, title=title) QChartView.__init__(self, pie_chart) self.setRenderHint(QPainter.Antialiasing)
def __init__(self, parent=None): super().__init__(parent) self.setWindowTitle("Demo12_1, QChart基本绘图") self.resize(580, 420) #创建chart和chartView chart = QChart() #创建 Chart chart.setTitle("简单函数曲线") chartView = QChartView(self) #创建 ChartView chartView.setChart(chart) #Chart添加到ChartView self.setCentralWidget(chartView) #创建曲线序列 series0 = QLineSeries() series1 = QLineSeries() series0.setName("Sin曲线") series1.setName("Cos曲线") chart.addSeries(series0) #序列添加到图表 chart.addSeries(series1) #序列添加数值 t = 0 intv = 0.1 pointCount = 100 for i in range(pointCount): y1 = math.cos(t) series0.append(t, y1) y2 = 1.5 * math.sin(t + 20) series1.append(t, y2) t = t + intv ##创建坐标轴 axisX = QValueAxis() #X 轴 axisX.setRange(0, 10) #设置坐标轴范围 axisX.setTitleText("time(secs)") #标题 ## axisX.setLabelFormat("%.1f") #标签格式 ## axisX.setTickCount(11) #主分隔个数 ## axisX.setMinorTickCount(4) ## axisX.setGridLineVisible(false) axisY = QValueAxis() #Y 轴 axisY.setRange(-2, 2) axisY.setTitleText("value") ## axisY.setTickCount(5) ## axisY.setMinorTickCount(4) ## axisY.setLabelFormat("%.2f") #标签格式 ## axisY.setGridLineVisible(false) #为序列设置坐标轴 chart.setAxisX(axisX, series0) #为序列设置坐标轴 chart.setAxisY(axisY, series0) chart.setAxisX(axisX, series1) #为序列设置坐标轴 chart.setAxisY(axisY, series1)
class StatsTab(QWidget): 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) def retranslateUi(self): chart = self.chart_view.chart() chart.setTitle( QApplication.translate("StatsTab", "Daily aggregated stats of your school")) @pyqtSlot(QListWidgetItem) def on_stat_clicked(self, item): key = item.data(Qt.UserRole) series = self.seriesmap[key] series.setVisible(not series.isVisible())
def afterDelay(self): # print("in after delay bar") min_num, max_num = 0, 100 max_count = 0 total_stopped_after_delay = [] count = [0] * (int(max_num) + 1) # choose the largest num as length of count try: total_stopped_after_delay = self.tm.total_stopped_after_delay max_num = max(total_stopped_after_delay) count = [0] * (int(max_num) + 1) # choose the largest num as length of count for num in total_stopped_after_delay: count[int(num)] += 1 # update every number's count max_count = max(count) except (AttributeError, ValueError): self.statusbar.showMessage('Data not ready') setBar = QBarSet('Stop Time Occurrence') setBar.append(count) brush = QBrush(QColor(0xA6E22E)) # Green pen = QPen(QColor(0xA6E22E)) # Green pen.setWidth(2) setBar.setPen(pen) setBar.setBrush(brush) series = QBarSeries() series.append(setBar) chart = QChart() font = QFont() font.setPixelSize(18) chart.setTitleFont(font) chart.setTitle('Stop time Occurrence (after)') chart.addSeries(series) chart.setAnimationOptions(QChart.SeriesAnimations) axisX = QValueAxis() axisX.setRange(min_num, max_num+20) chart.setAxisX(axisX, series) axisY = QValueAxis() axisY.setRange(0, max_count+20) chart.setAxisY(axisY, series) chart.legend().setVisible(True) chart.legend().setAlignment(Qt.AlignBottom) chartView = QChartView(chart) chartView.setRenderHint(QPainter.Antialiasing) # MainWindow.setCentralWidget(chartView) return chartView
def __init__(self, parent=None): super(Multitargeting, self).__init__() uic.loadUi('multitargetingwindow.ui', self) self.setWindowIcon(QtGui.QIcon("cas9image.png")) # Storage containers for the repeats and seed sequences self.sq = SeqTranslate() # SeqTranslate object used in class # Initializes the three graphs self.chart_view_chro_bar = QChartView() self.chart_view_repeat_bar = QChartView() self.chart_view_repeat_line = QChartView() self.data = "" self.shortHand = "" self.chromo_length = list() # Listeners for changing the seed sequence or the .cspr file self.max_chromo.currentIndexChanged.connect(self.fill_seed_id_chrom) self.min_chromo.currentIndexChanged.connect(self.fill_seed_id_chrom) self.chromo_seed.currentIndexChanged.connect(self.chro_bar_data) self.Analyze_Button.clicked.connect(self.make_graphs) #go back to main button self.back_button.clicked.connect(self.go_back) #Tool Bar options self.actionCASPER.triggered.connect(self.changeto_main) # Statistics storage variables self.max_repeats = 1 self.average = 0 self.median = 0 self.mode = 0 self.average_unique = 0 self.average_rep = 0 self.bar_coords = [] self.seed_id_seq_pair = {} self.positions = [] #parser object self.parser = CSPRparser("") self.ready_chromo_min_max = True self.ready_chromo_make_graph = True self.directory = 'Cspr files' self.info_path = os.getcwd() ################################## self.scene = QtWidgets.QGraphicsScene() self.graphicsView.setScene(self.scene) self.scene2 = QtWidgets.QGraphicsScene() self.graphicsView_2.setScene(self.scene2) self.graphicsView.viewport().installEventFilter(self)
def __init__(self, device, parent=None): super().__init__(parent) self.ch = ChartObject(devices=device) self.view = QChartView(self.ch.chart) self.view.setRenderHint(QPainter.Antialiasing) layout = QVBoxLayout() layout.addWidget(self.view) self.setLayout(layout) self.resize(500, 800) self.color = Qt.black
def __init__(self): QChartView.__init__(self) self._title = None self._titleFontSize = 14 self._animations = True self._progressDialogEnabled = False self.actionSave = QAction(self.tr("Save as image")) self.actionSave.setIcon(QIcon(":/reusingcode/save.png")) self.setContextMenuPolicy(Qt.CustomContextMenu) self.actionSave.triggered.connect(self.on_actionSave_triggered)
class WindowStatic(QWidget): def __init__(self, window: WindowCinemas = None, title: str = '', base: list = None) -> None: super().__init__() self.title = title self.window = window.static self.base = base self._init_ui() def _init_chart(self) -> None: series = QBarSeries() axis_x = QBarCategoryAxis() axis_y = QValueAxis() data_set = defaultdict(int) for title, money in self.base: data_set[title] += money for title, money in data_set.items(): bar = QBarSet(title) axis_x.append(title) bar.append(money) series.append(bar) # self.chart = QChart() self.chart.addSeries(series) self.chart.setAnimationOptions(QChart.SeriesAnimations) # series.attachAxis(axis_x) self.chart.addAxis(axis_x, Qt.AlignBottom) axis_y.setRange(0, max(data_set.values())) axis_y.setTickCount(11) self.chart.addAxis(axis_y, Qt.AlignLeft) series.attachAxis(axis_y) # self.chart.legend().setVisible(True) self.chart.legend().setAlignment(Qt.AlignBottom) def _init_ui(self) -> None: self.window.resize(1000, 900) self._init_chart() self.chartView = QChartView(self.chart) self.chartView.setRenderHint(QPainter.Antialiasing) self.label_title = QLabel(self.title) # self.label_title.setFont(QFont('MS Shell Dlg 2', 20)) # self.label_title.setAlignment(Qt.AlignHCenter | Qt.AlignHCenter) # self.layout = QVBoxLayout(self, spacing=0) self.layout.setContentsMargins(10, 0, 10, 0) # self.layout.addWidget(self.label_title) self.layout.addWidget(self.chartView)
def __init__(self, parent=None): super(ThemeWidget, self).__init__(parent) self.m_charts = [] self.m_listCount = 3 self.m_valueMax = 10 self.m_valueCount = 7 self.m_dataTable = self.generateRandomData(self.m_listCount, self.m_valueMax, self.m_valueCount) self.m_themeComboBox = self.createThemeBox() self.m_antialiasCheckBox = QCheckBox("Anti-aliasing") self.m_animatedComboBox = self.createAnimationBox() self.m_legendComboBox = self.createLegendBox() self.connectSignals() # Create the layout. baseLayout = QGridLayout() settingsLayout = QHBoxLayout() settingsLayout.addWidget(QLabel("Theme:")) settingsLayout.addWidget(self.m_themeComboBox) settingsLayout.addWidget(QLabel("Animation:")) settingsLayout.addWidget(self.m_animatedComboBox) settingsLayout.addWidget(QLabel("Legend:")) settingsLayout.addWidget(self.m_legendComboBox) settingsLayout.addWidget(self.m_antialiasCheckBox) settingsLayout.addStretch() baseLayout.addLayout(settingsLayout, 0, 0, 1, 3) # Create the charts. chartView = QChartView(self.createAreaChart()) baseLayout.addWidget(chartView, 1, 0) self.m_charts.append(chartView) chartView = QChartView(self.createBarChart(self.m_valueCount)) baseLayout.addWidget(chartView, 1, 1) self.m_charts.append(chartView) chartView = QChartView(self.createLineChart()) baseLayout.addWidget(chartView, 1, 2) self.m_charts.append(chartView) chartView = QChartView(self.createPieChart()) # Funny things happen if the pie slice labels no not fit the screen... chartView.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) baseLayout.addWidget(chartView, 2, 0) self.m_charts.append(chartView) chartView = QChartView(self.createSplineChart()) baseLayout.addWidget(chartView, 2, 1) self.m_charts.append(chartView) chartView = QChartView(self.createScatterChart()) baseLayout.addWidget(chartView, 2, 2) self.m_charts.append(chartView) self.setLayout(baseLayout) # Set the defaults. self.m_antialiasCheckBox.setChecked(True) self.updateUI()