QChart,如何隐藏网格和数值?我只需要显示这条线

问题描述 投票:0回答:1

如何隐藏网格和数值?我只需要显示该行 enter image description here

class myChard(QChartView):
    def __init__(self):
        super().__init__()
        self.resize(300, 300)
        self.setRenderHint(QPainter.Antialiasing)
        chart = QChart()
        self.setChart(chart)
        chart.setTitle('Simple splinechart example')
        self.getSeries(chart)
        chart.createDefaultAxes()
        chart.legend().setVisible(0)
    
    def getSeries(self, chart):
        series = QSplineSeries(chart)
        series.append([QPointF(1,1),QPointF(3,1),QPointF(999,1)])
        chart.addSeries(series)

class Window(QWidget):
    def __init__(self):
        super().__init__()
        muChart=myChard()
        layout2 = QVBoxLayout()
        layout2.addWidget(muChart)
        self.setLayout(layout2)
        self.setWindowTitle("Border Layout")

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(app.exec())

只需显示线条即可

pyqt qchart qchartview
1个回答
0
投票

就我而言:

from PyQt6.QtGui import *
from PyQt6.QtWidgets import *
from PyQt6.QtCharts import *
from PyQt6.QtCore import *


def set_candle_sticks(chartview, symbol):

    chart = QChart()
    chart.setAnimationOptions(QChart.AnimationOption.AllAnimations)
    chart.setDropShadowEnabled(True)
    chart.setBackgroundVisible(False)
    chart.legend().hide()


    # part of the code is hidden
        
    chart.addSeries(market_series)

    chart.createDefaultAxes()

    chart.axes(Qt.Orientation.Horizontal)[0].setGridLineVisible(False)
    chart.axes(Qt.Orientation.Vertical)[0].setGridLineVisible(False)

    chartview.setChart(chart)

    return chartview
© www.soinside.com 2019 - 2024. All rights reserved.