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. Using different colors for different bars in Qt 3D Bar Graph
Forum Updated to NodeBB v4.3 + New Features

Using different colors for different bars in Qt 3D Bar Graph

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.6k 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.
  • O Offline
    O Offline
    onat
    wrote on last edited by
    #1

    Hello,
    I want to create a 3D bar graph using the data visualizations library. But according to the requirements of the project, the bars must be colored according to which value range they are in. To make things more concrete:

    1. Yellow if the value is between 0 and 5000.
    2. Red if the value is between 5001 and 15000.
    3. Blue if the value is between 15001 and 20000.
      I tried doing something like this:
    QLinearGradient barGradient(0, 0, 1, 1);
        barGradient.setColorAt(0.0, Qt::yellow);
        barGradient.setColorAt(0.24, Qt::yellow);
        barGradient.setColorAt(0.25, Qt::red);
        barGradient.setColorAt(0.74, Qt::red);
        barGradient.setColorAt(0.75, Qt::blue);
        barGradient.setColorAt(1.0, Qt::blue);
     
        barSeries->setBaseGradient(barGradient);
    barSeries->setColorStyle(Q3DTheme::ColorStyleRangeGradient);
    

    But the problem is I keep getting bars in 2 or 3 colors, whereas I want them in just one color, based on the value range. In addition, the underlying libraries determine the start and end values of each color on the largets value in the data set, not on the constant boundaries that I want to specify (in this case 5000, 15000 and 20000).
    How can I get around this problem?
    Thanks in advance.
    onat

    O 1 Reply Last reply
    0
    • O onat

      Hello,
      I want to create a 3D bar graph using the data visualizations library. But according to the requirements of the project, the bars must be colored according to which value range they are in. To make things more concrete:

      1. Yellow if the value is between 0 and 5000.
      2. Red if the value is between 5001 and 15000.
      3. Blue if the value is between 15001 and 20000.
        I tried doing something like this:
      QLinearGradient barGradient(0, 0, 1, 1);
          barGradient.setColorAt(0.0, Qt::yellow);
          barGradient.setColorAt(0.24, Qt::yellow);
          barGradient.setColorAt(0.25, Qt::red);
          barGradient.setColorAt(0.74, Qt::red);
          barGradient.setColorAt(0.75, Qt::blue);
          barGradient.setColorAt(1.0, Qt::blue);
       
          barSeries->setBaseGradient(barGradient);
      barSeries->setColorStyle(Q3DTheme::ColorStyleRangeGradient);
      

      But the problem is I keep getting bars in 2 or 3 colors, whereas I want them in just one color, based on the value range. In addition, the underlying libraries determine the start and end values of each color on the largets value in the data set, not on the constant boundaries that I want to specify (in this case 5000, 15000 and 20000).
      How can I get around this problem?
      Thanks in advance.
      onat

      O Offline
      O Offline
      onat
      wrote on last edited by onat
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • O Offline
        O Offline
        onat
        wrote on last edited by
        #3

        Let me put it this way: Can I color individual bars with the color I want using the underlying QOpenGLContext?
        Any ideas? Please help.

        YashpalY 1 Reply Last reply
        0
        • O onat

          Let me put it this way: Can I color individual bars with the color I want using the underlying QOpenGLContext?
          Any ideas? Please help.

          YashpalY Offline
          YashpalY Offline
          Yashpal
          wrote on last edited by
          #4

          @onat Do you have a solution to this problem?

          1 Reply Last reply
          0
          • F Offline
            F Offline
            f.lerdino
            wrote on last edited by
            #5

            No solution?

            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