Skip to content

Commit

Permalink
feat: impl SiTrendChart
Browse files Browse the repository at this point in the history
  • Loading branch information
ChinaIceF committed Dec 14, 2024
1 parent 94c08a7 commit 8f3d96c
Show file tree
Hide file tree
Showing 8 changed files with 591 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import random

from PyQt5.QtCore import Qt
from PyQt5.QtCore import Qt, QPointF
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QLabel

from siui.components import SiDenseHContainer, SiTitledWidgetGroup, SiLongPressButton, SiDenseVContainer
from siui.components.button import SiPushButtonRefactor, SiProgressPushButton, SiLongPressButtonRefactor, SiFlatButton, \
SiToggleButtonRefactor, SiSwitchRefactor, SiRadioButtonWithAvatar, SiRadioButtonWithDescription, \
SiRadioButtonRefactor
from siui.components.chart import SiTrendChart
from siui.components.page import SiPage
from siui.components.slider_ import SiSlider, SiCoordinatePicker2D, SiCoordinatePicker3D
from siui.core import SiGlobal
Expand Down Expand Up @@ -368,6 +369,26 @@ def __init__(self, *args, **kwargs):
group.addWidget(self.coordinate_picker_2ds)
group.addWidget(self.coordinate_picker_3ds)

with self.titled_widgets_group as group:
group.addTitle("统计图表")

self.charts = OptionCardPlaneForWidgetDemos(self)
self.charts.setTitle("趋势折线图")

self.trend_chart = SiTrendChart(self)
self.trend_chart.resize(900, 340)
self.trend_chart.setPointList([QPointF(i, (i/50)**2 * 0 + random.random() * (5 + 25 * ((i + 5) % 20 == 0))) for i in range(-50, 51)])
self.trend_chart.setToolTipFunc(lambda x, y: f"起始点:{x}\n振幅:{y}")
self.trend_chart.setQuality(1)
self.trend_chart.adjustViewRect()

self.charts.body().setAdjustWidgetsSize(True)
self.charts.body().addWidget(self.trend_chart)
self.charts.body().addPlaceholder(12)
self.charts.adjustSize()

group.addWidget(self.charts)

# 添加页脚的空白以增加美观性
self.titled_widgets_group.addPlaceholder(64)

Expand Down
19 changes: 17 additions & 2 deletions examples/Gallery for siui/components/page_widgets/page_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import random

import numpy
from PyQt5.QtCore import Qt
from PyQt5.QtCore import Qt, QPointF, QRectF
from PyQt5.QtGui import QCursor, QIcon
from PyQt5.QtWidgets import QGraphicsBlurEffect
from PyQt5.QtWidgets import QGraphicsBlurEffect, QLabel

from siui.components import (
SiCircularProgressBar,
Expand All @@ -27,7 +27,9 @@
SiSwitchRefactor,
SiToggleButtonRefactor,
)
from siui.components.chart import SiTrendChart
from siui.components.combobox import SiComboBox
from siui.components.label import HyperRoundBorderTest
from siui.components.menu import SiMenu
from siui.components.page import SiPage
from siui.components.progress_bar import SiProgressBar
Expand Down Expand Up @@ -319,6 +321,16 @@ def __init__(self, *args, **kwargs):

self.refactor_switch = SiSwitchRefactor(self)

self.test_rect = HyperRoundBorderTest(self)
self.test_rect.resize(256, 128)

self.original_rect = QLabel(self)
self.original_rect.resize(64, 64)
self.original_rect.setStyleSheet("background-color: #a681bf; border-radius: 14px")
# self.trend_chart.adjustViewRect()
# print(self.trend_chart.viewRect())

# self.refactor_buttons.body().setAdjustWidgetsSize(True)
self.refactor_buttons.body().addWidget(self.refactor_pushbutton)
self.refactor_buttons.body().addWidget(self.refactor_progress_button)
self.refactor_buttons.body().addWidget(self.refactor_long_press_button)
Expand All @@ -328,6 +340,9 @@ def __init__(self, *args, **kwargs):
self.refactor_buttons.body().addWidget(self.refactor_slider)
self.refactor_buttons.body().addWidget(self.refactor_slider2)
self.refactor_buttons.body().addWidget(self.coordinate_picker_2d)
self.refactor_buttons.body().addWidget(self.test_rect)
self.refactor_buttons.body().addWidget(self.original_rect)
# self.refactor_buttons.body().addWidget(self.trend_chart)

self.refactor_buttons.body().addPlaceholder(12)
self.refactor_buttons.adjustSize()
Expand Down
1 change: 1 addition & 0 deletions siui/components/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

from siui.core import GlobalFont, SiGlobal, createPainter
from siui.core.animation import SiExpAnimationRefactor
from siui.core.painter import getSuperRoundedRectPath
from siui.gui import SiFont

if TYPE_CHECKING:
Expand Down
Loading

0 comments on commit 8f3d96c

Please sign in to comment.