Unsolved PyQtCharts QAreaSeries. Nothing Show's up.
-
In a Qt Designer UI I have a widget and promoted it to
Class Name: QChartView
Header File: PyQt5.QtChart.hIm testing out all the series on QtCharts and run into a problem.
I'm trying to make a QAreaSeries but when I execute nothing in the widget shows up. All I can see is a box with a color (which is probably the legend)
Here's my current code:
upperSeries = QLineSeries() lowerSeries = QLineSeries() for i in range(3): rand = random.randint(1, 10) upperSeries.append(i, rand) lowerSeries.append(i, rand) series = QAreaSeries(upperSeries) chart = QChart() chart.addSeries(series) self.view.setChart(chart) # View is the widget I made in the UI File.
-
@Qt-Bot05
If you are saying that is really your actual code, what isseries
, what is in it, there is no relationship between that and theupper
/lowerSeries
you populate? -
@JonB Sorry I forgot to copy paste the QAreaSeries part
-
I'm trying to make a QAreaSeries but when I execute nothing in the widget shows up
I have never used Qt charts. But isn't the idea of a
QAreaSeries
to show a "colored region" betweenlowerSeries()
&upperSeries()
? Yet because you use the same random number for the Y coordinate for both, (assuming that's what you do from your series variables) doesn't that mean there will no "area" to fill? What happens if you replace your use ofrand
with, say,1
inlowerSeries
and10
inupperSeries
? -
@JonB I tried simplifying the code and still nothing shows up.
up = QLineSeries() up.append(0, 10) down = QLineSeries() down.append(5, 50) series = QAreaSeries(up, down) chart = QChart() chart.addSeries(series) self.view.setChart(chart)
-
@Qt-Bot05
Well, it seems to me you're using Y values the wrong way round forupperSeries
andlowerSeries
! But I think the docs imply that doesn't actually matter, though you might want to verify by swapping. Also, you're testing with just 2 points, it's an area series so why would you test with less than 4? What are you expecting to see? Anyway, your issue is probably something else.Have you checked it works for you for other than
QAreaSeries
?