def __iniChart(self): #图表初始化 self.chart = QPolarChart() ##极坐标图 self.chart.legend().setVisible(False) self.ui.chartView.setChart(self.chart) self.ui.chartView.setRenderHint(QPainter.Antialiasing) self.ui.chartView.setCursor(Qt.CrossCursor) self.__axisAngle = QValueAxis() #角度坐标轴 self.__axisAngle.setRange(0, 360) #角度范围 self.__axisAngle.setLabelFormat("NE %.0f") self.__axisAngle.setTickCount(9) self.chart.addAxis(self.__axisAngle, QPolarChart.PolarOrientationAngular) self.__axisRadial = QValueAxis() #径向坐标轴 self.__axisRadial.setTickCount(6) self.__axisRadial.setLabelFormat("%.1f") #标签格式 self.chart.addAxis(self.__axisRadial, QPolarChart.PolarOrientationRadial) pen = QPen(Qt.blue) pen.setWidth(2) seriesSpLine = QSplineSeries() seriesSpLine.setPen(pen) seriesSpLine.setPointsVisible(True) #数据点可见 seriesSpLine.hovered.connect(self.do_series_hovered) self.chart.addSeries(seriesSpLine) seriesSpLine.attachAxis(self.__axisAngle) seriesSpLine.attachAxis(self.__axisRadial)
class DynamicSpline(QChart): def __init__(self): super().__init__() self.m_step = 0 self.m_x = 2 self.m_y = 1 # Инициализировать изображение self.series = QSplineSeries(self) red_pen = QPen(Qt.red) red_pen.setWidth(2) self.series.setPen(red_pen) self.axisX = QValueAxis() self.axisY = QValueAxis() self.series.append(self.m_x, self.m_y) self.addSeries(self.series) self.addAxis(self.axisX, Qt.AlignBottom) self.addAxis(self.axisY, Qt.AlignLeft) self.series.attachAxis(self.axisX) self.series.attachAxis(self.axisY) self.axisX.setTickCount(5) self.axisX.setRange(0, 10) self.axisY.setRange(0, 100) self.timer = QTimer(self) self.timer.setInterval(1000) self.timer.timeout.connect(self.handleTimeout) self.timer.start() def handleTimeout(self): x = self.plotArea().width() / self.axisX.tickCount() y = (self.axisX.max() - self.axisX.min()) / self.axisX.tickCount() self.m_x += y # В PyQt 5.11.3 и выше, QRandomGenerator.global() был переименован в global_() try: self.m_y=db_wrk() except : self.m_y = QRandomGenerator.global_().bounded(50) self.series.append(self.m_x, self.m_y) self.scroll(x, 0) if self.m_x >= 10: self.timer.stop() def db_wrk(): return m_y
class CpuLineChart(QChart): def __init__(self, *args, **kwargs): super(CpuLineChart, self).__init__(*args, **kwargs) self.m_count = 10 # 隐藏图例 self.legend().hide() self.m_series = QSplineSeries(self) # 设置画笔 self.m_series.setPen(QPen(QColor('#3B8CFF'), 2, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)) self.addSeries(self.m_series) # x轴 self.m_axisX = QDateTimeAxis(self) self.m_axisX.setTickCount(self.m_count + 1) # 设置刻度数量 self.m_axisX.setFormat('hh:mm:ss') # 设置时间显示格式 now = QDateTime.currentDateTime() # 前10秒到现在 self.m_axisX.setRange(now.addSecs(-self.m_count), now) self.addAxis(self.m_axisX, Qt.AlignBottom) self.m_series.attachAxis(self.m_axisX) # y轴 self.m_axisY = QValueAxis(self) self.m_axisY.setLabelFormat('%d') # 设置文本格式 self.m_axisY.setMinorTickCount(4) # 设置小刻度线的数目 self.m_axisY.setTickCount(self.m_count + 1) self.m_axisY.setRange(0, 100) self.addAxis(self.m_axisY, Qt.AlignLeft) self.m_series.attachAxis(self.m_axisY) # 填充11个初始点,注意x轴 需要转为秒的时间戳 self.m_series.append( [QPointF(now.addSecs(-i).toMSecsSinceEpoch(), 0) for i in range(self.m_count, -1, -1)]) # 定时器获取数据 self.m_timer = QTimer() self.m_timer.timeout.connect(self.update_data) self.m_timer.start(1000) def update_data(self): value = cpu_percent() now = QDateTime.currentDateTime() self.m_axisX.setRange(now.addSecs(-self.m_count), now) # 重新调整x轴的时间范围 # 获取原来的所有点,去掉第一个并追加新的一个 points = self.m_series.pointsVector() points.pop(0) points.append(QPointF(now.toMSecsSinceEpoch(), value)) # 替换法速度更快 self.m_series.replace(points)
class Chart(QChart): def __init__(self): super(QChart, self).__init__() self.m_timer = QTimer() self.m_series = None self.m_titles = [] self.m_axis = QValueAxis() self.m_step = None self.m_x = 5 self.m_y = 1 random.seed(QTime.currentTime().msec()) self.m_timer.timeout.connect(self.handleTimeout) self.m_timer.setInterval(1000) self.m_series = QSplineSeries(self) green = QPen(Qt.green) green.setWidth(3) self.m_series.setPen(green) self.m_series.append(self.m_x, self.m_y) self.addSeries(self.m_series) self.createDefaultAxes() self.setAxisX(self.m_axis, self.m_series) self.m_axis.setTickCount(5) self.axisX().setRange(0, 10) self.axisY().setRange(-5, 10) self.m_timer.start() @pyqtSlot() def handleTimeout(self): x = self.plotArea().width() / self.m_axis.tickCount() y = (self.m_axis.max() - self.m_axis.min()) / self.m_axis.tickCount() self.m_x += y self.m_y = random.randint(0, 5) - 2.5 self.m_series.append(self.m_x, self.m_y) self.scroll(x, 0) if self.m_x is 100: self.m_timer.stop()
class DynamicSpline(QChart): def __init__(self): super().__init__() self.m_step = 0 self.m_x = 5 self.m_y = 1 # 初始化图像 self.series = QSplineSeries(self) green_pen = QPen(Qt.red) green_pen.setWidth(3) self.series.setPen(green_pen) self.axisX = QValueAxis() self.axisY = QValueAxis() self.series.append(self.m_x, self.m_y) self.addSeries(self.series) self.addAxis(self.axisX, Qt.AlignBottom) self.addAxis(self.axisY, Qt.AlignLeft) self.series.attachAxis(self.axisX) self.series.attachAxis(self.axisY) self.axisX.setTickCount(5) self.axisX.setRange(0, 10) self.axisY.setRange(-5, 10) self.timer = QTimer(self) self.timer.setInterval(1000) self.timer.timeout.connect(self.handleTimeout) self.timer.start() def handleTimeout(self): x = self.plotArea().width() / self.axisX.tickCount() y = (self.axisX.max() - self.axisX.min()) / self.axisX.tickCount() self.m_x += y # 在PyQt5.11.3及以上版本中,QRandomGenerator.global()被重命名为global_() self.m_y = QRandomGenerator.global_().bounded(5) - 2.5 self.series.append(self.m_x, self.m_y) self.scroll(x, 0) if self.m_x >= 100: self.timer.stop()
def __createChart(self): ##创建图表 chart = QChart() #创建 Chart ## chart.setTitle("简单函数曲线") chart.legend().setVisible(True) self.chartView.setChart(chart) #Chart添加到chartView pen=QPen() pen.setWidth(2) ##========LineSeries折线 和 ScatterSeries散点 seriesLine = QLineSeries() seriesLine.setName("LineSeries折线") seriesLine.setPointsVisible(False) #数据点不可见 pen.setColor(Qt.red) seriesLine.setPen(pen) seriesLine.hovered.connect(self.do_series_hovered) #信号 hovered seriesLine.clicked.connect(self.do_series_clicked) #信号 clicked chart.addSeries(seriesLine) #添加到chart seriesLinePoint = QScatterSeries() #散点序列 seriesLinePoint.setName("ScatterSeries散点") shape=QScatterSeries.MarkerShapeCircle #MarkerShapeRectangle seriesLinePoint.setMarkerShape(shape) #散点形状,只有2种 seriesLinePoint.setBorderColor(Qt.yellow) seriesLinePoint.setBrush(QBrush(Qt.red)) seriesLinePoint.setMarkerSize(10) #散点大小 seriesLinePoint.hovered.connect(self.do_series_hovered) #信号 hovered seriesLinePoint.clicked.connect(self.do_series_clicked) #信号 clicked chart.addSeries(seriesLinePoint) #添加到chart ##======== SplineSeries 曲线和 QScatterSeries 散点 seriesSpLine = QSplineSeries() seriesSpLine.setName("SplineSeries曲线") seriesSpLine.setPointsVisible(False) #数据点不可见 pen.setColor(Qt.blue) seriesSpLine.setPen(pen) seriesSpLine.hovered.connect(self.do_series_hovered) #信号 hovered seriesSpLine.clicked.connect(self.do_series_clicked) #信号 clicked seriesSpPoint = QScatterSeries() #散点序列 seriesSpPoint.setName("QScatterSeries") shape=QScatterSeries.MarkerShapeRectangle #MarkerShapeCircle seriesSpPoint.setMarkerShape(shape) #散点形状,只有2种 seriesSpPoint.setBorderColor(Qt.green) seriesSpPoint.setBrush(QBrush(Qt.blue)) seriesSpPoint.setMarkerSize(10) #散点大小 seriesSpPoint.hovered.connect(self.do_series_hovered) #信号 hovered seriesSpPoint.clicked.connect(self.do_series_clicked) #信号 clicked chart.addSeries(seriesSpLine) chart.addSeries(seriesSpPoint) ## 创建缺省坐标轴 chart.createDefaultAxes() #创建缺省坐标轴并与序列关联 chart.axisX().setTitleText("time(secs)") chart.axisX().setRange(0,10) chart.axisX().applyNiceNumbers() chart.axisY().setTitleText("value") chart.axisY().setRange(-2,2) chart.axisY().applyNiceNumbers() for marker in chart.legend().markers(): #QLegendMarker类型列表 marker.clicked.connect(self.do_LegendMarkerClicked)
class TotalEquityChartView(QChartView): """ Chart that displays the balance between several dates from an account, token or whole portfolio """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.chart = QChart() def setupChartWithData(self, data, linecolor='#422F8A'): """ Chart gets updated displaying the new data. Data has to be expressed on a dictionary form: - keys are timestamps - values are total balance for that timestamp """ self.chart = QChart() self.chart.setTheme(QChart.ChartThemeDark) self.chart.setAnimationOptions(QChart.SeriesAnimations) self.chart.setBackgroundBrush(QBrush(QColor("transparent"))) # self.chart.setTitle("") # self.chart.setTitleBrush(QBrush(QColor('white'))) # Axis X (Dates) self.x_axis = QDateTimeAxis() self.x_axis.setTickCount(11) self.x_axis.setLabelsAngle(70) font = QFont() font.setFamily('Roboto') font.setLetterSpacing(QFont.PercentageSpacing, 110) font.setPointSize(8) self.x_axis.setLabelsFont(font) self.x_axis.setFormat("dd-MM-yy") self.x_axis.setTitleText(self.tr('Date')) self.x_axis.setTitleVisible(False) self.x_axis.setLineVisible(False) self.x_axis.setGridLineVisible(False) # Axis Y (Balances) self.y_axis = QValueAxis() if data != {}: self.y_axis.setMax(max(data.values()) * 1.05) self.y_axis.setMin(min(data.values()) * 0.95) # self.y_axis.setMinorGridLineVisible(False) self.y_axis.setLineVisible(False) self.y_axis.setGridLineColor(QColor("#ECE9F1")) self.chart.addAxis(self.y_axis, Qt.AlignLeft) self.chart.addAxis(self.x_axis, Qt.AlignBottom) # Series self.btcseries = QSplineSeries() for date in data: balance = data[date] date = QDateTime(datetime.fromtimestamp(int(float(date)))) self.btcseries.append(date.toMSecsSinceEpoch(), balance) self.btcseries.setName("BTC") pen = QPen(QColor(linecolor)) pen.setWidth(3) self.btcseries.setPen(pen) # Series functionality self.btcseries.hovered.connect(self.selectPoint) self.chart.addSeries(self.btcseries) self.btcseries.attachAxis(self.x_axis) self.btcseries.attachAxis(self.y_axis) self.setChart(self.chart) self.setRenderHint(QPainter.Antialiasing) self.setStyleSheet("border: 0px; background-color: rgba(0,0,0,0); ") self.chart.legend().hide() def selectPoint(self, point, state): """ Shows point where mouse is hovered """ self.chart.setTitle( f"{int(point.y())} {confighandler.get_fiat_currency().upper()}")
class Example(QMainWindow): def __init__(self, ): super().__init__() self.bijiao = [0, 0, 0] self.res = "" self.queue = [] self.k = -1 self.flag = -1 try: self.initUI() self.chart_init(10) except: traceback.print_exc() def initUI(self): icon = QtGui.QIcon() icon.addPixmap( QtGui.QPixmap("D:\\Sysytem\\Desktop\\zhong\\data\\ico.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.setWindowIcon(icon) self.resize(1000, 700) self.setWindowTitle('Icon') self.setObjectName("清华大学得不到的学生") self.setWindowTitle("一枚小乖乖~") self.label = QLabel(self) self.label.setWindowTitle("清华大学得不到的学生") self.setWindowFlags(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground) self.label.setGeometry(QtCore.QRect(15, 15, 970, self.height() - 30)) self.label.setText("") palette = QtGui.QPalette() self.label.setStyleSheet("background-color: #fff;border-radius: 15px;") self.labelshadow = QGraphicsDropShadowEffect(self) self.labelshadow.setBlurRadius(15) self.labelshadow.setOffset(1, 1) self.label.setGraphicsEffect(self.labelshadow) self.label.setScaledContents(True) self.label.setObjectName("label") self.pushButton_12 = QtWidgets.QPushButton(self) self.pushButton_12.setGeometry( QtCore.QRect(self.width() - 55, 29, 20, 20)) self.pushButton_12.setStyleSheet( "QPushButton{\n" " background:#fc625d;\n" " color:white;\n" " box-shadow: 1px 1px 3px rgba(0,0,0,0.3);font-size:20px;border-radius: 10px;font-family: 微软雅黑;\n" "}\n" "QPushButton:hover{ \n" " background:#FF2D2D;\n" "}\n" "QPushButton:pressed{\n" " border: 1px solid #3C3C3C!important;\n" " background:#AE0000;\n" "}") self.pushButton_12.clicked.connect(self.close) self.pushButton_14 = QtWidgets.QPushButton(self) self.pushButton_14.setGeometry( QtCore.QRect(self.width() - 55 - 35, 29, 20, 20)) self.pushButton_14.setStyleSheet( "QPushButton{\n" " background:#35cd4b;\n" " color:white;\n" " box-shadow: 1px 1px 3px rgba(0,0,0,0.3);font-size:20px;border-radius: 10px;font-family: 微软雅黑;\n" "}\n" "QPushButton:hover{ \n" " background:#00CC00;\n" "}\n" "QPushButton:pressed{\n" " border: 1px solid #3C3C3C!important;\n" " background:#009900;\n" "}") self.pushButton_14.clicked.connect(self.showMinimized) self.color = ["#e89291", "#c4b98b", "#81a8e1", "#8cc9c4", "#83bde2"] # -----------------------------------------------------------------测试数量------------------------ error = QtWidgets.QLineEdit(self) error.setGeometry(QtCore.QRect(70, 70, 150, 50)) error.setStyleSheet( "text-align: center;background-color: " + self.color[0] + ";border-radius: 7px;border: 0px solid #000;color:#ffffff;font-size:20px;font-family: 微软雅黑;" ) errorshadow = QGraphicsDropShadowEffect(self) error.setPlaceholderText("测试数量") errorshadow.setBlurRadius(30) cl = QColor("#cacaca") errorshadow.setColor(cl) error.setAlignment(Qt.AlignCenter) errorshadow.setOffset(0, 0) error.textChanged.connect(self.set_suliang) # error.setGraphicsEffect(errorshadow) # -----------------------------------------------------------------随机范围------------------------ fan = QtWidgets.QLineEdit(self) fan.setGeometry(QtCore.QRect(240, 70, 150, 50)) fan.setStyleSheet( "text-align: center;background-color: " + self.color[2] + ";border-radius: 7px;border: 0px solid #000;color:#ffffff;font-size:20px;font-family: 微软雅黑;" ) fanshadow = QGraphicsDropShadowEffect(self) fanshadow.setBlurRadius(30) fancl = QColor("#cacaca") fan.setPlaceholderText("随机范围") fanshadow.setColor(fancl) fan.setAlignment(Qt.AlignCenter) fanshadow.setOffset(0, 0) fan.textChanged.connect(self.set_fanwei) # fan.setGraphicsEffect(fanshadow) # -----------------------------------------------------------------内存块数----------------------- kuai = QtWidgets.QLineEdit(self) kuai.setGeometry(QtCore.QRect(410, 70, 150, 50)) kuai.setStyleSheet( "text-align: center;background-color: " + self.color[3] + ";border-radius: 7px;border: 0px solid #000;color:#ffffff;font-size:20px;font-family: 微软雅黑;" ) kuaishadow = QGraphicsDropShadowEffect(self) kuaishadow.setBlurRadius(30) kuaicl = QColor("#cacaca") kuai.setPlaceholderText("内存块数") kuaishadow.setColor(kuaicl) kuai.setAlignment(Qt.AlignCenter) kuaishadow.setOffset(0, 0) kuai.textChanged.connect(self.set_kuai) # kuai.setGraphicsEffect(kuaishadow) self.Button = QtWidgets.QPushButton(self) self.Button.setGeometry(QtCore.QRect(580, 70, 150, 50)) self.Button.setStyleSheet( "QPushButton{text-align: center;background-color: #83bde2;" "border-radius: 7px;border: 0px solid #000;color:#ffffff;" "font-size:20px;font-family: 微软雅黑;}" + "QPushButton:hover{ " + " background-color: #9ad0d0;color: white;" + "}") Buttonshadow = QGraphicsDropShadowEffect(self) Buttonshadow.setBlurRadius(30) Buttoncl = QColor("#cacaca") self.Button.setText("执行") Buttonshadow.setColor(Buttoncl) Buttonshadow.setOffset(0, 0) # Button.setGraphicsEffect(Buttonshadow) self.Button.clicked.connect(self.on_click_start) self.avgflag = 0 self.qq = QtWidgets.QPushButton(self) self.qq.setGeometry(QtCore.QRect(750, 70, 180, 50)) self.qq.setStyleSheet( "color: #000;text-align: center;background-color: #f0f0f0;border-radius: 7px;border: 0px solid #000;font-size:14px;font-family: 微软雅黑;" ) self.qq.clicked.connect(self.on_avg) self.show() def on_avg(self): if self.avgflag == 0: self.series.hide() self.serieslru.hide() self.seriesopt.hide() self.seriesfifoavg.show() self.serieslruavg.show() self.seriesoptavg.show() self.avgflag = 1 else: self.series.show() self.serieslru.show() self.seriesopt.show() self.seriesfifoavg.hide() self.serieslruavg.hide() self.seriesoptavg.hide() self.avgflag = 0 def set_kuai(self, text): self.kuai = text def set_fanwei(self, text): self.fan = text def set_suliang(self, text): self.su = text def hideerror(self): self.error.hide() def set_kuaishu(self, text): self.kuaishu = text def set_yemian(self, text): self.yemian = text def retranslateUi(self, Form): _translate = QtCore.QCoreApplication.translate def mousePressEvent(self, e): if e.button() == Qt.LeftButton: self.m_drag = True self.m_DragPosition = e.globalPos() - self.pos() e.accept() def mouseReleaseEvent(self, e): if e.button() == Qt.LeftButton: self.m_drag = False def mouseMoveEvent(self, e): try: if Qt.LeftButton and self.m_drag: self.move(e.globalPos() - self.m_DragPosition) e.accept() except: print("错误代码:000x0") def on_click_start(self): try: self.jishu = 0 self.thread = MyThread() self.thread.set_su(self.su) self.thread.set_kuai(self.kuai) self.thread.set_x(self.dtaxisX) self.thread.set_fan(self.fan) self.thread.det_bijiao(self.bijiao) self.dailist = [] self.avg = [] self.avg1 = [] self.avg2 = [] self.dailistlru = [] self.dailistopt = [] self.thread.sinOut.connect(self.change) self.thread.start() # self.qq.setText("FIFO:%0.2f LRU:%0.2f \n OPT:%0.2f" % (self.bijiao[0], self.bijiao[1], self.bijiao[2])) except: traceback.print_exc() # self.sinOut.emit(self.dailist) # self.sinOut2.emit(self.dailistlru) # self.sinOut3.emit(self.dailistopt) def change(self, dailist): try: # print(dailist) # arr = str.split(dailist) # print(arr) flag = 0 start = 0 flag = dailist.find(" ", flag) flag = dailist.find(" ", flag + 1) end = flag arr = str.split(dailist[start:end]) start = flag flag = dailist.find(" ", flag + 1) flag = dailist.find(" ", flag + 1) end = flag arr1 = str.split(dailist[start:end]) start = flag flag = dailist.find(" ", flag + 1) flag = dailist.find(" ", flag + 1) end = flag arr2 = str.split(dailist[start:end]) self.dailist.append(QPointF(float(arr[0]), float(arr[1]))) self.dailistlru.append(QPointF(float(arr1[0]), float(arr1[1]))) self.dailistopt.append(QPointF(float(arr2[0]), float(arr2[1]))) # self.series.replace(self.dailist) self.serieslru.replace(self.dailistlru) self.seriesopt.replace(self.dailistopt) if self.jishu == 0: self.bijiao[0] = float(arr[1]) self.bijiao[1] = float(arr1[1]) self.bijiao[2] = float(arr2[1]) self.jishu = 1 else: self.bijiao[0] = (float(arr[1]) + self.bijiao[0]) / 2.0 self.bijiao[1] = (float(arr1[1]) + self.bijiao[1]) / 2.0 self.bijiao[2] = (float(arr2[1]) + self.bijiao[2]) / 2.0 self.jishu = self.jishu + 1 self.avg.append(QPointF(float(arr[0]), self.bijiao[0])) self.avg1.append(QPointF(float(arr[0]), self.bijiao[1])) self.avg2.append(QPointF(float(arr[0]), self.bijiao[2])) # print(self.avg) self.seriesfifoavg.replace(self.avg) self.serieslruavg.replace(self.avg1) self.seriesoptavg.replace(self.avg2) self.qq.setText("FIFO:%0.2f LRU:%0.2f \n OPT:%0.2f" % (self.bijiao[0], self.bijiao[1], self.bijiao[2])) except: traceback.print_exc() def drawLine(self): self.series.replace(self.dailist) # print("uiy") def chart_init(self, su): self.start_num = 0 self.chart = QChartView(self) self.chart.setGeometry(50, 150, self.width() - 100, self.height() - 150 - 50) # 设置charView位置、大小 self.series = QSplineSeries() self.series.setName("FIFO") self.chart.chart().addSeries(self.series) pen = QPen(Qt.gray) pen.setWidth(2) self.serieslru = QSplineSeries() self.serieslru.setPen(pen) self.serieslru.setName("LRU") self.serieslru.setColor(QColor("#e89291")) self.chart.chart().addSeries(self.serieslru) pen2 = QPen(Qt.gray) pen2.setWidth(2) self.seriesopt = QSplineSeries() self.seriesopt.setPen(pen2) self.seriesopt.setColor(QColor("#3ea54f")) self.seriesopt.setName("OPT") self.chart.chart().addSeries(self.seriesopt) penfifo = QPen(Qt.gray) penfifo.setWidth(2) self.seriesfifoavg = QSplineSeries() self.seriesfifoavg.setPen(penfifo) self.seriesfifoavg.setName("FIFO-avg") self.seriesfifoavg.setColor(QColor("#209fdf")) self.chart.chart().addSeries(self.seriesfifoavg) self.seriesfifoavg.hide() penavg = QPen(Qt.gray) penavg.setWidth(2) self.serieslruavg = QSplineSeries() self.serieslruavg.setPen(penavg) self.serieslruavg.setName("LRU-avg") self.serieslruavg.setColor(QColor("#e89291")) self.chart.chart().addSeries(self.serieslruavg) self.serieslruavg.hide() pen2avg = QPen(Qt.gray) pen2avg.setWidth(2) self.seriesoptavg = QSplineSeries() self.seriesoptavg.setPen(pen2avg) self.seriesoptavg.setColor(QColor("#3ea54f")) self.seriesoptavg.setName("OPT-avg") self.chart.chart().addSeries(self.seriesoptavg) self.seriesoptavg.hide() self.dtaxisX = QValueAxis() self.vlaxisY = QValueAxis() self.dtaxisX.setMin(10) self.dtaxisX.setMax(100) self.vlaxisY.setMin(0) self.vlaxisY.setMax(100) self.dtaxisX.setTickCount(6) self.vlaxisY.setTickCount(11) self.dtaxisX.setTitleText("页数") self.vlaxisY.setTitleText("缺页率") self.vlaxisY.setGridLineVisible(False) self.chart.chart().addAxis(self.dtaxisX, Qt.AlignBottom) self.chart.chart().addAxis(self.vlaxisY, Qt.AlignLeft) self.series.attachAxis(self.dtaxisX) self.series.attachAxis(self.vlaxisY) self.serieslru.attachAxis(self.dtaxisX) self.serieslru.attachAxis(self.vlaxisY) self.seriesopt.attachAxis(self.dtaxisX) self.seriesopt.attachAxis(self.vlaxisY) self.seriesoptavg.attachAxis(self.dtaxisX) self.seriesoptavg.attachAxis(self.vlaxisY) self.serieslruavg.attachAxis(self.dtaxisX) self.serieslruavg.attachAxis(self.vlaxisY) self.seriesfifoavg.attachAxis(self.dtaxisX) self.seriesfifoavg.attachAxis(self.vlaxisY) self.chart.chart().setTitleBrush(QBrush(Qt.cyan)) cc = QColor("#f0f0f0") self.chart.setBackgroundBrush(cc) self.chart.setStyleSheet( "QChartView{ background-color: #83bde2;border-radius: 20px;}") self.chart.show()