Display all bars in a barset in one category.
-
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. -
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.@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
QBarSetactually 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.
294is category "2013",246is 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:
In your case, I think you can't use
QBarSetin the way you do currently.Either implement your own "logic" to handle this or deal with it that your data index equals the category.