[Interest] [QtCharts] Logarithmic QDateTimeAxis

Elvis Stansvik elvstone at gmail.com
Wed Jul 13 13:38:56 CEST 2016

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

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.


> Adam Thompson
> Computer Scientist, Nuclear Engineering
> Oak Ridge National Laboratory
> +1.865.241.8062
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

More information about the Interest mailing list