Using different colors for different bars in Qt 3D Bar Graph
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:
- Yellow if the value is between 0 and 5000.
- Red if the value is between 5001 and 15000.
- 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.
This post is deleted!
Let me put it this way: Can I color individual bars with the color I want using the underlying QOpenGLContext?
Any ideas? Please help.