QCustomPlot Discussion and Comments

Bargraph and my code?Return to overview

Hi All,

I've prepared sample code as below.
But nothing is visible?
Could you please advise what I should add/change in it?

QCPBars *newBars = new QCPBars(ui->plot->xAxis, ui->plot->yAxis);
ui->plot->addGraph();
QVector<double> x(10), y(100);
ui->plot->addPlottable(newBars);
newBars->setName("Test data");
newBars->setData(x, y);
ui->plot->xAxis->setLabel("Data1");
ui->plot->yAxis->setLabel("Data2");
ui->plot->replot();

Thanks in advance for help.
Ojdas

This line does not do anything in your example:

ui->plot->addGraph();

If you don't populate x and y I don't think you should see anything. Also, I was under the impression that x and y need to have equal dimensions (but I might be wrong).