QChart , How can I hide the grid and the numerical values? I only need to show the line

57 views Asked by At

How can I hide the grid and the numerical values? I only need to show the line 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())

only need to show the line

1

There are 1 answers

0
HriPit On

In my case:

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