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())
只需显示线条即可
就我而言:
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