[Interest] [QtCharts] Logarithmic QDateTimeAxis

Thompson, Adam B. thompsonab at ornl.gov
Wed Jul 13 14:10:18 CEST 2016


> On 7/13/16, 7:46 AM, "chgans at googlemail.com on behalf of Ch'Gans" <chgans at googlemail.com on behalf of chgans at gna.org> wrote:
>
> Why not use a plain QLogValueAxis for your X axis, if you're talking
> thousand of years, i guess you don't need month, day, hours, minutes,
>... on your X axis, do you? Do you need to take into account leap
> year, leap seconds? Is there a mathematical definition of
> log(date:time)
> QLogValueAxis with just years should do the job. But maybe i'm missing
> something.
>
> Looking at the source in qt5/qtcharts/src/charts/axis/datetimeaxis and
> qt5/qtcharts/src/charts/axis/logvalueaxis doesn't show complicated
> code. So this seems to be doable "easily".
>
> My 2cents,
> Chris

Chris,

I would think it safe to assume that level of precision (month, day, …) wouldn’t be necessary when viewing data that’s extrapolated that far, but I’d need to confirm with others before moving forward on that assumption.

The issue with using QLogValueAxis is that you’re still displaying numeric values on the labels as opposed to the actual date representation. Instead of seeing 12345 BCE, you’d see 12345 BCE – base year BCE (e.g., 10329 for the max year if the base year is 2016). That’s not necessarily what the user might expect, so I want to be able to handle displaying the actual date.

As far as I know, there’s no way for me to provide custom labels for a QLogValueAxis, converting the numeric value to a QDate(Time) representation. I don’t see a simple way of extending the other axis types to do this, particularly since their actual implementation is dependent on private classes (QLogValueAxisPrivate and QDateTimeAxisPrivate) that are not accessible to developers for extending.

If you see something I’m missing, I’m all ears.

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




More information about the Interest mailing list