[Interest] [QtCharts] Logarithmic QDateTimeAxis

Thompson, Adam B. thompsonab at ornl.gov
Wed Jul 13 13:59:36 CEST 2016


On 7/13/16, 7:38 AM, "Elvis Stansvik" <elvstone at gmail.com> wrote:

> Hi Adam,

> 2016-06-27 21:55 GMT+02:00 Thompson, Adam B. <thompsonab at ornl.gov>:
> > The software package I co-develop at work is dependent on Qt 4.8, but we
> > plan to move to Qt 5 when we have time/funding. We currently depend on a
> > third-party plotting package for our 2D data visualization, but we'd like to
> > be able to use QtCharts when we upgrade.
> >
> >
> >
> > Some of our data sets are time-dependent and are often extrapolated hundreds
> > or thousands of years in the future. As such, a logarithmic time scale would
> > be quite useful, if not necessary to view the data in a truly meaningful
> > manner.
> >
> >
> >
> > Can anyone provide guidance on properly extending QDateTimeAxis (,
> > QLogValueAxis, or QAbstractAxis) to provide a logarithmic time scale as I've
> > described?
>
> I have not used QtCharts at all myself yet, but from looking at the
> classes you mentioned, I don't think there's a way to combine the
> functions of QDateTimeAxis and QLogValueAxis to get what you want.
> Also note, that even if this had been possible, there's this
> limitation (from the QDateTimeAxis) docs:
>
>     "QDateTimeAxis works correctly with dates from 4714 BCE to 287396
> CE. There are also other limitiation related to QDateTime. Please
> refer to QDateTime documentation."
>
> Which may or may not be a problem for you.
>
> What you probably have to do is to create a custom axis type, deriving
> the QAbstractAxis that you mentioned. You could of course have a look
> at the source of QDateTimeAxis and QLogValueAxis for inspiration.
>
> Time, and especially calendar systems, is a tricky business, but
> depending on your requirements, you may not have to deal much with
> that.
>
> A possibility may be to use a QLogValueAxis as your internal
> representation, to leverage some of its functionality. But since it
> works with floating point numbers, I think I'd rather make my own that
> works with an integer type as internal representation of time.
>
> Sorry I can't be of more help, but I think deriving QAbstractAxis to
> implement a custom axis type is what you'll have to do.
>
> Elvis

Elvis,

Thank you for your response.

True, there are potential limitations to keep in mind when attempting to display dates far into the future. The documentation for QDateTime (http://doc.qt.io/qt-5/qdatetime.html) mentions a much larger supported range of values, so I find that a little confusing.

If there were a way to use QLogValueAxis but provide custom labels, that would easily suffice, but I don’t see a way to do that, either. Those types depend on private classes derived from QAbstractAxisPrivate, but I wouldn’t be able to extend that myself since it’s declared in a private header and implemented in qabstractaxis.cpp. The same goes for extending QLogValueAxis(Private) or QDateTimeAxis(Private).

Adam Thompson
Computer Scientist, Nuclear Engineering
Oak Ridge National Laboratory
+1.865.241.8062




More information about the Interest mailing list