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. Display all bars in a barset in one category.

Display all bars in a barset in one category.

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 302 Views 1 Watching
  • 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.
  • N Offline
    N Offline
    ntos
    wrote on last edited by
    #1

    Hi. Here is a piece of code:
    QBarSet *set2 = new QBarSet("A");
    *set2 << 294 << 246 << 257 << 319 << 300 << 325;
    QBarSet *set3 = new QBarSet("B");
    *set3 << 248 << 244 << 265 << 281 << 278 << 313;
    QStringList category;
    category << "2013" << "2014";
    If I use the QBarSeries, the bars from the sets are interleaved, which is not what I want.
    I want to display all bars from set2 in category 2013 and those from set3 in category 2014.
    How do I do it?
    Thank you.

    Pl45m4P 1 Reply Last reply
    0
    • N ntos

      Hi. Here is a piece of code:
      QBarSet *set2 = new QBarSet("A");
      *set2 << 294 << 246 << 257 << 319 << 300 << 325;
      QBarSet *set3 = new QBarSet("B");
      *set3 << 248 << 244 << 265 << 281 << 278 << 313;
      QStringList category;
      category << "2013" << "2014";
      If I use the QBarSeries, the bars from the sets are interleaved, which is not what I want.
      I want to display all bars from set2 in category 2013 and those from set3 in category 2014.
      How do I do it?
      Thank you.

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @ntos said in Display all bars in a barset in one category.:

      If I use the QBarSeries, the bars from the sets are interleaved, which is not what I want.
      I want to display all bars from set2 in category 2013 and those from set3 in category 2014.

      See how QBarSet actually works, which is not as you think:

      A bar set contains one data value for each category. The first value of a set is assumed to belong to the first category, the second one to the second category, and so on. If the set has fewer values than there are categories, the missing values are assumed to be located at the end of the set

      (from: https://doc.qt.io/qt-6/qbarset.html#details)

      So your

      *set2 << 294 << 246 << 257 << 319 << 300 << 325;
      

      is not fully cat.A. or cat.B.
      294 is category "2013", 246 is category "2014"

      In general, a set is expected to have a value for each category and not all values for one category.

      You will find a better example here:

      • https://doc.qt.io/qt-6/qtcharts-barchart-example.html

      In your case, I think you can't use QBarSet in the way you do currently.

      Either implement your own "logic" to handle this or deal with it that your data index equals the category.


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

      ~E. W. Dijkstra

      1 Reply Last reply
      0
      • N Offline
        N Offline
        ntos
        wrote on last edited by
        #3

        Thank you. Could you recommend a Qt's data structure to display the numbers 294 << 246 << 257 << 319 << 300 << 325 in bar form?

        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