diff options
Diffstat (limited to 'examples/charts')
-rw-r--r-- | examples/charts/callout/callout.py | 42 | ||||
-rw-r--r-- | examples/charts/chartthemes/main.py | 5 | ||||
-rw-r--r-- | examples/charts/legend/legend.py | 6 | ||||
-rw-r--r-- | examples/charts/percentbarchart/percentbarchart.py | 8 | ||||
-rw-r--r-- | examples/charts/pointconfiguration/chartwindow.py | 8 | ||||
-rw-r--r-- | examples/charts/pointselectionandmarkers/pointselectionandmarkers.py | 11 |
6 files changed, 41 insertions, 39 deletions
diff --git a/examples/charts/callout/callout.py b/examples/charts/callout/callout.py index 3de00b8df..59a1c3fad 100644 --- a/examples/charts/callout/callout.py +++ b/examples/charts/callout/callout.py @@ -4,8 +4,8 @@ """PySide6 port of the Callout example from Qt v5.x""" import sys -from PySide6.QtWidgets import (QApplication, QGraphicsScene, - QGraphicsView, QGraphicsSimpleTextItem, QGraphicsItem) +from PySide6.QtWidgets import (QApplication, QGraphicsScene, QGraphicsView, + QGraphicsSimpleTextItem, QGraphicsItem) from PySide6.QtCore import Qt, QPointF, QRectF, QRect from PySide6.QtCharts import QChart, QLineSeries, QSplineSeries from PySide6.QtGui import QPainter, QFont, QFontMetrics, QPainterPath, QColor @@ -42,37 +42,37 @@ class Callout(QGraphicsItem): # establish the position of the anchor point in relation to _rect above = anchor.y() <= self._rect.top() - above_center = (anchor.y() > self._rect.top() and - anchor.y() <= self._rect.center().y()) - below_center = (anchor.y() > self._rect.center().y() and - anchor.y() <= self._rect.bottom()) + above_center = (anchor.y() > self._rect.top() + and anchor.y() <= self._rect.center().y()) + below_center = (anchor.y() > self._rect.center().y() + and anchor.y() <= self._rect.bottom()) below = anchor.y() > self._rect.bottom() on_left = anchor.x() <= self._rect.left() - left_of_center = (anchor.x() > self._rect.left() and - anchor.x() <= self._rect.center().x()) - right_of_center = (anchor.x() > self._rect.center().x() and - anchor.x() <= self._rect.right()) + left_of_center = (anchor.x() > self._rect.left() + and anchor.x() <= self._rect.center().x()) + right_of_center = (anchor.x() > self._rect.center().x() + and anchor.x() <= self._rect.right()) on_right = anchor.x() > self._rect.right() # get the nearest _rect corner. x = (on_right + right_of_center) * self._rect.width() y = (below + below_center) * self._rect.height() - corner_case = ((above and on_left) or (above and on_right) or - (below and on_left) or (below and on_right)) + corner_case = ((above and on_left) or (above and on_right) + or (below and on_left) or (below and on_right)) vertical = abs(anchor.x() - x) > abs(anchor.y() - y) - x1 = (x + left_of_center * 10 - right_of_center * 20 + corner_case * - int(not vertical) * (on_left * 10 - on_right * 20)) - y1 = (y + above_center * 10 - below_center * 20 + corner_case * - vertical * (above * 10 - below * 20)) + x1 = (x + left_of_center * 10 - right_of_center * 20 + corner_case + * int(not vertical) * (on_left * 10 - on_right * 20)) + y1 = (y + above_center * 10 - below_center * 20 + corner_case + * vertical * (above * 10 - below * 20)) point1.setX(x1) point1.setY(y1) - x2 = (x + left_of_center * 20 - right_of_center * 10 + corner_case * - int(not vertical) * (on_left * 20 - on_right * 10)) - y2 = (y + above_center * 20 - below_center * 10 + corner_case * - vertical * (above * 20 - below * 10)) + x2 = (x + left_of_center * 20 - right_of_center * 10 + corner_case + * int(not vertical) * (on_left * 20 - on_right * 10)) + y2 = (y + above_center * 20 - below_center * 10 + corner_case + * vertical * (above * 20 - below * 10)) point2.setX(x2) point2.setY(y2) @@ -127,7 +127,7 @@ class View(QGraphicsView): self._chart = QChart() self._chart.setMinimumSize(640, 480) self._chart.setTitle("Hover the line to show callout. Click the line " - "to make it stay") + "to make it stay") self._chart.legend().hide() self.series = QLineSeries() self.series.append(1, 3) diff --git a/examples/charts/chartthemes/main.py b/examples/charts/chartthemes/main.py index 3a058804d..3ea7b629d 100644 --- a/examples/charts/chartthemes/main.py +++ b/examples/charts/chartthemes/main.py @@ -27,7 +27,7 @@ class ThemeWidget(QWidget): self.value_max = 10 self.value_count = 7 self.data_table = self.generate_random_data(self.list_count, - self.value_max, self.value_count) + self.value_max, self.value_count) self.ui.setupUi(self) self.populate_themebox() @@ -41,8 +41,7 @@ class ThemeWidget(QWidget): # Pie Chart chart_view = QChartView(self.create_pie_chart()) - chart_view.setSizePolicy(QSizePolicy.Ignored, - QSizePolicy.Ignored) + chart_view.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) self.ui.gridLayout.addWidget(chart_view, 1, 1) self.charts.append(chart_view) diff --git a/examples/charts/legend/legend.py b/examples/charts/legend/legend.py index 39b9543f4..5417a940f 100644 --- a/examples/charts/legend/legend.py +++ b/examples/charts/legend/legend.py @@ -207,10 +207,8 @@ class MainWidget(QWidget): def update_legend_layout(self): legend = self.chart.legend() - rect = QRectF(self.legend_posx.value(), - self.legend_posy.value(), - self.legend_width.value(), - self.legend_height.value()) + rect = QRectF(self.legend_posx.value(), self.legend_posy.value(), + self.legend_width.value(), self.legend_height.value()) legend.setGeometry(rect) legend.update() diff --git a/examples/charts/percentbarchart/percentbarchart.py b/examples/charts/percentbarchart/percentbarchart.py index cfb11800a..9f70c0328 100644 --- a/examples/charts/percentbarchart/percentbarchart.py +++ b/examples/charts/percentbarchart/percentbarchart.py @@ -21,11 +21,11 @@ class MainWindow(QMainWindow): set3 = QBarSet("Mary") set4 = QBarSet("Samantha") - set0.append([1, 2, 3, 4, 5, 6]) - set1.append([5, 0, 0, 4, 0, 7]) + set0.append([1, 2, 3, 4, 5, 6]) + set1.append([5, 0, 0, 4, 0, 7]) set2.append([3, 5, 8, 13, 8, 5]) - set3.append([5, 6, 7, 3, 4, 5]) - set4.append([9, 7, 5, 3, 1, 2]) + set3.append([5, 6, 7, 3, 4, 5]) + set4.append([9, 7, 5, 3, 1, 2]) series = QPercentBarSeries() series.append(set0) diff --git a/examples/charts/pointconfiguration/chartwindow.py b/examples/charts/pointconfiguration/chartwindow.py index 055802b9f..36b10aa16 100644 --- a/examples/charts/pointconfiguration/chartwindow.py +++ b/examples/charts/pointconfiguration/chartwindow.py @@ -109,14 +109,14 @@ class ChartWindow(QMainWindow): self._selectedPointConfig = self._series.pointConfiguration(index) selected_point = self._series.at(index) selected_index_lineedit = self._selected_point_index_lineedit - selected_index_lineedit.setText("(" + str(selected_point.x()) + ", " + - str(selected_point.y()) + ")") + selected_index_lineedit.setText("(" + str(selected_point.x()) + ", " + + str(selected_point.y()) + ")") config = self._series.pointConfiguration(index) color = config.get(PointConfig.Color) or self._series.color() size = config.get(PointConfig.Size) or self._series.markerSize() - labelVisibility = (config.get(PointConfig.LabelVisibility) or - self._series.pointLabelsVisible()) + labelVisibility = (config.get(PointConfig.LabelVisibility) + or self._series.pointLabelsVisible()) customLabel = config.get(PointConfig.LabelFormat) or "" combobox_value_list = [ diff --git a/examples/charts/pointselectionandmarkers/pointselectionandmarkers.py b/examples/charts/pointselectionandmarkers/pointselectionandmarkers.py index 20a65bdaf..df7b61687 100644 --- a/examples/charts/pointselectionandmarkers/pointselectionandmarkers.py +++ b/examples/charts/pointselectionandmarkers/pointselectionandmarkers.py @@ -7,7 +7,8 @@ import sys from PySide6.QtCore import Slot, QPointF, Qt from PySide6.QtCharts import QChart, QChartView, QSplineSeries from PySide6.QtGui import QPainter, QImage -from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QGridLayout, QComboBox, QCheckBox, QLabel, QHBoxLayout +from PySide6.QtWidgets import (QApplication, QMainWindow, QWidget, QGridLayout, + QComboBox, QCheckBox, QLabel, QHBoxLayout) import utilities as Utilities @@ -68,7 +69,9 @@ if __name__ == "__main__": @Slot(int) def set_selected_light_marker(index): - series.setSelectedLightMarker(Utilities.get_selected_point_representation(Utilities.selected_point_type(index), marker_size)) + series.setSelectedLightMarker( + Utilities.get_selected_point_representation( + Utilities.selected_point_type(index), marker_size)) char_point_selected = QLabel("Char point selected: ") char_point_selected_combobox.addItems(["Blue triangle", "Yellow rectangle", "Lavender circle"]) @@ -85,7 +88,9 @@ if __name__ == "__main__": @Slot(int) def display_unselected_points(checkbox_state): if checkbox_state: - series.setLightMarker(Utilities.get_point_representation(Utilities.point_type(char_point_combobox.currentIndex()), marker_size)) + series.setLightMarker( + Utilities.get_point_representation( + Utilities.point_type(char_point_combobox.currentIndex()), marker_size)) else: series.setLightMarker(QImage()) |