0

I'm creating a QChart bar plot. I have a previously unknown number of QBarSets (I know the number of QBarSets during runtime - but maybe between 1-10) and a, possibly high number of categories (10-1000).

QVector<QBarSet*> barSets; 
for(int i=0; i<n; ++i){ // n between 1-10
    QBarSet *set = new QBarSet("");
    for(int j=0; j<m; ++j){ // m between 1-1000
        *set << someValue;
    }
    barSets.push_back(set);
}
QBarSeries* series = new QBarSeries();
for(int i=0; i<barSets.count(); ++i){
    series->append(barSets.at(i));
}

everything else is almost the same as described here.

My problem is that every bar gets very very tiny. I would like to plot each bar with a fixed width and maybe use a Horizontal Scroll Bar to scroll through the categories.

Does someone have a tiny example how to do this?

user7431005
  • 3,899
  • 4
  • 22
  • 49

1 Answers1

0

turns out the answer is very simple. you can grep the QBarCategoryAxis very simply using

auto axis = qobject_cast<QBarCategoryAxis*>(chart->axisX());

and then simply control the visible categories by name

auto categories = axis->categories();
QString min = categories.at(n);
QString max = categories.at(m);
axis->setMin(min);
axis->setMax(max);

I have used the horizontalScrollBar_valueChanged signal to change the min and max category numbers(n,m).

user7431005
  • 3,899
  • 4
  • 22
  • 49