QCustomPlot Discussion and Comments

QCPAxisTickerDateTime produces odd labelsReturn to overview

I set the axis range from 2016-01-01 to 2017-07-17. It produces two labels; the first an empty string and the second '2016-12-31\n19:00:000'. The size of the QCusomPlot axis is plenty big enough for multiple labels. With smaller time spans I typically get three or four labels.

It seems like you have changed the default date time format. Please post the full code with which you configure your QCPAxisTickerDateTime.

This code produces the cited result.

const char * const Panel::m_title = "Demonstration";

  // Set the window title and top level layout.
  QHBoxLayout *topLayout = new QHBoxLayout;
  QCustomPlot *plot = new QCustomPlot;

  QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
  // Configure the time axis.
  const double start = 1451624400.0;  // 2016-01-01
  const double end = 1500264000.0;    // 2017-07-17
  plot->xAxis->setRange(start, end);

Using only the code you posted above, I get the following output:


Which is as expected.

So the labels "2016-07-01\n01:00:00" (no three zeros as in your case), "2017-01-01\n01:00:00", and to the right "2017-07-01\n01:00:00".
The label all the way to the right might be clipped if the font is a slightly different size/geometry because it's very close to the widget border. When tick labels intersect with the widget border, they become invisible, this is intentional behaviour to prevent half-visible (and thus potentially ambiguous) labeling. The label at the tick on the very left of the x axis is made invisible for exactly this reason, too.

Note the difference in the time (19 in your case, 01 in my case) is due to time zone differences between our systems.

Another hint: Instead of entering the number of seconds as a double, you could use QCPAxisTickerDateTime::dateTimeToKey(QDate(2016, 1, 1));
which is much nicer to read and edit.

If you want more labels, read the documentation of QCPAxisTicker::setTickCount and setTickStepStrategy.

I get a very different result, using the same source code. I use the following version of the library. I will email an image of what I see. What version were you using?

#### Version 2.0.0-beta released on 13.09.16 ####