class QDateTimeAxis#

The QDateTimeAxis class adds dates and times to a chart’s axis. More

Inheritance diagram of PySide6.QtCharts.QDateTimeAxis

Synopsis#

Properties#

  • formatᅟ - String that is used when creating the label for the axis out of a QDateTime object

  • maxᅟ - Maximum value on the axis

  • minᅟ - Minimum value on the axis

  • tickCountᅟ - Number of tick marks on the axis

Methods#

Signals#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

QDateTimeAxis can be set up to show an axis line with tick marks, grid lines, and shades. The labels can be configured by setting an appropriate DateTime format. QDateTimeAxis works correctly with dates from 4714 BCE to 287396 CE. For other limitiations related to QDateTime, see QDateTime documentation.

Note

QDateTimeAxis is disabled on platforms that define qreal as float.

../../_images/api_datatime_axis.png

QDateTimeAxis can be used with any QXYSeries . To add a data point to the series, QDateTime::toMSecsSinceEpoch() is used:

QLineSeries *series = new QLineSeries;

QDateTime xValue;
xValue.setDate(QDate(2012, 1 , 18));
xValue.setTime(QTime(9, 34));
qreal yValue = 12;
series->append(xValue.toMSecsSinceEpoch(), yValue);

xValue.setDate(QDate(2013, 5 , 11));
xValue.setTime(QTime(11, 14));
qreal yValue = 22;
series->append(xValue.toMSecsSinceEpoch(), yValue);

The following code snippet illustrates adding the series to the chart and setting up QDateTimeAxis :

QChartView *chartView = new QChartView;
chartView->chart()->addSeries(series);

// ...
QDateTimeAxis *axisX = new QDateTimeAxis;
axisX->setFormat("dd-MM-yyyy h:mm");
chartView->chart()->setAxisX(axisX, series);

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property formatᅟ: str#

This property holds The format string that is used when creating the label for the axis out of a QDateTime object..

See QDateTime documentation for information on how the string should be defined.

See also

locale

Access functions:
property maxᅟ: QDateTime#

This property holds The maximum value on the axis..

When setting this property, the minimum value is adjusted if necessary, to ensure that the range remains valid.

Access functions:
property minᅟ: QDateTime#

This property holds The minimum value on the axis..

When setting this property, the maximum value is adjusted if necessary, to ensure that the range remains valid.

Access functions:
property tickCountᅟ: int#

This property holds The number of tick marks on the axis..

Access functions:
__init__([parent=None])#
Parameters:

parentQObject

Constructs an axis object that is a child of parent.

format()#
Return type:

str

See also

setFormat()

Getter of property formatᅟ .

formatChanged(format)#
Parameters:

format – str

This signal is emitted when the format of the axis changes.

Notification signal of property formatᅟ .

max()#
Return type:

QDateTime

See also

setMax()

Getter of property maxᅟ .

maxChanged(max)#
Parameters:

maxQDateTime

This signal is emitted when the maximum value of the axis, specified by max, changes.

Notification signal of property maxᅟ .

min()#
Return type:

QDateTime

See also

setMin()

Getter of property minᅟ .

minChanged(min)#
Parameters:

minQDateTime

This signal is emitted when the minimum value of the axis, specified by min, changes.

Notification signal of property minᅟ .

rangeChanged(min, max)#
Parameters:

This signal is emitted when the minimum or maximum value of the axis, specified by min and max, changes.

setFormat(format)#
Parameters:

format – str

See also

format()

Setter of property formatᅟ .

setMax(max)#
Parameters:

maxQDateTime

See also

max()

Setter of property maxᅟ .

setMin(min)#
Parameters:

minQDateTime

See also

min()

Setter of property minᅟ .

setRange(min, max)#
Parameters:

Sets the range on the axis from min to max. If min is greater than max, this function returns without making any changes.

setTickCount(count)#
Parameters:

count – int

Sets the number of tick marks on the axis to count.

See also

tickCount()

Setter of property tickCountᅟ .

tickCount()#
Return type:

int

Returns the number of tick marks on the axis.

See also

setTickCount()

Getter of property tickCountᅟ .

tickCountChanged(tick)#
Parameters:

tick – int

This signal is emitted when the number of tick marks on the axis, specified by tickCount, changes.

Notification signal of property tickCountᅟ .