Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. pyside2 qtcharts updating its self as month elapse

pyside2 qtcharts updating its self as month elapse

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 332 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    erico
    wrote on last edited by erico
    #1

    I am trying to make a chart where every first of each month the chart updates its self if anyone who has a solution or an idea i would be so grateful.

     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()
         else:
              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)
    
    Pl45m4P 1 Reply Last reply
    0
    • E erico

      I am trying to make a chart where every first of each month the chart updates its self if anyone who has a solution or an idea i would be so grateful.

       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()
           else:
                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)
      
      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @erico

      Where is your question?

      @erico said in pyside2 qtcharts updating its self as month elapse:

      if the current month is over the chart updates

      Cant you just replace this statement with "every first of each month"? When it is the first of any month, the last month is most likely over ;-)

      Edit:

      Since you updated your question... I meant this literally. You could check if datetime.now().day == 1.

      What kind of program is this? Should it keep on running all the time or do you want to update, when you start your program?


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      E 1 Reply Last reply
      0
      • Pl45m4P Pl45m4

        @erico

        Where is your question?

        @erico said in pyside2 qtcharts updating its self as month elapse:

        if the current month is over the chart updates

        Cant you just replace this statement with "every first of each month"? When it is the first of any month, the last month is most likely over ;-)

        Edit:

        Since you updated your question... I meant this literally. You could check if datetime.now().day == 1.

        What kind of program is this? Should it keep on running all the time or do you want to update, when you start your program?

        E Offline
        E Offline
        erico
        wrote on last edited by
        #3

        @Pl45m4 it should keep on updating its self

        JonBJ 1 Reply Last reply
        0
        • E erico

          @Pl45m4 it should keep on updating its self

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @erico
          Update itself when/in response to what? You have to clarify what you are looking to do.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved