Candlestick is not showing without data
Unsolved
Qt for Python
-
Hello i am new to using Qt5,
I'm trying to make a candlestick chart but can't get my data on the chart, can someone tell me what I'm doing wrong?Dataset:
Date,Open,High,Low,Close,Adj Close,Volume
2020-01-01,7194.892090,7254.330566,7174.944336,7200.174316,7200.174316,18565664997
more data ...def create_candle_chart(self, symbol): series = QtCharts.QCandlestickSeries() series.setIncreasingColor(Qt.green) series.setDecreasingColor(Qt.red) with open('ETH-USD-29_SEP_2021-10_NOV_2021.csv', 'r') as csvFile: csvReader = csv.reader(csvFile, delimiter=",") horizontal_list = list() for row in csvReader: set = QtCharts.QCandlestickSet() horizontal_list.append(row[0]) set.open = float(row[1]) set.high = float(row[2]) set.low = float(row[3]) set.close = float(row[4]) series.append(set) candleChart = QtCharts.QChart() candleChart.addSeries(series) candleChart.createDefaultAxes() candleChart.setTitle('Candlestick') candleChart.setAnimationOptions(QtCharts.QChart.AllAnimations) candleChart.setTheme(QtCharts.QChart.ChartThemeDark) candleChart.axisX(series).setCategories(horizontal_list) candleChart.setVisible(True) chart_view = QtCharts.QChartView(candleChart) self.ui.candleChart.addWidget(chart_view)
this is what i get:
-
Hi and welcome to devnet,
What happens if you use the setter of each property ?
On a side note,
set
is a Python keyword, you should either use a more relevant variable name or useset_
to avoid replacing the originalset
type.