[PyQt] PyQt Chart Documentation
Nick
napperley at gmail.com
Thu Aug 25 11:34:16 BST 2016
Did the trick, thanks.
On Thu, 25 Aug 2016 at 22:25 Phil Thompson <phil at riverbankcomputing.com>
wrote:
>
> > On 25 Aug 2016, at 10:17 am, Nick <napperley at gmail.com> wrote:
> >
> > Thanks! Realised that there was an extra "s" that needed to be removed
> at the end of the import. Got the Bar chart example working based on the
> one in the Qt C++ documentation. However the axis legend doesn't appear.
> Below is the function that creates the QChart which is used in the
> QChartView:
> >
> > ===================================================
> > def create_bar_chart(self):
> > set0 = QBarSet('Jane')
> > set1 = QBarSet('John')
> > series = QBarSeries()
> > chart = QChart()
> > axis = QBarCategoryAxis()
> > categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
> >
> > set0.append([1, 2, 3, 4, 5, 6])
> > set1.append([5, 0, 0, 4, 0, 7])
> > series.append(set0)
> > series.append(set1)
> > chart.addSeries(series)
> > axis.append(categories)
> >
> > chart.setTitle('Simple barchart example')
> > chart.createDefaultAxes()
> > chart.setAxisX(axis, series)
> > chart.legend().setAlignment(Qt.AlignBottom)
> > return chart
> > ===================================================
>
> It's an ownership bug in PyQtChart. To work around do...
>
> axis = QBarCategoryAxis(chart)
>
> Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160825/bd621170/attachment.html>
More information about the PyQt
mailing list