summaryrefslogtreecommitdiffstats
path: root/src/barchart/vertical/bar
diff options
context:
space:
mode:
Diffstat (limited to 'src/barchart/vertical/bar')
-rw-r--r--src/barchart/vertical/bar/barchartitem.cpp125
-rw-r--r--src/barchart/vertical/bar/barchartitem_p.h57
-rw-r--r--src/barchart/vertical/bar/qbarseries.cpp124
-rw-r--r--src/barchart/vertical/bar/qbarseries.h45
-rw-r--r--src/barchart/vertical/bar/qbarseries_p.h52
5 files changed, 0 insertions, 403 deletions
diff --git a/src/barchart/vertical/bar/barchartitem.cpp b/src/barchart/vertical/bar/barchartitem.cpp
deleted file mode 100644
index 9a57325a..00000000
--- a/src/barchart/vertical/bar/barchartitem.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Enterprise Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "barchartitem_p.h"
-#include "bar_p.h"
-#include "qabstractbarseries_p.h"
-#include "qbarset.h"
-#include "qbarset_p.h"
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-BarChartItem::BarChartItem(QAbstractBarSeries *series, QGraphicsItem* item) :
- AbstractBarChartItem(series, item)
-{
- connect(series, SIGNAL(labelsPositionChanged(QAbstractBarSeries::LabelsPosition)),
- this, SLOT(handleLabelsPositionChanged()));
- connect(series, SIGNAL(labelsFormatChanged(QString)), this, SLOT(positionLabels()));
-}
-
-void BarChartItem::initializeLayout()
-{
- qreal categoryCount = m_series->d_func()->categoryCount();
- qreal setCount = m_series->count();
- qreal barWidth = m_series->d_func()->barWidth();
-
- m_layout.clear();
- for(int category = 0; category < categoryCount; category++) {
- for (int set = 0; set < setCount; set++) {
- QRectF rect;
- QPointF topLeft;
- QPointF bottomRight;
-
- if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) {
- topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + set/setCount * barWidth, domain()->minY()), m_validData);
- bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/setCount * barWidth, domain()->minY()), m_validData);
- } else {
- topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + set/setCount * barWidth, 0), m_validData);
- bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/setCount * barWidth, 0), m_validData);
- }
-
- if (!m_validData)
- return;
- rect.setTopLeft(topLeft);
- rect.setBottomRight(bottomRight);
- m_layout.append(rect.normalized());
- }
- }
-}
-
-QVector<QRectF> BarChartItem::calculateLayout()
-{
- QVector<QRectF> layout;
-
- // Use temporary qreals for accuracy
- qreal categoryCount = m_series->d_func()->categoryCount();
- qreal setCount = m_series->count();
- qreal barWidth = m_series->d_func()->barWidth();
-
- for(int category = 0; category < categoryCount; category++) {
- for (int set = 0; set < setCount; set++) {
- qreal value = m_series->barSets().at(set)->at(category);
- QRectF rect;
- QPointF topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set)/(setCount) * barWidth, value), m_validData);
- QPointF bottomRight;
- if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain)
- bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/(setCount) * barWidth, domain()->minY()), m_validData);
- else
- bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/(setCount) * barWidth, 0), m_validData);
-
- rect.setTopLeft(topLeft);
- rect.setBottomRight(bottomRight);
- layout.append(rect.normalized());
- }
- }
-
- return layout;
-}
-
-void BarChartItem::handleLabelsPositionChanged()
-{
- positionLabels();
-}
-
-void BarChartItem::positionLabels()
-{
- for (int i = 0; i < m_layout.count(); i++) {
- QGraphicsTextItem *label = m_labels.at(i);
- qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
- qreal yPos = 0;
-
- int offset = m_bars.at(i)->pen().width() / 2 + 2;
- if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
- yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
- else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
- yPos = m_layout.at(i).top() - offset;
- else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
- yPos = m_layout.at(i).bottom() - label->boundingRect().height() + offset;
- else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd)
- yPos = m_layout.at(i).top() - label->boundingRect().height() + offset;
-
- label->setPos(xPos, yPos);
- label->setZValue(zValue() + 1);
- }
-}
-
-#include "moc_barchartitem_p.cpp"
-
-QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/vertical/bar/barchartitem_p.h b/src/barchart/vertical/bar/barchartitem_p.h
deleted file mode 100644
index b94e9c34..00000000
--- a/src/barchart/vertical/bar/barchartitem_p.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Enterprise Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt Enterprise Chart API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-
-#ifndef BARCHARTITEM_H
-#define BARCHARTITEM_H
-
-#include "abstractbarchartitem_p.h"
-#include "qstackedbarseries.h"
-#include <QGraphicsItem>
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-class BarChartItem : public AbstractBarChartItem
-{
- Q_OBJECT
-public:
- BarChartItem(QAbstractBarSeries *series, QGraphicsItem* item = 0);
-
-private slots:
- void handleLabelsPositionChanged();
- void positionLabels();
-
-private:
- virtual QVector<QRectF> calculateLayout();
- void initializeLayout();
-};
-
-QTCOMMERCIALCHART_END_NAMESPACE
-
-#endif // BARCHARTITEM_H
diff --git a/src/barchart/vertical/bar/qbarseries.cpp b/src/barchart/vertical/bar/qbarseries.cpp
deleted file mode 100644
index 780f5837..00000000
--- a/src/barchart/vertical/bar/qbarseries.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Enterprise Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qbarseries.h"
-#include "qbarseries_p.h"
-#include "barchartitem_p.h"
-#include "chartdataset_p.h"
-#include "charttheme_p.h"
-#include "qvalueaxis.h"
-#include "qbarcategoryaxis.h"
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-/*!
- \class QBarSeries
- \inmodule Qt Charts
- \brief Series for creating bar chart.
- \mainclass
-
- QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars
- as groups, where bars in same category are grouped next to each other. QBarSeries groups the data
- from sets to categories, which are defined by a QStringList.
-
- See the \l {BarChart Example} {bar chart example} to learn how to create a grouped bar chart.
- \image examples_barchart.png
-
- \sa QBarSet, QPercentBarSeries, QAbstractBarSeries, QStackedBarSeries
-*/
-#ifdef QDOC_QT5
-/*!
- \qmltype BarSeries
- \instantiates QBarSeries
- \inqmlmodule QtCommercial.Chart
-
- \include doc/src/barseries.qdocinc
-*/
-#else
-/*!
- \qmlclass BarSeries QBarSeries
-
- \include ../doc/src/barseries.qdocinc
-*/
-#endif
-
-/*!
- Constructs empty QBarSeries.
- QBarSeries is QObject which is a child of a \a parent.
-*/
-QBarSeries::QBarSeries(QObject *parent)
- : QAbstractBarSeries(*new QBarSeriesPrivate(this), parent)
-{
-
-}
-
-/*!
- Returns QAbstractSeries::SeriesTypeBar.
-*/
-QAbstractSeries::SeriesType QBarSeries::type() const
-{
- return QAbstractSeries::SeriesTypeBar;
-}
-
-/*!
- Destructor. Removes series from chart.
-*/
-QBarSeries::~QBarSeries()
-{
- Q_D(QBarSeries);
- if (d->m_chart)
- d->m_chart->removeSeries(this);
-}
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : QAbstractBarSeriesPrivate(q)
-{
-
-}
-
-void QBarSeriesPrivate::initializeDomain()
-{
- qreal minX(domain()->minX());
- qreal minY(domain()->minY());
- qreal maxX(domain()->maxX());
- qreal maxY(domain()->maxY());
-
- qreal x = categoryCount();
- minX = qMin(minX, - (qreal)0.5);
- minY = qMin(minY, min());
- maxX = qMax(maxX, x - (qreal)0.5);
- maxY = qMax(maxY, max());
-
- domain()->setRange(minX, maxX, minY, maxY);
-}
-
-
-void QBarSeriesPrivate::initializeGraphics(QGraphicsItem* parent)
-{
- Q_Q(QBarSeries);
- BarChartItem *bar = new BarChartItem(q,parent);
- m_item.reset(bar);
- QAbstractSeriesPrivate::initializeGraphics(parent);
-}
-
-#include "moc_qbarseries.cpp"
-
-QTCOMMERCIALCHART_END_NAMESPACE
-
diff --git a/src/barchart/vertical/bar/qbarseries.h b/src/barchart/vertical/bar/qbarseries.h
deleted file mode 100644
index 4e38543e..00000000
--- a/src/barchart/vertical/bar/qbarseries.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Enterprise Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QBARSERIES_H
-#define QBARSERIES_H
-
-#include <qabstractbarseries.h>
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-class QBarSeriesPrivate;
-
-class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractBarSeries
-{
- Q_OBJECT
-public:
- explicit QBarSeries(QObject *parent = 0);
- ~QBarSeries();
- QAbstractSeries::SeriesType type() const;
-
-private:
- Q_DECLARE_PRIVATE(QBarSeries)
- Q_DISABLE_COPY(QBarSeries)
-};
-
-QTCOMMERCIALCHART_END_NAMESPACE
-
-#endif // QBARSERIES_H
diff --git a/src/barchart/vertical/bar/qbarseries_p.h b/src/barchart/vertical/bar/qbarseries_p.h
deleted file mode 100644
index e6d3a8a7..00000000
--- a/src/barchart/vertical/bar/qbarseries_p.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Enterprise Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt Enterprise Chart API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#ifndef QBARSERIES_P_H
-#define QBARSERIES_P_H
-
-#include "qabstractbarseries_p.h"
-#include "abstractdomain_p.h"
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-
-class QBarSeriesPrivate: public QAbstractBarSeriesPrivate
-{
-public:
- QBarSeriesPrivate(QBarSeries *q);
- void initializeGraphics(QGraphicsItem* parent);
- void initializeDomain();
-
-private:
- Q_DECLARE_PUBLIC(QBarSeries)
-};
-
-QTCOMMERCIALCHART_END_NAMESPACE
-
-#endif // QBARSERIES_P_H