QCustomPlot Discussion and Comments

graph dissapearing, QCPAxisTickerDateTimeReturn to overview

Hello. Sorry for my eng.
I need to draw a graph with time-dependent values. I have this data from database.
Example of data:
value date
100,199 2016-12-25 15:19:05.857
100,035 2016-12-25 15:22:55.937
100,199 2016-12-25 15:23:55.953

 QSqlQuery query; query.exec(str); 

click wrong button _-_
i create a query, and converting String to double

res->append(pos,query.value(0).toDouble(),QDateTime::fromString(query.value(1).toString(),"yyyy-MM-ddThh:mm:ss")
                        .toSecsSinceEpoch());

res - my own simple struct for data
after i set data to graph and etc
QSharedPointer<QCPAxisTickerDateTime> dateTimeTicker(new QCPAxisTickerDateTime);
    plot->xAxis->setTicker(dateTimeTicker);
    dateTimeTicker->setDateTimeFormat("mm-ss-zzz\nhh-mm-ss\nd. MMM\nyyyy");
    plot->addGraph();
    plot->graph(0)->setPen(QPen(Qt::blue));
    plot->graph(0)->setData(valuesList->date,valuesList->values(),true);
    plot->rescaleAxes();

what a problem - i cant nicely zoom and drag my graph. He(graph) disappears.
https://ibb.co/tbcwWmJ - basic graph
https://ibb.co/2tMjgJQ - im tried to zoom by wheel or drag etc.
Im was try disable AdaptiveSampling but its not help me.
What im doing wrong?

1. check your data correct
2. dynamic plot or static plot?

To lancelot:
1. i think trouble in date on double representation: very big numbers, like 1.51.57507e+12 on X axis.
2. oh, i think static: adding data only once, and clear graph if i need draw new.
This code well work with positions (0-1-2-3-4...), but i need time stamps at X axis. If you have any ideas how realize it, you are welcome.

show more code

its almost whole related with QCP:

plot = ui->plot;
    plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom );

QSharedPointer<QCPAxisTickerDateTime> dateTimeTicker(new QCPAxisTickerDateTime);

    plot->xAxis->setTicker(dateTimeTicker);

    dateTimeTicker->setDateTimeFormat("mm-ss-zzz\nhh-mm-ss\nd. MMM\nyyyy");
    plot->addGraph();
    plot->graph(0)->setPen(QPen(Qt::blue));

    plot->graph(0)->setData(valuesList->date,valuesList->values(),true);

    plot->rescaleAxes();

I have some code to zoom and drag graph by buttons(like at pict), but i think they do not affect

I change QCPAxisTickerDateTime to QCPAxisTickerText.
I set ticksCount and strategy:

QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
plot->xAxis->setTicker(textTicker);
textTicker->setTicks(valuesList->intKeys,valuesList->date);
textTicker->setTickCount(5);
textTicker->setTickStepStrategy(QCPAxisTickerText::tssReadability);

Graph work well, but text overlapping.
https://ibb.co/HC9bFXy
What i doing wrong now?
If it important, i add textTicker after adding data and rescaling X Axis. I try other StepStrategy, nothing changes

subclass QCPAxisTickerText and reimplement createTickVector.

you can see https://blog.csdn.net/qq10097355/article/details/106593411

thank you very much, it helps me