1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include <private/polarchartdatetimeaxisangular_p.h>
5#include <private/chartpresenter_p.h>
6#include <private/abstractchartlayout_p.h>
7#include <QtCharts/QDateTimeAxis>
8
9QT_BEGIN_NAMESPACE
10
11PolarChartDateTimeAxisAngular::PolarChartDateTimeAxisAngular(QDateTimeAxis *axis, QGraphicsItem *item)
12 : PolarChartAxisAngular(axis, item)
13{
14 QObject::connect(sender: axis, SIGNAL(tickCountChanged(int)), receiver: this, SLOT(handleTickCountChanged(int)));
15 QObject::connect(sender: axis, SIGNAL(formatChanged(QString)), receiver: this, SLOT(handleFormatChanged(QString)));
16}
17
18PolarChartDateTimeAxisAngular::~PolarChartDateTimeAxisAngular()
19{
20}
21
22QList<qreal> PolarChartDateTimeAxisAngular::calculateLayout() const
23{
24 int tickCount = static_cast<QDateTimeAxis *>(axis())->tickCount();
25 Q_ASSERT(tickCount >= 2);
26
27 QList<qreal> points;
28 points.resize(size: tickCount);
29
30 const qreal d = 360.0 / qreal(tickCount - 1);
31
32 for (int i = 0; i < tickCount; ++i) {
33 qreal angularCoordinate = qreal(i) * d;
34 points[i] = angularCoordinate;
35 }
36
37 return points;
38}
39void PolarChartDateTimeAxisAngular::createAxisLabels(const QList<qreal> &layout)
40{
41 QStringList labelList = createDateTimeLabels(max: min(), min: max(), ticks: layout.size(), format: static_cast<QDateTimeAxis *>(axis())->format());
42 setLabels(labelList);
43}
44
45void PolarChartDateTimeAxisAngular::handleTickCountChanged(int tick)
46{
47 Q_UNUSED(tick);
48 QGraphicsLayoutItem::updateGeometry();
49 if (presenter())
50 presenter()->layout()->invalidate();
51}
52
53void PolarChartDateTimeAxisAngular::handleFormatChanged(const QString &format)
54{
55 Q_UNUSED(format);
56 QGraphicsLayoutItem::updateGeometry();
57 if (presenter())
58 presenter()->layout()->invalidate();
59}
60
61QT_END_NAMESPACE
62
63#include "moc_polarchartdatetimeaxisangular_p.cpp"
64

source code of qtcharts/src/charts/axis/datetimeaxis/polarchartdatetimeaxisangular.cpp