Python pyside2 qtcharts在一个月后更新其自身
我正在尝试制作一张图表,如果本月结束,图表将在下个月更新,任何有想法或解决方案的人我都将非常感激Python pyside2 qtcharts在一个月后更新其自身,python,pyside2,Python,Pyside2,我正在尝试制作一张图表,如果本月结束,图表将在下个月更新,任何有想法或解决方案的人我都将非常感激 def create_bar(self): # The QBarSet class represents a set of bars in the bar chart. # It groups several bars into a bar set set0 = QtCharts.QBarSet("markup") set1 = QtC
def create_bar(self):
# The QBarSet class represents a set of bars in the bar chart.
# It groups several bars into a bar set
set0 = QtCharts.QBarSet("markup")
set1 = QtCharts.QBarSet("liabil")
# set data
# initial data = current sales and expenses
if datetime.now().day == datetime.now().month:
set0 << self.total_sales()
set1 << self.total_expenses()
# load data to chart
series = QtCharts.QBarSeries()
series.append(set0)
series.append(set1)
# initialize chart
chart = QtCharts.QChart()
chart.addSeries(series)
chart.setAnimationOptions(QtCharts.QChart.SeriesAnimations)
categories = datetime.now().strftime('%b')
axis = QtCharts.QCategoryAxis()
axisY = QtCharts.QValueAxis()
axis.append(str(categories), 0)
chart.addAxis(axisY, QtCore.Qt.AlignLeft)
series.attachAxis(axisY)
axisY.setRange(0, 10000)
chart.setAxisX(axis, series)
chart.legend().setVisible(True)
chart.legend().setAlignment(Qt.AlignBottom)
self.place = QtWidgets.QVBoxLayout(self)
self.place = QtWidgets.QVBoxLayout(self.ui.widget_2)
self.place.setContentsMargins(0, 0, 0, 0)
self.chartview = QtCharts.QChartView(chart)
self.chartview.setRenderHint(QPainter.Antialiasing)
self.chartview.setContentsMargins(0, 0, 0, 0)
self.place.addWidget(self.chartview)
def创建工具栏(自):
#QBarSet类表示条形图中的一组条形图。
#它将多个条分组为一个条集
set0=QtCharts.QBarSet(“标记”)
set1=QtCharts.QBarSet(“liabil”)
#设置数据
#初始数据=当前销售额和费用
如果datetime.now().day==datetime.now().month:
set0请提供一个