diff options
Diffstat (limited to 'examples/charts/linechart')
-rw-r--r-- | examples/charts/linechart/doc/linechart.png | bin | 0 -> 13485 bytes | |||
-rw-r--r-- | examples/charts/linechart/doc/linechart.rst | 8 | ||||
-rw-r--r-- | examples/charts/linechart/linechart.py | 47 | ||||
-rw-r--r-- | examples/charts/linechart/linechart.pyproject | 3 |
4 files changed, 58 insertions, 0 deletions
diff --git a/examples/charts/linechart/doc/linechart.png b/examples/charts/linechart/doc/linechart.png Binary files differnew file mode 100644 index 000000000..9c32aabd5 --- /dev/null +++ b/examples/charts/linechart/doc/linechart.png diff --git a/examples/charts/linechart/doc/linechart.rst b/examples/charts/linechart/doc/linechart.rst new file mode 100644 index 000000000..b3daea3cf --- /dev/null +++ b/examples/charts/linechart/doc/linechart.rst @@ -0,0 +1,8 @@ +Line Chart Example +================== + +The example shows how to create a simple line chart. + +.. image:: linechart.png + :width: 400 + :alt: Line Chart Screenshot diff --git a/examples/charts/linechart/linechart.py b/examples/charts/linechart/linechart.py new file mode 100644 index 000000000..cee4c16db --- /dev/null +++ b/examples/charts/linechart/linechart.py @@ -0,0 +1,47 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +"""PySide6 port of the linechart example from Qt v5.x""" + +import sys +from PySide6.QtCore import QPointF +from PySide6.QtGui import QPainter +from PySide6.QtWidgets import QMainWindow, QApplication +from PySide6.QtCharts import QChart, QChartView, QLineSeries + + +class TestChart(QMainWindow): + def __init__(self): + super().__init__() + + self.series = QLineSeries() + self.series.append(0, 6) + self.series.append(2, 4) + self.series.append(3, 8) + self.series.append(7, 4) + self.series.append(10, 5) + self.series.append(QPointF(11, 1)) + self.series.append(QPointF(13, 3)) + self.series.append(QPointF(17, 6)) + self.series.append(QPointF(18, 3)) + self.series.append(QPointF(20, 2)) + + self.chart = QChart() + self.chart.legend().hide() + self.chart.addSeries(self.series) + self.chart.createDefaultAxes() + self.chart.setTitle("Simple line chart example") + + self._chart_view = QChartView(self.chart) + self._chart_view.setRenderHint(QPainter.Antialiasing) + + self.setCentralWidget(self._chart_view) + + +if __name__ == "__main__": + app = QApplication(sys.argv) + + window = TestChart() + window.show() + window.resize(440, 300) + sys.exit(app.exec()) diff --git a/examples/charts/linechart/linechart.pyproject b/examples/charts/linechart/linechart.pyproject new file mode 100644 index 000000000..a0b84c285 --- /dev/null +++ b/examples/charts/linechart/linechart.pyproject @@ -0,0 +1,3 @@ +{ + "files": ["linechart.py"] +} |