8#include "ChartAxisSource.h"
18 connect(
this, &ChartAxisSource::itemCountChanged,
this, &ChartAxisSource::dataChanged);
19 connect(
this, &ChartAxisSource::chartChanged,
this, &ChartAxisSource::dataChanged);
20 connect(
this, &ChartAxisSource::axisChanged,
this, &ChartAxisSource::dataChanged);
23QVariant ChartAxisSource::item(
int index)
const
25 if (!m_chart || index < 0 || index > m_itemCount) {
30 if (m_axis == Axis::XAxis) {
31 return range.startX + (range.distanceX / (m_itemCount - 1)) * index;
33 return range.startY + (range.distanceY / (m_itemCount - 1)) * index;
37QVariant ChartAxisSource::minimum()
const
43 if (m_axis == Axis::XAxis) {
50QVariant ChartAxisSource::maximum()
const
56 if (m_axis == Axis::XAxis) {
63XYChart *ChartAxisSource::chart()
const
68void ChartAxisSource::setChart(
XYChart *newChart)
70 if (newChart == m_chart) {
85ChartAxisSource::Axis ChartAxisSource::axis()
const
90void ChartAxisSource::setAxis(ChartAxisSource::Axis newAxis)
92 if (newAxis == m_axis) {
100int ChartAxisSource::itemCount()
const
105void ChartAxisSource::setItemCount(
int newItemCount)
107 if (newItemCount == m_itemCount) {
111 m_itemCount = newItemCount;
112 Q_EMIT itemCountChanged();
115#include "moc_ChartAxisSource.cpp"
ChartAxisSource(QObject *parent=nullptr)
Constructor.
Abstract base class for data sources.
A base class for Charts that are based on an X/Y grid.
Q_SIGNAL void computedRangeChanged()
Emitted whenever the complete range is recalculated.
ComputedRange computedRange() const
Get the complete, calculated range for this chart.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)