Reputation: 2949
I was wondering either it is possible in the QCustomPlot library to change display format of the data on one of the axis. In my application on the X axis I have time in seconds and I would like to display the steps in HH:MM:SS instead. As an alternative I am thinking of changing the display only from seconds to minutes to hours depending on the X lenght and updating the label from Time [s] to [min] to [hour]. But I would avoid that if its possible to do it the way I described. I Would appreciate all help!
When using:
customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
customPlot->xAxis->setDateTimeFormat("hh:mm:ss");
My timeline starts from hour 1 instead of 0: Is there a way to fix this?
Upvotes: 2
Views: 2691
Reputation: 41
// Создаем формат отображения дискретных отсчетов времени захвата мгновенного курса судна
QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
// Установка формата отображения времени захвата мгновенного курса судна
dateTicker->setDateTimeFormat("hh:mm:ss");
// Передаем вектор подписей в график
m_QCustomPlot->yAxis->setTicker(dateTicker);
Upvotes: 0
Reputation: 16324
You can use setTickLabelType()
and setDateTimeFormat
:
plot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
plot->xAxis->setDateTimeFormat("hh:mm:ss");
The format string is built according to the the format string of QDateTime::toString()
.
Upvotes: 1