aboutsummaryrefslogtreecommitdiffstats
path: root/examples/charts
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-01-19 08:09:39 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-01-20 10:11:11 +0000
commit76dbc2b4ec6e5c797ab333b176e019e1f9b14ca2 (patch)
tree2a178eac7a6e48245ca50c70c13dd1302c74058f /examples/charts
parent63614c3085fa8105e9f8ced6b2d166c2a7a2c6e6 (diff)
QtCharts: Remove namespace
Adapt to 227020b118fa38ada1d8bd579593dae61f6e3881. Task-number: PYSIDE-904 Task-number: PYSIDE-1482 Change-Id: I9adb78cfe60efd0df73be52132b4ea029986ea18 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/charts')
-rw-r--r--examples/charts/audio.py14
-rw-r--r--examples/charts/donutbreakdown.py29
-rw-r--r--examples/charts/legend.py14
-rw-r--r--examples/charts/lineandbar.py27
-rw-r--r--examples/charts/linechart.py10
-rw-r--r--examples/charts/logvalueaxis.py15
-rw-r--r--examples/charts/memoryusage.py13
-rw-r--r--examples/charts/modeldata.py19
-rw-r--r--examples/charts/nesteddonuts.py13
-rw-r--r--examples/charts/percentbarchart.py25
-rw-r--r--examples/charts/piechart.py10
-rw-r--r--examples/charts/temperaturerecords.py21
12 files changed, 109 insertions, 101 deletions
diff --git a/examples/charts/audio.py b/examples/charts/audio.py
index 6d7b4895a..969f2b9ab 100644
--- a/examples/charts/audio.py
+++ b/examples/charts/audio.py
@@ -1,7 +1,7 @@
#############################################################################
##
-## Copyright (C) 2018 The Qt Company Ltd.
+## Copyright (C) 2021 The Qt Company Ltd.
## Contact: http://www.qt.io/licensing/
##
## This file is part of the Qt for Python examples of the Qt Toolkit.
@@ -42,7 +42,7 @@
"""PySide6 port of the charts/audio example from Qt v5.x"""
import sys
-from PySide6.QtCharts import QtCharts
+from PySide6.QtCharts import QChart, QChartView, QLineSeries, QValueAxis
from PySide6.QtCore import QPointF
from PySide6.QtMultimedia import (QAudioDeviceInfo, QAudioFormat,
QAudioInput)
@@ -55,14 +55,14 @@ class MainWindow(QMainWindow):
def __init__(self, device):
super(MainWindow, self).__init__()
- self.series = QtCharts.QLineSeries()
- self.chart = QtCharts.QChart()
+ self.series = QLineSeries()
+ self.chart = QChart()
self.chart.addSeries(self.series)
- self.axisX = QtCharts.QValueAxis()
+ self.axisX = QValueAxis()
self.axisX.setRange(0, sampleCount)
self.axisX.setLabelFormat("%g")
self.axisX.setTitleText("Samples")
- self.axisY = QtCharts.QValueAxis()
+ self.axisY = QValueAxis()
self.axisY.setRange(-1, 1)
self.axisY.setTitleText("Audio level")
self.chart.setAxisX(self.axisX, self.series)
@@ -82,7 +82,7 @@ class MainWindow(QMainWindow):
self.ioDevice = self.audioInput.start()
self.ioDevice.readyRead.connect(self._readyRead)
- self.chartView = QtCharts.QChartView(self.chart)
+ self.chartView = QChartView(self.chart)
self.setCentralWidget(self.chartView)
self.buffer = [QPointF(x, 0) for x in range(sampleCount)]
diff --git a/examples/charts/donutbreakdown.py b/examples/charts/donutbreakdown.py
index cde318087..4c319c84f 100644
--- a/examples/charts/donutbreakdown.py
+++ b/examples/charts/donutbreakdown.py
@@ -1,6 +1,6 @@
#############################################################################
##
-## Copyright (C) 2018 The Qt Company Ltd.
+## Copyright (C) 2021 The Qt Company Ltd.
## Contact: http://www.qt.io/licensing/
##
## This file is part of the Qt for Python examples of the Qt Toolkit.
@@ -43,11 +43,11 @@
import sys
from PySide6.QtCore import Qt
-from PySide6.QtGui import QColor, QFont, QPainter
+from PySide6.QtGui import QColor, QFont, QPainter, QScreen
from PySide6.QtWidgets import QApplication, QMainWindow
-from PySide6.QtCharts import QtCharts
+from PySide6.QtCharts import QChart, QChartView, QPieSeries, QPieSlice
-class MainSlice(QtCharts.QPieSlice):
+class MainSlice(QPieSlice):
def __init__(self, breakdown_series, parent=None):
super(MainSlice, self).__init__(parent)
@@ -70,10 +70,11 @@ class MainSlice(QtCharts.QPieSlice):
self.percentage() * 100))
-class DonutBreakdownChart(QtCharts.QChart):
+class DonutBreakdownChart(QChart):
def __init__(self, parent=None):
- super(DonutBreakdownChart, self).__init__(QtCharts.QChart.ChartTypeCartesian, parent, Qt.WindowFlags())
- self.main_series = QtCharts.QPieSeries()
+ super(DonutBreakdownChart, self).__init__(QChart.ChartTypeCartesian,
+ parent, Qt.WindowFlags())
+ self.main_series = QPieSeries()
self.main_series.setPieSize(0.7)
self.addSeries(self.main_series)
@@ -90,7 +91,7 @@ class DonutBreakdownChart(QtCharts.QChart):
main_slice.setBrush(color)
main_slice.setLabelVisible()
main_slice.setLabelColor(Qt.white)
- main_slice.setLabelPosition(QtCharts.QPieSlice.LabelInsideHorizontal)
+ main_slice.setLabelPosition(QPieSlice.LabelInsideHorizontal)
main_slice.setLabelFont(font)
# position and customize the breakdown series
@@ -142,27 +143,27 @@ if __name__ == "__main__":
# 'Total consumption of energy increased by 10 per cent in 2010'
# Statistics Finland, 13 December 2011
# http://www.stat.fi/til/ekul/2010/ekul_2010_2011-12-13_tie_001_en.html
- series1 = QtCharts.QPieSeries()
+ series1 = QPieSeries()
series1.setName("Fossil fuels")
series1.append("Oil", 353295)
series1.append("Coal", 188500)
series1.append("Natural gas", 148680)
series1.append("Peat", 94545)
- series2 = QtCharts.QPieSeries()
+ series2 = QPieSeries()
series2.setName("Renewables")
series2.append("Wood fuels", 319663)
series2.append("Hydro power", 45875)
series2.append("Wind power", 1060)
- series3 = QtCharts.QPieSeries()
+ series3 = QPieSeries()
series3.setName("Others")
series3.append("Nuclear energy", 238789)
series3.append("Import energy", 37802)
series3.append("Other", 32441)
donut_breakdown = DonutBreakdownChart()
- donut_breakdown.setAnimationOptions(QtCharts.QChart.AllAnimations)
+ donut_breakdown.setAnimationOptions(QChart.AllAnimations)
donut_breakdown.setTitle("Total consumption of energy in Finland 2010")
donut_breakdown.legend().setAlignment(Qt.AlignRight)
donut_breakdown.add_breakdown_series(series1, Qt.red)
@@ -170,10 +171,10 @@ if __name__ == "__main__":
donut_breakdown.add_breakdown_series(series3, Qt.darkBlue)
window = QMainWindow()
- chart_view = QtCharts.QChartView(donut_breakdown)
+ chart_view = QChartView(donut_breakdown)
chart_view.setRenderHint(QPainter.Antialiasing)
window.setCentralWidget(chart_view)
- available_geometry = app.desktop().availableGeometry(window)
+ available_geometry = window.screen().availableGeometry()
size = available_geometry.height() * 0.75
window.resize(size, size * 0.8)
window.show()
diff --git a/examples/charts/legend.py b/examples/charts/legend.py
index b833ccedd..71fd94885 100644
--- a/examples/charts/legend.py
+++ b/examples/charts/legend.py
@@ -1,6 +1,6 @@
#############################################################################
##
-## Copyright (C) 2018 The Qt Company Ltd.
+## Copyright (C) 2021 The Qt Company Ltd.
## Contact: http://www.qt.io/licensing/
##
## This file is part of the Qt for Python examples of the Qt Toolkit.
@@ -45,13 +45,13 @@ from PySide6.QtCore import Qt, QRectF
from PySide6.QtGui import QBrush, QColor, QPainter, QPen
from PySide6.QtWidgets import (QApplication, QDoubleSpinBox,
QFormLayout, QGridLayout, QGroupBox, QPushButton, QWidget)
-from PySide6.QtCharts import QtCharts
+from PySide6.QtCharts import QBarSeries, QBarSet, QChart, QChartView
class MainWidget(QWidget):
def __init__(self, parent=None):
super(MainWidget, self).__init__(parent)
- self.chart = QtCharts.QChart()
- self.series = QtCharts.QBarSeries()
+ self.chart = QChart()
+ self.series = QBarSeries()
self.main_layout = QGridLayout()
self.button_layout = QGridLayout()
@@ -105,7 +105,7 @@ class MainWidget(QWidget):
self.legend_settings.setVisible(False)
# Create chart view with the chart
- self.chart_view = QtCharts.QChartView(self.chart, self)
+ self.chart_view = QChartView(self.chart, self)
# Create spinbox to modify font size
self.font_size.setValue(self.chart.legend().font().pointSizeF())
@@ -177,7 +177,7 @@ class MainWidget(QWidget):
def add_barset(self):
series_count = self.series.count()
- bar_set = QtCharts.QBarSet("set {}".format(series_count))
+ bar_set = QBarSet(f"set {series_count}")
delta = series_count * 0.1
bar_set.append([1 + delta, 2 + delta, 3 + delta, 4 + delta])
self.series.append(bar_set)
@@ -245,7 +245,7 @@ class MainWidget(QWidget):
if __name__ == "__main__":
app = QApplication(sys.argv)
w = MainWidget()
- available_geometry = app.desktop().availableGeometry(w)
+ available_geometry = w.screen().availableGeometry()
size = available_geometry.height() * 0.75
w.setFixedSize(size, size)
w.show()
diff --git a/examples/charts/lineandbar.py b/examples/charts/lineandbar.py
index e06298e63..219da17b5 100644
--- a/examples/charts/lineandbar.py
+++ b/examples/charts/lineandbar.py
@@ -1,7 +1,7 @@
#############################################################################
##
-## Copyright (C) 2018 The Qt Company Ltd.
+## Copyright (C) 2021 The Qt Company Ltd.
## Contact: http://www.qt.io/licensing/
##
## This file is part of the Qt for Python examples of the Qt Toolkit.
@@ -45,18 +45,19 @@ import sys
from PySide6.QtCore import QPoint, Qt
from PySide6.QtGui import QPainter
from PySide6.QtWidgets import QMainWindow, QApplication
-from PySide6.QtCharts import QtCharts
+from PySide6.QtCharts import (QBarCategoryAxis, QBarSeries, QBarSet, QChart,
+ QChartView, QLineSeries, QValueAxis)
class TestChart(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
- self.set0 = QtCharts.QBarSet("Jane")
- self.set1 = QtCharts.QBarSet("John")
- self.set2 = QtCharts.QBarSet("Axel")
- self.set3 = QtCharts.QBarSet("Mary")
- self.set4 = QtCharts.QBarSet("Sam")
+ self.set0 = QBarSet("Jane")
+ self.set1 = QBarSet("John")
+ self.set2 = QBarSet("Axel")
+ self.set3 = QBarSet("Mary")
+ self.set4 = QBarSet("Sam")
self.set0.append([1, 2, 3, 4, 5, 6])
self.set1.append([5, 0, 0, 4, 0, 7])
@@ -64,14 +65,14 @@ class TestChart(QMainWindow):
self.set3.append([5, 6, 7, 3, 4, 5])
self.set4.append([9, 7, 5, 3, 1, 2])
- self.barSeries = QtCharts.QBarSeries()
+ self.barSeries = QBarSeries()
self.barSeries.append(self.set0)
self.barSeries.append(self.set1)
self.barSeries.append(self.set2)
self.barSeries.append(self.set3)
self.barSeries.append(self.set4)
- self.lineSeries = QtCharts.QLineSeries()
+ self.lineSeries = QLineSeries()
self.lineSeries.setName("trend")
self.lineSeries.append(QPoint(0, 4))
self.lineSeries.append(QPoint(1, 15))
@@ -80,19 +81,19 @@ class TestChart(QMainWindow):
self.lineSeries.append(QPoint(4, 12))
self.lineSeries.append(QPoint(5, 17))
- self.chart = QtCharts.QChart()
+ self.chart = QChart()
self.chart.addSeries(self.barSeries)
self.chart.addSeries(self.lineSeries)
self.chart.setTitle("Line and barchart example")
self.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
- self.axisX = QtCharts.QBarCategoryAxis()
+ self.axisX = QBarCategoryAxis()
self.axisX.append(self.categories)
self.chart.setAxisX(self.axisX, self.lineSeries)
self.chart.setAxisX(self.axisX, self.barSeries)
self.axisX.setRange("Jan", "Jun")
- self.axisY = QtCharts.QValueAxis()
+ self.axisY = QValueAxis()
self.chart.setAxisY(self.axisY, self.lineSeries)
self.chart.setAxisY(self.axisY, self.barSeries)
self.axisY.setRange(0, 20)
@@ -100,7 +101,7 @@ class TestChart(QMainWindow):
self.chart.legend().setVisible(True)
self.chart.legend().setAlignment(Qt.AlignBottom)
- self.chartView = QtCharts.QChartView(self.chart)
+ self.chartView = QChartView(self.chart)
self.chartView.setRenderHint(QPainter.Antialiasing)
self.setCentralWidget(self.chartView)
diff --git a/examples/charts/linechart.py b/examples/charts/linechart.py
index 7a3e15f60..84cd0c8b3 100644
--- a/examples/charts/linechart.py
+++ b/examples/charts/linechart.py
@@ -1,6 +1,6 @@
#############################################################################
##
-## Copyright (C) 2020 The Qt Company Ltd.
+## Copyright (C) 2021 The Qt Company Ltd.
## Contact: http://www.qt.io/licensing/
##
## This file is part of the Qt for Python examples of the Qt Toolkit.
@@ -44,14 +44,14 @@ import sys
from PySide6.QtCore import QPointF
from PySide6.QtGui import QPainter
from PySide6.QtWidgets import QMainWindow, QApplication
-from PySide6.QtCharts import QtCharts
+from PySide6.QtCharts import QChart, QChartView, QLineSeries
class TestChart(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
- self.series = QtCharts.QLineSeries()
+ self.series = QLineSeries()
self.series.append(0, 6)
self.series.append(2, 4)
self.series.append(3, 8)
@@ -63,13 +63,13 @@ class TestChart(QMainWindow):
self.series.append(QPointF(18, 3))
self.series.append(QPointF(20, 2))
- self.chart = QtCharts.QChart()
+ self.chart = QChart()
self.chart.legend().hide()
self.chart.addSeries(self.series)
self.chart.createDefaultAxes()
self.chart.setTitle("Simple line chart example")
- self.chartView = QtCharts.QChartView(self.chart)
+ self.chartView = QChartView(self.chart)
self.chartView.setRenderHint(QPainter.Antialiasing)
self.setCentralWidget(self.chartView)
diff --git a/examples/charts/logvalueaxis.py b/examples/charts/logvalueaxis.py
index 37558ecb7..c5e90c584 100644
--- a/examples/charts/logvalueaxis.py
+++ b/examples/charts/logvalueaxis.py
@@ -1,6 +1,6 @@
#############################################################################
##
-## Copyright (C) 2020 The Qt Company Ltd.
+## Copyright (C) 2021 The Qt Company Ltd.
## Contact: http://www.qt.io/licensing/
##
## This file is part of the Qt for Python examples of the Qt Toolkit.
@@ -46,31 +46,32 @@ import sys
from PySide6.QtCore import Qt, QPointF
from PySide6.QtGui import QPainter
from PySide6.QtWidgets import QMainWindow, QApplication
-from PySide6.QtCharts import QtCharts
+from PySide6.QtCharts import (QChart, QChartView, QLineSeries, QLogValueAxis,
+ QValueAxis)
class TestChart(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
- self.series = QtCharts.QLineSeries()
+ self.series = QLineSeries()
self.series.append([
QPointF(1.0, 1.0), QPointF(2.0, 73.0), QPointF(3.0, 268.0),
QPointF(4.0, 17.0), QPointF(5.0, 4325.0), QPointF(6.0, 723.0)])
- self.chart = QtCharts.QChart()
+ self.chart = QChart()
self.chart.addSeries(self.series)
self.chart.legend().hide()
self.chart.setTitle("Logarithmic axis example")
- self.axisX = QtCharts.QValueAxis()
+ self.axisX = QValueAxis()
self.axisX.setTitleText("Data point")
self.axisX.setLabelFormat("%i")
self.axisX.setTickCount(self.series.count())
self.chart.addAxis(self.axisX, Qt.AlignBottom)
self.series.attachAxis(self.axisX)
- self.axisY = QtCharts.QLogValueAxis()
+ self.axisY = QLogValueAxis()
self.axisY.setTitleText("Values")
self.axisY.setLabelFormat("%g")
self.axisY.setBase(8.0)
@@ -78,7 +79,7 @@ class TestChart(QMainWindow):
self.chart.addAxis(self.axisY, Qt.AlignLeft)
self.series.attachAxis(self.axisY)
- self.chartView = QtCharts.QChartView(self.chart)
+ self.chartView = QChartView(self.chart)
self.chartView.setRenderHint(QPainter.Antialiasing)
self.setCentralWidget(self.chartView)
diff --git a/examples/charts/memoryusage.py b/examples/charts/memoryusage.py
index 9d7a99311..a6c536de5 100644
--- a/examples/charts/memoryusage.py
+++ b/examples/charts/memoryusage.py
@@ -1,7 +1,7 @@
#############################################################################
##
-## Copyright (C) 2017 The Qt Company Ltd.
+## Copyright (C) 2021 The Qt Company Ltd.
## Contact: http://www.qt.io/licensing/
##
## This file is part of the Qt for Python examples of the Qt Toolkit.
@@ -45,7 +45,8 @@ import os
import sys
from PySide6.QtCore import QProcess
from PySide6.QtWidgets import QApplication, QMainWindow
-from PySide6.QtCharts import QtCharts
+from PySide6.QtCharts import QChart, QChartView, QPieSeries
+
def runProcess(command, arguments):
process = QProcess()
@@ -103,22 +104,22 @@ class MainWindow(QMainWindow):
if len(memoryUsage) > 5:
memoryUsage = memoryUsage[0:4]
- self.series = QtCharts.QPieSeries()
+ self.series = QPieSeries()
for item in memoryUsage:
self.series.append(item[0], item[1])
slice = self.series.slices()[0]
slice.setExploded()
slice.setLabelVisible()
- self.chart = QtCharts.QChart()
+ self.chart = QChart()
self.chart.addSeries(self.series)
- self.chartView = QtCharts.QChartView(self.chart)
+ self.chartView = QChartView(self.chart)
self.setCentralWidget(self.chartView)
if __name__ == '__main__':
app = QApplication(sys.argv)
mainWin = MainWindow()
- availableGeometry = app.desktop().availableGeometry(mainWin)
+ availableGeometry = mainWin.screen().availableGeometry()
size = availableGeometry.height() * 3 / 4
mainWin.resize(size, size)
mainWin.show()
diff --git a/examples/charts/modeldata.py b/examples/charts/modeldata.py
index 739b73d63..1d10190f4 100644
--- a/examples/charts/modeldata.py
+++ b/examples/charts/modeldata.py
@@ -1,7 +1,7 @@
#############################################################################
##
-## Copyright (C) 2018 The Qt Company Ltd.
+## Copyright (C) 2021 The Qt Company Ltd.
## Contact: http://www.qt.io/licensing/
##
## This file is part of the Qt for Python examples of the Qt Toolkit.
@@ -48,7 +48,8 @@ from PySide6.QtCore import QAbstractTableModel, QModelIndex, QRect, Qt
from PySide6.QtGui import QColor, QPainter
from PySide6.QtWidgets import (QApplication, QGridLayout, QHeaderView,
QTableView, QWidget)
-from PySide6.QtCharts import QtCharts
+from PySide6.QtCharts import QChart, QChartView, QLineSeries, QVXYModelMapper
+
class CustomTableModel(QAbstractTableModel):
def __init__(self):
@@ -127,12 +128,12 @@ class TableWidget(QWidget):
self.table_view.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.table_view.verticalHeader().setSectionResizeMode(QHeaderView.Stretch)
- self.chart = QtCharts.QChart()
- self.chart.setAnimationOptions(QtCharts.QChart.AllAnimations)
+ self.chart = QChart()
+ self.chart.setAnimationOptions(QChart.AllAnimations)
- self.series = QtCharts.QLineSeries()
+ self.series = QLineSeries()
self.series.setName("Line 1")
- self.mapper = QtCharts.QVXYModelMapper(self)
+ self.mapper = QVXYModelMapper(self)
self.mapper.setXColumn(0)
self.mapper.setYColumn(1)
self.mapper.setSeries(self.series)
@@ -147,10 +148,10 @@ class TableWidget(QWidget):
self.model.add_mapping(seriesColorHex, QRect(0, 0, 2, self.model.rowCount()))
# series 2
- self.series = QtCharts.QLineSeries()
+ self.series = QLineSeries()
self.series.setName("Line 2")
- self.mapper = QtCharts.QVXYModelMapper(self)
+ self.mapper = QVXYModelMapper(self)
self.mapper.setXColumn(2)
self.mapper.setYColumn(3)
self.mapper.setSeries(self.series)
@@ -162,7 +163,7 @@ class TableWidget(QWidget):
self.model.add_mapping(seriesColorHex, QRect(2, 0, 2, self.model.rowCount()))
self.chart.createDefaultAxes()
- self.chart_view = QtCharts.QChartView(self.chart)
+ self.chart_view = QChartView(self.chart)
self.chart_view.setRenderHint(QPainter.Antialiasing)
self.chart_view.setMinimumSize(640, 480)
diff --git a/examples/charts/nesteddonuts.py b/examples/charts/nesteddonuts.py
index 09c77d022..9005980a2 100644
--- a/examples/charts/nesteddonuts.py
+++ b/examples/charts/nesteddonuts.py
@@ -46,7 +46,8 @@ import sys
from PySide6.QtCore import Qt, QTimer
from PySide6.QtGui import QPainter
from PySide6.QtWidgets import QApplication, QGridLayout, QWidget
-from PySide6.QtCharts import QtCharts
+from PySide6.QtCharts import QChart, QChartView, QPieSeries, QPieSlice
+
from random import randrange
from functools import partial
@@ -56,12 +57,12 @@ class Widget(QWidget):
QWidget.__init__(self)
self.setMinimumSize(800, 600)
self.donuts = []
- self.chart_view = QtCharts.QChartView()
+ self.chart_view = QChartView()
self.chart_view.setRenderHint(QPainter.Antialiasing)
self.chart = self.chart_view.chart()
self.chart.legend().setVisible(False)
self.chart.setTitle("Nested donuts demo")
- self.chart.setAnimationOptions(QtCharts.QChart.AllAnimations)
+ self.chart.setAnimationOptions(QChart.AllAnimations)
self.min_size = 0.1
self.max_size = 0.9
@@ -80,15 +81,15 @@ class Widget(QWidget):
def setup_donuts(self):
for i in range(self.donut_count):
- donut = QtCharts.QPieSeries()
+ donut = QPieSeries()
slccount = randrange(3, 6)
for j in range(slccount):
value = randrange(100, 200)
- slc = QtCharts.QPieSlice(str(value), value)
+ slc = QPieSlice(str(value), value)
slc.setLabelVisible(True)
slc.setLabelColor(Qt.white)
- slc.setLabelPosition(QtCharts.QPieSlice.LabelInsideTangential)
+ slc.setLabelPosition(QPieSlice.LabelInsideTangential)
# Connection using an extra parameter for the slot
slc.hovered[bool].connect(partial(self.explode_slice, slc=slc))
diff --git a/examples/charts/percentbarchart.py b/examples/charts/percentbarchart.py
index a70cae7cf..b9301f36e 100644
--- a/examples/charts/percentbarchart.py
+++ b/examples/charts/percentbarchart.py
@@ -1,7 +1,7 @@
#############################################################################
##
-## Copyright (C) 2018 The Qt Company Ltd.
+## Copyright (C) 2021 The Qt Company Ltd.
## Contact: http://www.qt.io/licensing/
##
## This file is part of the Qt for Python examples of the Qt Toolkit.
@@ -45,17 +45,18 @@ import sys
from PySide6.QtCore import Qt
from PySide6.QtGui import QPainter
from PySide6.QtWidgets import (QMainWindow, QApplication)
-from PySide6.QtCharts import QtCharts
+from PySide6.QtCharts import (QBarCategoryAxis, QBarSet, QChart, QChartView,
+ QPercentBarSeries)
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
- set0 = QtCharts.QBarSet("Jane")
- set1 = QtCharts.QBarSet("John")
- set2 = QtCharts.QBarSet("Axel")
- set3 = QtCharts.QBarSet("Mary")
- set4 = QtCharts.QBarSet("Samantha")
+ set0 = QBarSet("Jane")
+ set1 = QBarSet("John")
+ set2 = QBarSet("Axel")
+ set3 = QBarSet("Mary")
+ set4 = QBarSet("Samantha")
set0.append([1, 2, 3, 4, 5, 6])
set1.append([5, 0, 0, 4, 0, 7])
@@ -63,20 +64,20 @@ class MainWindow(QMainWindow):
set3.append([5, 6, 7, 3, 4, 5])
set4.append([9, 7, 5, 3, 1, 2])
- series = QtCharts.QPercentBarSeries()
+ series = QPercentBarSeries()
series.append(set0)
series.append(set1)
series.append(set2)
series.append(set3)
series.append(set4)
- chart = QtCharts.QChart()
+ chart = QChart()
chart.addSeries(series)
chart.setTitle("Simple percentbarchart example")
- chart.setAnimationOptions(QtCharts.QChart.SeriesAnimations)
+ chart.setAnimationOptions(QChart.SeriesAnimations)
categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
- axis = QtCharts.QBarCategoryAxis()
+ axis = QBarCategoryAxis()
axis.append(categories)
chart.createDefaultAxes()
chart.setAxisX(axis, series)
@@ -84,7 +85,7 @@ class MainWindow(QMainWindow):
chart.legend().setVisible(True)
chart.legend().setAlignment(Qt.AlignBottom)
- chart_view = QtCharts.QChartView(chart)
+ chart_view = QChartView(chart)
chart_view.setRenderHint(QPainter.Antialiasing)
self.setCentralWidget(chart_view)
diff --git a/examples/charts/piechart.py b/examples/charts/piechart.py
index e1131d96e..29947263d 100644
--- a/examples/charts/piechart.py
+++ b/examples/charts/piechart.py
@@ -1,6 +1,6 @@
#############################################################################
##
-## Copyright (C) 2020 The Qt Company Ltd.
+## Copyright (C) 2021 The Qt Company Ltd.
## Contact: http://www.qt.io/licensing/
##
## This file is part of the Qt for Python examples of the Qt Toolkit.
@@ -44,7 +44,7 @@ import sys
from PySide6.QtCore import Qt
from PySide6.QtGui import QPainter, QPen
from PySide6.QtWidgets import QMainWindow, QApplication
-from PySide6.QtCharts import QtCharts
+from PySide6.QtCharts import QChart, QChartView, QPieSeries
class TestChart(QMainWindow):
@@ -52,7 +52,7 @@ class TestChart(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
- self.series = QtCharts.QPieSeries()
+ self.series = QPieSeries()
self.series.append('Jane', 1)
self.series.append('Joe', 2)
@@ -66,12 +66,12 @@ class TestChart(QMainWindow):
self.slice.setPen(QPen(Qt.darkGreen, 2))
self.slice.setBrush(Qt.green)
- self.chart = QtCharts.QChart()
+ self.chart = QChart()
self.chart.addSeries(self.series)
self.chart.setTitle('Simple piechart example')
self.chart.legend().hide()
- self.chartView = QtCharts.QChartView(self.chart)
+ self.chartView = QChartView(self.chart)
self.chartView.setRenderHint(QPainter.Antialiasing)
self.setCentralWidget(self.chartView)
diff --git a/examples/charts/temperaturerecords.py b/examples/charts/temperaturerecords.py
index 9c2cad1df..3a8a86f42 100644
--- a/examples/charts/temperaturerecords.py
+++ b/examples/charts/temperaturerecords.py
@@ -1,6 +1,6 @@
#############################################################################
##
-## Copyright (C) 2020 The Qt Company Ltd.
+## Copyright (C) 2021 The Qt Company Ltd.
## Contact: http://www.qt.io/licensing/
##
## This file is part of the Qt for Python examples of the Qt Toolkit.
@@ -44,35 +44,36 @@ import sys
from PySide6.QtCore import Qt
from PySide6.QtGui import QPainter
from PySide6.QtWidgets import QMainWindow, QApplication
-from PySide6.QtCharts import QtCharts
+from PySide6.QtCharts import (QBarCategoryAxis, QBarSet, QChart, QChartView,
+ QStackedBarSeries, QValueAxis)
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
- low = QtCharts.QBarSet("Min")
- high = QtCharts.QBarSet("Max")
+ low = QBarSet("Min")
+ high = QBarSet("Max")
low.append([-52, -50, -45.3, -37.0, -25.6, -8.0,
-6.0, -11.8, -19.7, -32.8, -43.0, -48.0])
high.append([11.9, 12.8, 18.5, 26.5, 32.0, 34.8,
38.2, 34.8, 29.8, 20.4, 15.1, 11.8])
- series = QtCharts.QStackedBarSeries()
+ series = QStackedBarSeries()
series.append(low)
series.append(high)
- chart = QtCharts.QChart()
+ chart = QChart()
chart.addSeries(series)
chart.setTitle("Temperature records in celcius")
- chart.setAnimationOptions(QtCharts.QChart.SeriesAnimations)
+ chart.setAnimationOptions(QChart.SeriesAnimations)
categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct", "Nov", "Dec"]
- axisX = QtCharts.QBarCategoryAxis()
+ axisX = QBarCategoryAxis()
axisX.append(categories)
axisX.setTitleText("Month")
chart.addAxis(axisX, Qt.AlignBottom)
- axisY = QtCharts.QValueAxis()
+ axisY = QValueAxis()
axisY.setRange(-52, 52)
axisY.setTitleText("Temperature [&deg;C]")
chart.addAxis(axisY, Qt.AlignLeft)
@@ -82,7 +83,7 @@ class MainWindow(QMainWindow):
chart.legend().setVisible(True)
chart.legend().setAlignment(Qt.AlignBottom)
- chart_view = QtCharts.QChartView(chart)
+ chart_view = QChartView(chart)
chart_view.setRenderHint(QPainter.Antialiasing)
self.setCentralWidget(chart_view)