File indexing completed on 2024-06-16 04:09:02

0001 /**
0002  * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
0003  *
0004  * This file is part of the KD Chart library.
0005  *
0006  * SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 
0009 #include "timeaxis.h"
0010 
0011 #include <QDateTime>
0012 
0013 TimeAxis::TimeAxis( KChart::AbstractCartesianDiagram* parent )
0014     : KChart::CartesianAxis( parent )
0015 {
0016     // Intentionally left blank
0017 }
0018 
0019 const QString TimeAxis::customizedLabel( const QString& label ) const
0020 {
0021     // Here we are free to format the value to whatever we want. As example we
0022     // could also return a scientific notation with something like the following
0023     // both lines;
0024     //const int precision = 2;
0025     //return QString::number(label.toReal(), 'E', precision);
0026 
0027     // Format the time-value to a nice string representation.
0028     const QDateTime dateTime = QDateTime::fromSecsSinceEpoch( label.toDouble() * 3600.0 );
0029     return dateTime.date().toString();
0030 }