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. How to insert a bar with different color into StackedBarChart?

How to insert a bar with different color into StackedBarChart?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 610 Views 2 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.
  • L Offline
    L Offline
    Lee908
    wrote on last edited by
    #1

    Hi,
    I'm new here. And I have a question about QChart: is it possible to insert a bar with different color into StackedBarChart? An example is shown in the following pic. Any suggestion would be appreciated!
    BarChart.png

    BTW, I'm not sure if it's suitable to raise the question in this category or not. If there is a more suitable place, please let me know. Thank you.

    1 Reply Last reply
    0
    • A.A.SEZENA Offline
      A.A.SEZENA Offline
      A.A.SEZEN
      wrote on last edited by
      #2

      Actually, your question is vague. For the example you quoted :

      set0->setColor(Qt::red);
      
      L 1 Reply Last reply
      0
      • A.A.SEZENA A.A.SEZEN

        Actually, your question is vague. For the example you quoted :

        set0->setColor(Qt::red);
        
        L Offline
        L Offline
        Lee908
        wrote on last edited by
        #3

        @A-A-SEZEN
        I tried that, it didn't work. But I have found a workaround by myself: insert zero into the existing barsets, and then add a new barset for red, containinng 5 zero and 1 non-zero at the end. For the existing barsets, the corresponding bars in the chart are not changed since the extra data is 0. For the new barset, it only contain one color int the bar because the high of the first 5 rectangles is 0. So my question is solved. Ha..

        1 Reply Last reply
        0
        • A.A.SEZENA Offline
          A.A.SEZENA Offline
          A.A.SEZEN
          wrote on last edited by
          #4

          It's already used like that. If there is a value, the color is there, otherwise it is not.

          L 1 Reply Last reply
          0
          • A.A.SEZENA A.A.SEZEN

            It's already used like that. If there is a value, the color is there, otherwise it is not.

            L Offline
            L Offline
            Lee908
            wrote on last edited by Lee908
            #5

            @A-A-SEZEN said in How to insert a bar with different color into StackedBarChart?:

            hat. If there is a value, the color is there, otherwise it is not.

            Yes, it's always been there, just I didn't find it before. Thank you all the same!

            BTW, how can I set this topic to be SOLVED? I don't find out that approach...

            jsulmJ 1 Reply Last reply
            0
            • L Lee908

              @A-A-SEZEN said in How to insert a bar with different color into StackedBarChart?:

              hat. If there is a value, the color is there, otherwise it is not.

              Yes, it's always been there, just I didn't find it before. Thank you all the same!

              BTW, how can I set this topic to be SOLVED? I don't find out that approach...

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by jsulm
              #6

              @Lee908 said in How to insert a bar with different color into StackedBarChart?:

              how can I set this topic to be SOLVED?

              "Topic Tools" in bottom right corner, then "Mark as Solved".

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              L 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Lee908 said in How to insert a bar with different color into StackedBarChart?:

                how can I set this topic to be SOLVED?

                "Topic Tools" in bottom right corner, then "Mark as Solved".

                L Offline
                L Offline
                Lee908
                wrote on last edited by
                #7

                @jsulm

                Thanks a lot.

                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