I am using PySide2.QtCharts in order to get a graph to display.
I have scoured the internet for hours and nobody else appears to have this problem, which means it's either ridiculously obscure, or that I'm missing something painfully obvious.
The data I have displaying in my Graph is centering itself in the graph, and as a result is flowing off the side of the graph so that it is unviewable.
This is currently how it is displaying. The fact that the blue and green columns are going off to the right is fine, it's the fact the orange column is off the top so far that it is unviewable.
This is ideally how I want it to look. The columns are thinner and are actually viewable. The length of the columns in this one are statically placed just for my testing purposes to see if it was actually working or not.
I know what you are thinking, 'well you have a working version - just put the data in that' - the data being inputted in my not working example is taken from a for loop which it iterating over different data, which in theory should not be causing any issues, but evidently it is doing so.
I'm not concerned about the data causing issues if I can fix it after the fact, which is the crux of the question I am asking. Is there any way to set the column width manually, and change the position of where the graphing starts? (for example, the bottom rather than the middle)
My (not working) code:
series = QtCharts.QHorizontalBarSeries()
set = QtCharts.QBarSet(name)
if value != None and value != '0':
set << float(value)
series.append(set)
else:
pass
index_chart = QtCharts.QChart()
index_chart.addSeries(series)
x_axis = QtCharts.QValueAxis()
x_axis.setRange(0, 100)
index_chart.setMaximumHeight(500)
index_chart.createDefaultAxes()
index_chart.setAxisX(x_axis, series)
chartView = QtCharts.QChartView(index_chart)
The working example code:
testseries = QtCharts.QHorizontalBarSeries()
set0 = QtCharts.QBarSet('test')
set1 = QtCharts.QBarSet('test')
set2 = QtCharts.QBarSet('test')
set0 << 50
set1 << 25
set2 << 85
testseries.append(set0)
testseries.append(set1)
testseries.append(set2)
index_chart = QtCharts.QChart()
index_chart.addSeries(testseries)
x_axis = QtCharts.QValueAxis()
x_axis.setRange(0, 100)
index_chart.setMaximumHeight(500)
index_chart.createDefaultAxes()
index_chart.setAxisX(x_axis, series)
chartView = QtCharts.QChartView(index_chart)
There really isn't any difference in how the two are functioning, so this is more if anyone can see a reason why it would be acting the way it is. But, I'm the one having a problem, so I could be wrong. Thanks in advance!