QCustomPlot Discussion and Comments

How to get x axis to be labled as time values, ie Minutes, Days, Months etc.Return to overview

I want to be able to plot a YTD graph of a specific company, to do so I would like the first y value to be plotted on the x value of Jan 1st, how do i properly get the Dates say january 1st - December 31st to be on the X axis with only displaying the dates maybe every month, attached will be a picture of my code and my current graph where none of the points are even being plotted or shown. Also will there be a way where the x axis automatically updates every minute to show real time data, for example say its 3:00PM, it will show that on the right most x value, but then it turns 3:01PM so now the right most x value would be 3:01PM, thank you in advance!

Attached Pictures

the datetime axis type is expecting a double in seconds from epoch (QDateTime::currentMsecsSinceEpoch /1000.0)

So what is the best way to label the x axis origin starting at the beginning of the year and ending at the end of the year? The seconds from epoch is confusing me?

from the docs, for setting the range, you would use something like this:

customPlot->xAxis->setRange(QCPAxisTickerDateTime::dateTimeToKey(QDate(2013, 11, 16)), QCPAxisTickerDateTime::dateTimeToKey(QDate(2015, 5, 2)));

as far as displaying only the dates every month, i dont really like doing this because it means you have no labels if you zoom. I think you could do something like using setTickCount(12) which should be close to what you want, but it will assign them on its own. If you want to do it properly, you would need to subclass QCPAxisTickerDateTime and reimplement the 'getTickStep' method.