KQuickCharts

ChartAxisSource.h
1/*
2 * This file is part of KQuickCharts
3 * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl>
4 *
5 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7
8#ifndef CHARTAXISSOURCE_H
9#define CHARTAXISSOURCE_H
10
11#include "ChartDataSource.h"
12
13class XYChart;
14
15/**
16 * A data source that provides values from a chart's axis as data.
17 */
18class QUICKCHARTS_EXPORT ChartAxisSource : public ChartDataSource
19{
20 Q_OBJECT
21 QML_ELEMENT
22
23public:
24 enum class Axis { XAxis, YAxis };
25 Q_ENUM(Axis)
26
27 /**
28 * Constructor
29 *
30 * @param parent TODO
31 */
32 ChartAxisSource(QObject *parent = nullptr);
33
34 Q_PROPERTY(XYChart *chart READ chart WRITE setChart NOTIFY chartChanged)
35 XYChart *chart() const;
36 Q_SLOT void setChart(XYChart *newChart);
37 Q_SIGNAL void chartChanged();
38
39 Q_PROPERTY(ChartAxisSource::Axis axis READ axis WRITE setAxis NOTIFY axisChanged)
40 ChartAxisSource::Axis axis() const;
41 Q_SLOT void setAxis(ChartAxisSource::Axis newAxis);
42 Q_SIGNAL void axisChanged();
43
44 Q_PROPERTY(int itemCount READ itemCount WRITE setItemCount NOTIFY itemCountChanged)
45 virtual int itemCount() const override;
46 Q_SLOT void setItemCount(int newItemCount);
47 Q_SIGNAL void itemCountChanged();
48
49 virtual QVariant item(int index) const override;
50 QVariant minimum() const override;
51 QVariant maximum() const override;
52
53private:
54 XYChart *m_chart = nullptr;
55 Axis m_axis = Axis::XAxis;
56 int m_itemCount = 2;
57};
58
59#endif // CHARTAXISSOURCE_H
A data source that provides values from a chart's axis as data.
Abstract base class for data sources.
A base class for Charts that are based on an X/Y grid.
Definition XYChart.h:33
Q_ENUM(...)
Q_PROPERTY(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:57 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.