@@ -0,0 +1,13 | |||
|
1 | INCLUDEPATH += $$PWD | |
|
2 | DEPENDPATH += $$PWD | |
|
3 | ||
|
4 | SOURCES += \ | |
|
5 | $$PWD/qhorizontalbarseries.cpp \ | |
|
6 | $$PWD/horizontalbarchartitem.cpp | |
|
7 | ||
|
8 | PRIVATE_HEADERS += \ | |
|
9 | $$PWD/qhorizontalbarseries_p.h \ | |
|
10 | $$PWD/horizontalbarchartitem_p.h | |
|
11 | ||
|
12 | PUBLIC_HEADERS += \ | |
|
13 | $$PWD/qhorizontalbarseries.h |
@@ -0,0 +1,3 | |||
|
1 | include(bar/bar.pri) | |
|
2 | include(percent/percent.pri) | |
|
3 | include(stacked/stacked.pri) No newline at end of file |
@@ -0,0 +1,13 | |||
|
1 | INCLUDEPATH += $$PWD | |
|
2 | DEPENDPATH += $$PWD | |
|
3 | ||
|
4 | SOURCES += \ | |
|
5 | $$PWD/qhorizontalpercentbarseries.cpp \ | |
|
6 | $$PWD/horizontalpercentbarchartitem.cpp | |
|
7 | ||
|
8 | PRIVATE_HEADERS += \ | |
|
9 | $$PWD/qhorizontalpercentbarseries_p.h \ | |
|
10 | $$PWD/horizontalpercentbarchartitem_p.h | |
|
11 | ||
|
12 | PUBLIC_HEADERS += \ | |
|
13 | $$PWD/qhorizontalpercentbarseries.h |
@@ -0,0 +1,15 | |||
|
1 | INCLUDEPATH += $$PWD | |
|
2 | DEPENDPATH += $$PWD | |
|
3 | ||
|
4 | SOURCES += \ | |
|
5 | $$PWD/qhorizontalstackedbarseries.cpp \ | |
|
6 | $$PWD/horizontalstackedbarchartitem.cpp | |
|
7 | ||
|
8 | ||
|
9 | PRIVATE_HEADERS += \ | |
|
10 | $$PWD/qhorizontalstackedbarseries_p.h \ | |
|
11 | $$PWD/horizontalstackedbarchartitem_p.h | |
|
12 | ||
|
13 | PUBLIC_HEADERS += \ | |
|
14 | $$PWD/qhorizontalstackedbarseries.h | |
|
15 |
@@ -0,0 +1,13 | |||
|
1 | INCLUDEPATH += $$PWD | |
|
2 | DEPENDPATH += $$PWD | |
|
3 | ||
|
4 | SOURCES += \ | |
|
5 | $$PWD/barchartitem.cpp \ | |
|
6 | $$PWD/qbarseries.cpp | |
|
7 | ||
|
8 | PRIVATE_HEADERS += \ | |
|
9 | $$PWD/barchartitem_p.h \ | |
|
10 | $$PWD/qbarseries_p.h | |
|
11 | ||
|
12 | PUBLIC_HEADERS += \ | |
|
13 | $$PWD/qbarseries.h |
@@ -0,0 +1,14 | |||
|
1 | INCLUDEPATH += $$PWD | |
|
2 | DEPENDPATH += $$PWD | |
|
3 | ||
|
4 | SOURCES += \ | |
|
5 | $$PWD/percentbarchartitem.cpp \ | |
|
6 | $$PWD/qpercentbarseries.cpp | |
|
7 | ||
|
8 | ||
|
9 | PRIVATE_HEADERS += \ | |
|
10 | $$PWD/percentbarchartitem_p.h \ | |
|
11 | $$PWD/qpercentbarseries_p.h | |
|
12 | ||
|
13 | PUBLIC_HEADERS += \ | |
|
14 | $$PWD/qpercentbarseries.h |
@@ -0,0 +1,13 | |||
|
1 | INCLUDEPATH += $$PWD | |
|
2 | DEPENDPATH += $$PWD | |
|
3 | ||
|
4 | SOURCES += \ | |
|
5 | $$PWD/qstackedbarseries.cpp \ | |
|
6 | $$PWD/stackedbarchartitem.cpp | |
|
7 | ||
|
8 | PRIVATE_HEADERS += \ | |
|
9 | $$PWD/stackedbarchartitem_p.h \ | |
|
10 | $$PWD/qstackedbarseries_p.h | |
|
11 | ||
|
12 | PUBLIC_HEADERS += \ | |
|
13 | $$PWD/qstackedbarseries.h |
@@ -0,0 +1,3 | |||
|
1 | include(bar/bar.pri) | |
|
2 | include(percent/percent.pri) | |
|
3 | include(stacked/stacked.pri) No newline at end of file |
@@ -1,55 +1,28 | |||
|
1 | include(vertical/vertical.pri) | |
|
2 | include(horizontal/horizontal.pri) | |
|
3 | ||
|
1 | 4 | INCLUDEPATH += $$PWD |
|
2 | 5 | DEPENDPATH += $$PWD |
|
3 | 6 | |
|
4 | 7 | SOURCES += \ |
|
5 | 8 | $$PWD/bar.cpp \ |
|
6 | 9 | $$PWD/abstractbarchartitem.cpp \ |
|
7 | $$PWD/percentbarchartitem.cpp \ | |
|
8 | $$PWD/barchartitem.cpp \ | |
|
9 | 10 | $$PWD/qabstractbarseries.cpp \ |
|
10 | 11 | $$PWD/qbarset.cpp \ |
|
11 | $$PWD/qpercentbarseries.cpp \ | |
|
12 | $$PWD/qstackedbarseries.cpp \ | |
|
13 | $$PWD/qbarseries.cpp \ | |
|
14 | $$PWD/stackedbarchartitem.cpp \ | |
|
15 | 12 | $$PWD/qbarmodelmapper.cpp \ |
|
16 | 13 | $$PWD/qvbarmodelmapper.cpp \ |
|
17 | 14 | $$PWD/qhbarmodelmapper.cpp \ |
|
18 | $$PWD/qhorizontalbarseries.cpp \ | |
|
19 | $$PWD/horizontalbarchartitem.cpp \ | |
|
20 | $$PWD/qhorizontalstackedbarseries.cpp \ | |
|
21 | $$PWD/horizontalstackedbarchartitem.cpp \ | |
|
22 | $$PWD/qhorizontalpercentbarseries.cpp \ | |
|
23 | $$PWD/horizontalpercentbarchartitem.cpp | |
|
24 | 15 | |
|
25 | 16 | PRIVATE_HEADERS += \ |
|
26 | 17 | $$PWD/bar_p.h \ |
|
27 | $$PWD/abstractbarchartitem_p.h \ | |
|
28 | $$PWD/percentbarchartitem_p.h \ | |
|
29 | $$PWD/stackedbarchartitem_p.h \ | |
|
30 | $$PWD/barchartitem_p.h \ | |
|
31 | 18 | $$PWD/qbarset_p.h \ |
|
19 | $$PWD/abstractbarchartitem_p.h \ | |
|
32 | 20 | $$PWD/qabstractbarseries_p.h \ |
|
33 |
$$PWD/q |
|
|
34 | $$PWD/qpercentbarseries_p.h \ | |
|
35 | $$PWD/qbarseries_p.h \ | |
|
36 | $$PWD/qbarmodelmapper_p.h \ | |
|
37 | $$PWD/qhorizontalbarseries_p.h \ | |
|
38 | $$PWD/horizontalbarchartitem_p.h \ | |
|
39 | $$PWD/qhorizontalstackedbarseries_p.h \ | |
|
40 | $$PWD/horizontalstackedbarchartitem_p.h \ | |
|
41 | $$PWD/qhorizontalpercentbarseries_p.h \ | |
|
42 | $$PWD/horizontalpercentbarchartitem_p.h | |
|
21 | $$PWD/qbarmodelmapper_p.h | |
|
43 | 22 | |
|
44 | 23 | PUBLIC_HEADERS += \ |
|
45 | 24 | $$PWD/qabstractbarseries.h \ |
|
46 | 25 | $$PWD/qbarset.h \ |
|
47 | $$PWD/qpercentbarseries.h \ | |
|
48 | $$PWD/qstackedbarseries.h \ | |
|
49 | $$PWD/qbarseries.h \ | |
|
50 | 26 | $$PWD/qbarmodelmapper.h \ |
|
51 | 27 | $$PWD/qvbarmodelmapper.h \ |
|
52 |
$$PWD/qhbarmodelmapper.h |
|
|
53 | $$PWD/qhorizontalbarseries.h \ | |
|
54 | $$PWD/qhorizontalstackedbarseries.h \ | |
|
55 | $$PWD/qhorizontalpercentbarseries.h | |
|
28 | $$PWD/qhbarmodelmapper.h |
|
1 | NO CONTENT: file renamed from src/barchart/horizontalbarchartitem.cpp to src/barchart/horizontal/bar/horizontalbarchartitem.cpp |
|
1 | NO CONTENT: file renamed from src/barchart/horizontalbarchartitem_p.h to src/barchart/horizontal/bar/horizontalbarchartitem_p.h |
@@ -1,89 +1,82 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
1 | 21 | #include "qhorizontalbarseries.h" |
|
2 | 22 | #include "qhorizontalbarseries_p.h" |
|
3 | 23 | #include "horizontalbarchartitem_p.h" |
|
4 | 24 | #include "horizontalbaranimation_p.h" |
|
5 | 25 | #include "qbarcategoriesaxis.h" |
|
6 | 26 | |
|
7 | 27 | #include "chartdataset_p.h" |
|
8 | 28 | #include "charttheme_p.h" |
|
9 | 29 | |
|
10 | 30 | |
|
11 | 31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
12 | 32 | |
|
13 | 33 | QHorizontalBarSeries::QHorizontalBarSeries(QObject *parent) : |
|
14 | 34 | QAbstractBarSeries(*new QHorizontalBarSeriesPrivate(this), parent) |
|
15 | 35 | { |
|
16 | 36 | } |
|
17 | 37 | |
|
18 | 38 | QAbstractSeries::SeriesType QHorizontalBarSeries::type() const |
|
19 | 39 | { |
|
20 | 40 | return QAbstractSeries::SeriesTypeHorizontalBar; |
|
21 | 41 | } |
|
22 | 42 | |
|
23 | ||
|
24 | ||
|
25 | 43 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
26 | 44 | |
|
27 | 45 | QHorizontalBarSeriesPrivate::QHorizontalBarSeriesPrivate(QHorizontalBarSeries *q) : QAbstractBarSeriesPrivate(q) |
|
28 | 46 | { |
|
29 | 47 | |
|
30 | 48 | } |
|
31 | 49 | |
|
32 | 50 | void QHorizontalBarSeriesPrivate::scaleDomain(Domain& domain) |
|
33 | 51 | { |
|
34 | 52 | qreal minX(domain.minX()); |
|
35 | 53 | qreal minY(domain.minY()); |
|
36 | 54 | qreal maxX(domain.maxX()); |
|
37 | 55 | qreal maxY(domain.maxY()); |
|
38 | 56 | |
|
39 | 57 | qreal y = categoryCount(); |
|
40 | 58 | qreal x = max(); |
|
41 | 59 | minX = qMin(minX, x); |
|
42 | 60 | minY = qMin(minY, - (qreal)0.5); |
|
43 | 61 | maxX = qMax(maxX, x); |
|
44 | 62 | maxY = qMax(maxY, y - (qreal)0.5); |
|
45 | 63 | |
|
46 | 64 | domain.setRange(minX,maxX,minY,maxY); |
|
47 | 65 | } |
|
48 | 66 | |
|
49 | ||
|
50 | 67 | Chart* QHorizontalBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
51 | 68 | { |
|
52 | 69 | Q_Q(QHorizontalBarSeries); |
|
53 | 70 | |
|
54 | 71 | HorizontalBarChartItem* bar = new HorizontalBarChartItem(q,presenter); |
|
55 | 72 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
56 | 73 | bar->setAnimator(presenter->animator()); |
|
57 | 74 | bar->setAnimation(new HorizontalBarAnimation(bar)); |
|
58 | 75 | } |
|
59 | 76 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
60 | 77 | return bar; |
|
61 | 78 | } |
|
62 | 79 | |
|
63 | void QHorizontalBarSeriesPrivate::initializeAxis(QAbstractAxis* axis) | |
|
64 | { | |
|
65 | ||
|
66 | if(axis->type()==QAbstractAxis::AxisTypeCategories && axis->orientation()==Qt::Vertical) | |
|
67 | { | |
|
68 | QBarCategoriesAxis* cataxis = qobject_cast<QBarCategoriesAxis*>(axis); | |
|
69 | Q_ASSERT(cataxis); | |
|
70 | QStringList categories; | |
|
71 | if(cataxis->categories().isEmpty()){ | |
|
72 | for (int i(1); i < categoryCount()+1; i++) | |
|
73 | categories << QString::number(i); | |
|
74 | cataxis->append(categories); | |
|
75 | } | |
|
76 | } | |
|
77 | } | |
|
78 | ||
|
79 | QAbstractAxis::AxisType QHorizontalBarSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
|
80 | { | |
|
81 | if(orientation==Qt::Vertical) | |
|
82 | return QAbstractAxis::AxisTypeCategories; | |
|
83 | else | |
|
84 | return QAbstractAxis::AxisTypeValues; | |
|
85 | } | |
|
86 | ||
|
87 | 80 | #include "moc_qhorizontalbarseries.cpp" |
|
88 | 81 | |
|
89 | 82 | QTCOMMERCIALCHART_END_NAMESPACE |
|
1 | NO CONTENT: file renamed from src/barchart/qhorizontalbarseries.h to src/barchart/horizontal/bar/qhorizontalbarseries.h |
@@ -1,53 +1,50 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef QHORIZONTALBARSERIES_P_H |
|
31 | 31 | #define QHORIZONTALBARSERIES_P_H |
|
32 | 32 | |
|
33 | 33 | #include "qabstractbarseries_p.h" |
|
34 | 34 | #include "domain_p.h" |
|
35 | 35 | |
|
36 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | 37 | |
|
38 | 38 | class QHorizontalBarSeriesPrivate: public QAbstractBarSeriesPrivate |
|
39 | 39 | { |
|
40 | 40 | public: |
|
41 | 41 | QHorizontalBarSeriesPrivate(QHorizontalBarSeries* q); |
|
42 | 42 | Chart* createGraphics(ChartPresenter* presenter); |
|
43 | 43 | void scaleDomain(Domain& domain); |
|
44 | void initializeAxis(QAbstractAxis* axis); | |
|
45 | QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const; | |
|
46 | ||
|
47 | 44 | private: |
|
48 | 45 | Q_DECLARE_PUBLIC(QHorizontalBarSeries) |
|
49 | 46 | }; |
|
50 | 47 | |
|
51 | 48 | QTCOMMERCIALCHART_END_NAMESPACE |
|
52 | 49 | |
|
53 | 50 | #endif // QHORIZONTALBARSERIES_P_H |
|
1 | NO CONTENT: file renamed from src/barchart/horizontalpercentbarchartitem.cpp to src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp |
|
1 | NO CONTENT: file renamed from src/barchart/horizontalpercentbarchartitem_p.h to src/barchart/horizontal/percent/horizontalpercentbarchartitem_p.h |
|
1 | NO CONTENT: file renamed from src/barchart/qhorizontalpercentbarseries.cpp to src/barchart/horizontal/percent/qhorizontalpercentbarseries.cpp |
|
1 | NO CONTENT: file renamed from src/barchart/qhorizontalpercentbarseries.h to src/barchart/horizontal/percent/qhorizontalpercentbarseries.h |
@@ -1,51 +1,50 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef QHORIZONTALPERCENTBARSERIES_P_H |
|
31 | 31 | #define QHORIZONTALPERCENTBARSERIES_P_H |
|
32 | 32 | |
|
33 | 33 | #include "qabstractbarseries_p.h" |
|
34 | 34 | #include "domain_p.h" |
|
35 | 35 | |
|
36 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | 37 | |
|
38 | 38 | class QHorizontalPercentBarSeriesPrivate: public QAbstractBarSeriesPrivate |
|
39 | 39 | { |
|
40 | 40 | public: |
|
41 | 41 | QHorizontalPercentBarSeriesPrivate(QHorizontalPercentBarSeries* q); |
|
42 | 42 | Chart* createGraphics(ChartPresenter* presenter); |
|
43 | 43 | void scaleDomain(Domain& domain); |
|
44 | ||
|
45 | 44 | private: |
|
46 | 45 | Q_DECLARE_PUBLIC(QHorizontalPercentBarSeries) |
|
47 | 46 | }; |
|
48 | 47 | |
|
49 | 48 | QTCOMMERCIALCHART_END_NAMESPACE |
|
50 | 49 | |
|
51 | 50 | #endif // QHORIZONTALPERCENTBARSERIES_P_H |
|
1 | NO CONTENT: file renamed from src/barchart/horizontalstackedbarchartitem.cpp to src/barchart/horizontal/stacked/horizontalstackedbarchartitem.cpp |
|
1 | NO CONTENT: file renamed from src/barchart/horizontalstackedbarchartitem_p.h to src/barchart/horizontal/stacked/horizontalstackedbarchartitem_p.h |
@@ -1,73 +1,62 | |||
|
1 | 1 | #include "qhorizontalstackedbarseries.h" |
|
2 | 2 | #include "qhorizontalstackedbarseries_p.h" |
|
3 | 3 | #include "horizontalstackedbarchartitem_p.h" |
|
4 | 4 | #include "horizontalstackedbaranimation_p.h" |
|
5 | 5 | |
|
6 | 6 | #include "chartdataset_p.h" |
|
7 | 7 | #include "charttheme_p.h" |
|
8 | 8 | |
|
9 | 9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | 10 | |
|
11 | 11 | QHorizontalStackedBarSeries::QHorizontalStackedBarSeries(QObject *parent) : |
|
12 | 12 | QAbstractBarSeries(*new QHorizontalStackedBarSeriesPrivate(this), parent) |
|
13 | 13 | { |
|
14 | 14 | } |
|
15 | 15 | |
|
16 | 16 | QAbstractSeries::SeriesType QHorizontalStackedBarSeries::type() const |
|
17 | 17 | { |
|
18 | 18 | return QAbstractSeries::SeriesTypeHorizontalStackedBar; |
|
19 | 19 | } |
|
20 | 20 | |
|
21 | 21 | |
|
22 | 22 | |
|
23 | 23 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
24 | 24 | |
|
25 | 25 | QHorizontalStackedBarSeriesPrivate::QHorizontalStackedBarSeriesPrivate(QHorizontalStackedBarSeries *q) : QAbstractBarSeriesPrivate(q) |
|
26 | 26 | { |
|
27 | 27 | |
|
28 | 28 | } |
|
29 | 29 | |
|
30 | 30 | void QHorizontalStackedBarSeriesPrivate::scaleDomain(Domain& domain) |
|
31 | 31 | { |
|
32 | 32 | qreal minX(domain.minX()); |
|
33 | 33 | qreal minY(domain.minY()); |
|
34 | 34 | qreal maxX(domain.maxX()); |
|
35 | 35 | qreal maxY(domain.maxY()); |
|
36 | 36 | |
|
37 | 37 | qreal y = categoryCount(); |
|
38 | 38 | qreal x = maxCategorySum(); |
|
39 | 39 | minX = qMin(minX, x); |
|
40 | 40 | minY = qMin(minY, - (qreal)0.5); |
|
41 | 41 | maxX = qMax(maxX, x); |
|
42 | 42 | maxY = qMax(maxY, y - (qreal)0.5); |
|
43 | 43 | |
|
44 | 44 | domain.setRange(minX,maxX,minY,maxY); |
|
45 | 45 | } |
|
46 | 46 | |
|
47 | 47 | Chart* QHorizontalStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
48 | 48 | { |
|
49 | 49 | Q_Q(QHorizontalStackedBarSeries); |
|
50 | 50 | |
|
51 | 51 | HorizontalStackedBarChartItem* bar = new HorizontalStackedBarChartItem(q,presenter); |
|
52 | 52 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
53 | 53 | bar->setAnimator(presenter->animator()); |
|
54 | 54 | bar->setAnimation(new HorizontalStackedBarAnimation(bar)); |
|
55 | 55 | } |
|
56 | 56 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
57 | 57 | return bar; |
|
58 | 58 | } |
|
59 | 59 | |
|
60 | QAbstractAxis::AxisType QHorizontalStackedBarSeriesPrivate::defaultAxisXType() const | |
|
61 | { | |
|
62 | return QAbstractAxis::AxisTypeValues; | |
|
63 | } | |
|
64 | ||
|
65 | QAbstractAxis::AxisType QHorizontalStackedBarSeriesPrivate::defaultAxisYType() const | |
|
66 | { | |
|
67 | return QAbstractAxis::AxisTypeCategories; | |
|
68 | } | |
|
69 | ||
|
70 | ||
|
71 | 60 | #include "moc_qhorizontalstackedbarseries.cpp" |
|
72 | 61 | |
|
73 | 62 | QTCOMMERCIALCHART_END_NAMESPACE |
|
1 | NO CONTENT: file renamed from src/barchart/qhorizontalstackedbarseries.h to src/barchart/horizontal/stacked/qhorizontalstackedbarseries.h |
@@ -1,53 +1,50 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef QHORIZONTALSTACKEDBARSERIES_P_H |
|
31 | 31 | #define QHORIZONTALSTACKEDBARSERIES_P_H |
|
32 | 32 | |
|
33 | 33 | #include "qabstractbarseries_p.h" |
|
34 | 34 | #include "domain_p.h" |
|
35 | 35 | |
|
36 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | 37 | |
|
38 | 38 | class QHorizontalStackedBarSeriesPrivate: public QAbstractBarSeriesPrivate |
|
39 | 39 | { |
|
40 | 40 | public: |
|
41 | 41 | QHorizontalStackedBarSeriesPrivate(QHorizontalStackedBarSeries* q); |
|
42 | 42 | Chart* createGraphics(ChartPresenter* presenter); |
|
43 | 43 | void scaleDomain(Domain& domain); |
|
44 | QAbstractAxis::AxisType defaultAxisXType() const; | |
|
45 | QAbstractAxis::AxisType defaultAxisYType() const; | |
|
46 | ||
|
47 | 44 | private: |
|
48 | 45 | Q_DECLARE_PUBLIC(QHorizontalStackedBarSeries) |
|
49 | 46 | }; |
|
50 | 47 | |
|
51 | 48 | QTCOMMERCIALCHART_END_NAMESPACE |
|
52 | 49 | |
|
53 | 50 | #endif // QHORIZONTALSTACKEDBARSERIES_P_H |
@@ -1,728 +1,786 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qabstractbarseries.h" |
|
22 | 22 | #include "qabstractbarseries_p.h" |
|
23 | 23 | #include "qbarset.h" |
|
24 | 24 | #include "qbarset_p.h" |
|
25 | 25 | #include "domain_p.h" |
|
26 | 26 | #include "legendmarker_p.h" |
|
27 | 27 | #include "chartdataset_p.h" |
|
28 | 28 | #include "charttheme_p.h" |
|
29 | 29 | #include "chartanimator_p.h" |
|
30 | 30 | #include "qvaluesaxis.h" |
|
31 | 31 | #include "qbarcategoriesaxis.h" |
|
32 | 32 | |
|
33 | 33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | 34 | |
|
35 | 35 | /*! |
|
36 | 36 | \class QAbstractBarSeries |
|
37 | 37 | \brief Series for creating a bar chart |
|
38 | 38 | \mainclass |
|
39 | 39 | |
|
40 | 40 | QAbstractBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to |
|
41 | 41 | the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar |
|
42 | 42 | and y-value is the height of the bar. The category names are ignored with this series and x-axis |
|
43 | 43 | shows the x-values. |
|
44 | 44 | |
|
45 | 45 | See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart. |
|
46 | 46 | \image examples_barchart.png |
|
47 | 47 | |
|
48 | 48 | \sa QBarSet, QStackedBarSeries, QPercentBarSeries |
|
49 | 49 | */ |
|
50 | 50 | /*! |
|
51 | 51 | \qmlclass AbstractBarSeries QAbstractBarSeries |
|
52 | 52 | \inherits QAbstractSeries |
|
53 | 53 | |
|
54 | 54 | The following QML shows how to create a simple bar chart: |
|
55 | 55 | \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1 |
|
56 | 56 | |
|
57 | 57 | \beginfloatleft |
|
58 | 58 | \image demos_qmlchart6.png |
|
59 | 59 | \endfloat |
|
60 | 60 | \clearfloat |
|
61 | 61 | */ |
|
62 | 62 | |
|
63 | 63 | /*! |
|
64 | 64 | \property QAbstractBarSeries::barWidth |
|
65 | 65 | The width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars |
|
66 | 66 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen |
|
67 | 67 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. |
|
68 | 68 | Note that with QBarSeries this value means the width of one group of bars instead of just one bar. |
|
69 | 69 | \sa QBarSeries |
|
70 | 70 | */ |
|
71 | 71 | /*! |
|
72 | 72 | \qmlproperty real AbstractBarSeries::barWidth |
|
73 | 73 | The width of the bars of the series. The unit of width is the unit of x-axis. The minimum width for bars |
|
74 | 74 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen |
|
75 | 75 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. |
|
76 | 76 | Note that with QBarSeries this value means the width of one group of bars instead of just one bar. |
|
77 | 77 | */ |
|
78 | 78 | |
|
79 | 79 | /*! |
|
80 | 80 | \property QAbstractBarSeries::count |
|
81 | 81 | Holds the number of sets in series. |
|
82 | 82 | */ |
|
83 | 83 | /*! |
|
84 | 84 | \qmlproperty int AbstractBarSeries::count |
|
85 | 85 | Holds the number of sets in series. |
|
86 | 86 | */ |
|
87 | 87 | |
|
88 | 88 | /*! |
|
89 | 89 | \property QAbstractBarSeries::labelsVisible |
|
90 | 90 | Defines the visibility of the labels in series |
|
91 | 91 | */ |
|
92 | 92 | /*! |
|
93 | 93 | \qmlproperty bool AbstractBarSeries::labelsVisible |
|
94 | 94 | Defines the visibility of the labels in series |
|
95 | 95 | */ |
|
96 | 96 | |
|
97 | 97 | /*! |
|
98 | 98 | \fn void QAbstractBarSeries::clicked(int index, QBarSet *barset) |
|
99 | 99 | The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset. |
|
100 | 100 | Clicked bar inside set is indexed by \a index |
|
101 | 101 | */ |
|
102 | 102 | /*! |
|
103 | 103 | \qmlsignal AbstractBarSeries::onClicked(int index, BarSet barset) |
|
104 | 104 | The signal is emitted if the user clicks with a mouse on top of BarSet. |
|
105 | 105 | Clicked bar inside set is indexed by \a index |
|
106 | 106 | */ |
|
107 | 107 | |
|
108 | 108 | /*! |
|
109 | 109 | \fn void QAbstractBarSeries::hovered(bool status, QBarSet* barset) |
|
110 | 110 | |
|
111 | 111 | The signal is emitted if mouse is hovered on top of series. |
|
112 | 112 | Parameter \a barset is the pointer of barset, where hover happened. |
|
113 | 113 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. |
|
114 | 114 | */ |
|
115 | 115 | /*! |
|
116 | 116 | \qmlsignal AbstractBarSeries::onHovered(bool status, BarSet barset) |
|
117 | 117 | |
|
118 | 118 | The signal is emitted if mouse is hovered on top of series. |
|
119 | 119 | Parameter \a barset is the pointer of barset, where hover happened. |
|
120 | 120 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. |
|
121 | 121 | */ |
|
122 | 122 | |
|
123 | 123 | /*! |
|
124 | 124 | \fn void QAbstractBarSeries::countChanged() |
|
125 | 125 | This signal is emitted when barset count has been changed, for example by append or remove. |
|
126 | 126 | */ |
|
127 | 127 | /*! |
|
128 | 128 | \qmlsignal AbstractBarSeries::onCountChanged() |
|
129 | 129 | This signal is emitted when barset count has been changed, for example by append or remove. |
|
130 | 130 | */ |
|
131 | 131 | |
|
132 | 132 | /*! |
|
133 | 133 | \fn void QAbstractBarSeries::labelsVisibleChanged() |
|
134 | 134 | This signal is emitted when labels visibility have changed. |
|
135 | 135 | \sa isLabelsVisible(), setLabelsVisible() |
|
136 | 136 | */ |
|
137 | 137 | |
|
138 | 138 | /*! |
|
139 | 139 | \fn void QAbstractBarSeries::barsetsAdded(QList<QBarSet*> sets) |
|
140 | 140 | This signal is emitted when \a sets have been added to the series. |
|
141 | 141 | \sa append(), insert() |
|
142 | 142 | */ |
|
143 | 143 | /*! |
|
144 | 144 | \qmlsignal AbstractBarSeries::onAdded(BarSet barset) |
|
145 | 145 | Emitted when \a barset has been added to the series. |
|
146 | 146 | */ |
|
147 | 147 | |
|
148 | 148 | /*! |
|
149 | 149 | \fn void QAbstractBarSeries::barsetsRemoved(QList<QBarSet*> sets) |
|
150 | 150 | This signal is emitted when \a sets have been removed from the series. |
|
151 | 151 | \sa remove() |
|
152 | 152 | */ |
|
153 | 153 | /*! |
|
154 | 154 | \qmlsignal AbstractBarSeries::onRemoved(BarSet barset) |
|
155 | 155 | Emitted when \a barset has been removed from the series. |
|
156 | 156 | */ |
|
157 | 157 | |
|
158 | 158 | /*! |
|
159 | 159 | \qmlmethod BarSet AbstractBarSeries::at(int index) |
|
160 | 160 | Returns bar set at \a index. Returns null if the index is not valid. |
|
161 | 161 | */ |
|
162 | 162 | |
|
163 | 163 | /*! |
|
164 | 164 | \qmlmethod BarSet AbstractBarSeries::append(string label, VariantList values) |
|
165 | 165 | Adds a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints. |
|
166 | 166 | For example: |
|
167 | 167 | \code |
|
168 | 168 | myBarSeries.append("set 1", [0, 0.2, 0.2, 0.5, 0.4, 1.5, 0.9]); |
|
169 | 169 | myBarSeries.append("set 2", [Qt.point(0, 1), Qt.point(2, 2.5), Qt.point(3.5, 2.2)]); |
|
170 | 170 | \endcode |
|
171 | 171 | */ |
|
172 | 172 | |
|
173 | 173 | /*! |
|
174 | 174 | \qmlmethod BarSet AbstractBarSeries::insert(int index, string label, VariantList values) |
|
175 | 175 | Inserts a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints. |
|
176 | 176 | If index is zero or smaller, the new barset is prepended. If the index is count or bigger, the new barset is |
|
177 | 177 | appended. |
|
178 | 178 | \sa AbstractBarSeries::append() |
|
179 | 179 | */ |
|
180 | 180 | |
|
181 | 181 | /*! |
|
182 | 182 | \qmlmethod bool AbstractBarSeries::remove(BarSet barset) |
|
183 | 183 | Removes the barset from the series. Returns true if successfull, false otherwise. |
|
184 | 184 | */ |
|
185 | 185 | |
|
186 | 186 | /*! |
|
187 | 187 | \qmlmethod AbstractBarSeries::clear() |
|
188 | 188 | Removes all barsets from the series. |
|
189 | 189 | */ |
|
190 | 190 | |
|
191 | 191 | /*! |
|
192 | Constructs empty QAbstractBarSeries. | |
|
193 | QAbstractBarSeries is QObject which is a child of a \a parent. | |
|
192 | This is depreciated constructor. | |
|
194 | 193 | */ |
|
195 | 194 | QAbstractBarSeries::QAbstractBarSeries(QObject *parent) : |
|
196 |
QAbstractSeries(* |
|
|
195 | QAbstractSeries(*(QAbstractBarSeriesPrivate*)(0),parent) | |
|
197 | 196 | { |
|
198 | 197 | } |
|
199 | 198 | |
|
200 | 199 | /*! |
|
201 | 200 | Destructs abstractbarseries and owned barsets. |
|
202 | 201 | */ |
|
203 | 202 | QAbstractBarSeries::~QAbstractBarSeries() |
|
204 | 203 | { |
|
205 | 204 | Q_D(QAbstractBarSeries); |
|
206 | 205 | if(d->m_dataset){ |
|
207 | 206 | d->m_dataset->removeSeries(this); |
|
208 | 207 | } |
|
209 | 208 | } |
|
210 | 209 | |
|
211 | 210 | /*! |
|
212 | 211 | \internal |
|
213 | 212 | */ |
|
214 | 213 | QAbstractBarSeries::QAbstractBarSeries(QAbstractBarSeriesPrivate &d, QObject *parent) : |
|
215 | 214 | QAbstractSeries(d,parent) |
|
216 | 215 | { |
|
217 | 216 | } |
|
218 | 217 | |
|
219 | 218 | /*! |
|
220 | 219 | Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars |
|
221 | 220 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen |
|
222 | 221 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. |
|
223 | 222 | Note that with \link QBarSeries \endlink this value means the width of one group of bars instead of just one bar. |
|
224 | 223 | */ |
|
225 | 224 | void QAbstractBarSeries::setBarWidth(qreal width) |
|
226 | 225 | { |
|
227 | 226 | Q_D(QAbstractBarSeries); |
|
228 | 227 | d->setBarWidth(width); |
|
229 | 228 | } |
|
230 | 229 | |
|
231 | 230 | /*! |
|
232 | 231 | Returns the width of the bars of the series. |
|
233 | 232 | \sa setBarWidth() |
|
234 | 233 | */ |
|
235 | 234 | qreal QAbstractBarSeries::barWidth() const |
|
236 | 235 | { |
|
237 | 236 | Q_D(const QAbstractBarSeries); |
|
238 | 237 | return d->barWidth(); |
|
239 | 238 | } |
|
240 | 239 | |
|
241 | 240 | /*! |
|
242 | 241 | Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. |
|
243 | 242 | Returns true, if appending succeeded. |
|
244 | 243 | */ |
|
245 | 244 | bool QAbstractBarSeries::append(QBarSet *set) |
|
246 | 245 | { |
|
247 | 246 | Q_D(QAbstractBarSeries); |
|
248 | 247 | bool success = d->append(set); |
|
249 | 248 | if (success) { |
|
250 | 249 | QList<QBarSet*> sets; |
|
251 | 250 | sets.append(set); |
|
252 | 251 | emit barsetsAdded(sets); |
|
253 | 252 | emit countChanged(); |
|
254 | 253 | } |
|
255 | 254 | return success; |
|
256 | 255 | } |
|
257 | 256 | |
|
258 | 257 | /*! |
|
259 | 258 | Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set. |
|
260 | 259 | Returns true, if set was removed. |
|
261 | 260 | */ |
|
262 | 261 | bool QAbstractBarSeries::remove(QBarSet *set) |
|
263 | 262 | { |
|
264 | 263 | Q_D(QAbstractBarSeries); |
|
265 | 264 | bool success = d->remove(set); |
|
266 | 265 | if (success) { |
|
267 | 266 | QList<QBarSet*> sets; |
|
268 | 267 | sets.append(set); |
|
269 | 268 | emit barsetsRemoved(sets); |
|
270 | 269 | emit countChanged(); |
|
271 | 270 | } |
|
272 | 271 | return success; |
|
273 | 272 | } |
|
274 | 273 | |
|
275 | 274 | /*! |
|
276 | 275 | Adds a list of barsets to series. Takes ownership of \a sets. |
|
277 | 276 | Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series, |
|
278 | 277 | nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended |
|
279 | 278 | and function returns false. |
|
280 | 279 | */ |
|
281 | 280 | bool QAbstractBarSeries::append(QList<QBarSet* > sets) |
|
282 | 281 | { |
|
283 | 282 | Q_D(QAbstractBarSeries); |
|
284 | 283 | bool success = d->append(sets); |
|
285 | 284 | if (success) { |
|
286 | 285 | emit barsetsAdded(sets); |
|
287 | 286 | emit countChanged(); |
|
288 | 287 | } |
|
289 | 288 | return success; |
|
290 | 289 | } |
|
291 | 290 | |
|
292 | 291 | /*! |
|
293 | 292 | Insert a set of bars to series at \a index postion. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. |
|
294 | 293 | Returns true, if inserting succeeded. |
|
295 | 294 | |
|
296 | 295 | */ |
|
297 | 296 | bool QAbstractBarSeries::insert(int index, QBarSet *set) |
|
298 | 297 | { |
|
299 | 298 | Q_D(QAbstractBarSeries); |
|
300 | 299 | bool success = d->insert(index, set); |
|
301 | 300 | if (success) { |
|
302 | 301 | QList<QBarSet*> sets; |
|
303 | 302 | sets.append(set); |
|
304 | 303 | emit barsetsAdded(sets); |
|
305 | 304 | emit countChanged(); |
|
306 | 305 | } |
|
307 | 306 | return success; |
|
308 | 307 | } |
|
309 | 308 | |
|
310 | 309 | /*! |
|
311 | 310 | Removes all of the bar sets from the series |
|
312 | 311 | */ |
|
313 | 312 | void QAbstractBarSeries::clear() |
|
314 | 313 | { |
|
315 | 314 | Q_D(QAbstractBarSeries); |
|
316 | 315 | QList<QBarSet *> sets = barSets(); |
|
317 | 316 | bool success = d->remove(sets); |
|
318 | 317 | if (success) { |
|
319 | 318 | emit barsetsRemoved(sets); |
|
320 | 319 | emit countChanged(); |
|
321 | 320 | } |
|
322 | 321 | } |
|
323 | 322 | |
|
324 | 323 | /*! |
|
325 | 324 | Returns number of sets in series. |
|
326 | 325 | */ |
|
327 | 326 | int QAbstractBarSeries::count() const |
|
328 | 327 | { |
|
329 | 328 | Q_D(const QAbstractBarSeries); |
|
330 | 329 | return d->m_barSets.count(); |
|
331 | 330 | } |
|
332 | 331 | |
|
333 | 332 | /*! |
|
334 | 333 | Returns a list of sets in series. Keeps ownership of sets. |
|
335 | 334 | */ |
|
336 | 335 | QList<QBarSet*> QAbstractBarSeries::barSets() const |
|
337 | 336 | { |
|
338 | 337 | Q_D(const QAbstractBarSeries); |
|
339 | 338 | return d->m_barSets; |
|
340 | 339 | } |
|
341 | 340 | |
|
342 | 341 | /*! |
|
343 | 342 | Sets the visibility of labels in series to \a visible |
|
344 | 343 | */ |
|
345 | 344 | void QAbstractBarSeries::setLabelsVisible(bool visible) |
|
346 | 345 | { |
|
347 | 346 | Q_D(QAbstractBarSeries); |
|
348 | 347 | if (d->m_labelsVisible != visible) { |
|
349 | 348 | d->setLabelsVisible(visible); |
|
350 | 349 | emit labelsVisibleChanged(); |
|
351 | 350 | } |
|
352 | 351 | } |
|
353 | 352 | |
|
354 | 353 | /*! |
|
355 | 354 | Returns the visibility of labels |
|
356 | 355 | */ |
|
357 | 356 | bool QAbstractBarSeries::isLabelsVisible() const |
|
358 | 357 | { |
|
359 | 358 | Q_D(const QAbstractBarSeries); |
|
360 | 359 | return d->m_labelsVisible; |
|
361 | 360 | } |
|
362 | 361 | |
|
363 | 362 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
364 | 363 | |
|
365 | 364 | QAbstractBarSeriesPrivate::QAbstractBarSeriesPrivate(QAbstractBarSeries *q) : |
|
366 | 365 | QAbstractSeriesPrivate(q), |
|
367 | 366 | m_barWidth(0.5), // Default value is 50% of category width |
|
368 | 367 | m_labelsVisible(false), |
|
369 | 368 | m_visible(true) |
|
370 | 369 | { |
|
371 | 370 | } |
|
372 | 371 | |
|
373 | 372 | int QAbstractBarSeriesPrivate::categoryCount() const |
|
374 | 373 | { |
|
375 | 374 | // No categories defined. return count of longest set. |
|
376 | 375 | int count = 0; |
|
377 | 376 | for (int i=0; i<m_barSets.count(); i++) { |
|
378 | 377 | if (m_barSets.at(i)->count() > count) { |
|
379 | 378 | count = m_barSets.at(i)->count(); |
|
380 | 379 | } |
|
381 | 380 | } |
|
382 | 381 | |
|
383 | 382 | return count; |
|
384 | 383 | } |
|
385 | 384 | |
|
386 | 385 | void QAbstractBarSeriesPrivate::setBarWidth(qreal width) |
|
387 | 386 | { |
|
388 | 387 | if (width < 0.0) { |
|
389 | 388 | width = 0.0; |
|
390 | 389 | } |
|
391 | 390 | m_barWidth = width; |
|
392 | 391 | emit updatedBars(); |
|
393 | 392 | } |
|
394 | 393 | |
|
395 | 394 | qreal QAbstractBarSeriesPrivate::barWidth() const |
|
396 | 395 | { |
|
397 | 396 | return m_barWidth; |
|
398 | 397 | } |
|
399 | 398 | |
|
400 | 399 | QBarSet* QAbstractBarSeriesPrivate::barsetAt(int index) |
|
401 | 400 | { |
|
402 | 401 | return m_barSets.at(index); |
|
403 | 402 | } |
|
404 | 403 | |
|
405 | 404 | void QAbstractBarSeriesPrivate::setVisible(bool visible) |
|
406 | 405 | { |
|
407 | 406 | m_visible = visible; |
|
408 | 407 | emit updatedBars(); |
|
409 | 408 | } |
|
410 | 409 | |
|
411 | 410 | void QAbstractBarSeriesPrivate::setLabelsVisible(bool visible) |
|
412 | 411 | { |
|
413 | 412 | m_labelsVisible = visible; |
|
414 | 413 | emit labelsVisibleChanged(visible); |
|
415 | 414 | } |
|
416 | 415 | |
|
417 | 416 | qreal QAbstractBarSeriesPrivate::min() |
|
418 | 417 | { |
|
419 | 418 | if (m_barSets.count() <= 0) { |
|
420 | 419 | return 0; |
|
421 | 420 | } |
|
422 | 421 | qreal min = INT_MAX; |
|
423 | 422 | |
|
424 | 423 | for (int i = 0; i < m_barSets.count(); i++) { |
|
425 | 424 | int categoryCount = m_barSets.at(i)->count(); |
|
426 | 425 | for (int j = 0; j < categoryCount; j++) { |
|
427 | 426 | qreal temp = m_barSets.at(i)->at(j); |
|
428 | 427 | if (temp < min) |
|
429 | 428 | min = temp; |
|
430 | 429 | } |
|
431 | 430 | } |
|
432 | 431 | return min; |
|
433 | 432 | } |
|
434 | 433 | |
|
435 | 434 | qreal QAbstractBarSeriesPrivate::max() |
|
436 | 435 | { |
|
437 | 436 | if (m_barSets.count() <= 0) { |
|
438 | 437 | return 0; |
|
439 | 438 | } |
|
440 | 439 | qreal max = INT_MIN; |
|
441 | 440 | |
|
442 | 441 | for (int i = 0; i < m_barSets.count(); i++) { |
|
443 | 442 | int categoryCount = m_barSets.at(i)->count(); |
|
444 | 443 | for (int j = 0; j < categoryCount; j++) { |
|
445 | 444 | qreal temp = m_barSets.at(i)->at(j); |
|
446 | 445 | if (temp > max) |
|
447 | 446 | max = temp; |
|
448 | 447 | } |
|
449 | 448 | } |
|
450 | 449 | |
|
451 | 450 | return max; |
|
452 | 451 | } |
|
453 | 452 | |
|
454 | 453 | qreal QAbstractBarSeriesPrivate::valueAt(int set, int category) |
|
455 | 454 | { |
|
456 | 455 | if ((set < 0) || (set >= m_barSets.count())) { |
|
457 | 456 | // No set, no value. |
|
458 | 457 | return 0; |
|
459 | 458 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
460 | 459 | // No category, no value. |
|
461 | 460 | return 0; |
|
462 | 461 | } |
|
463 | 462 | |
|
464 | 463 | return m_barSets.at(set)->at(category); |
|
465 | 464 | } |
|
466 | 465 | |
|
467 | 466 | qreal QAbstractBarSeriesPrivate::percentageAt(int set, int category) |
|
468 | 467 | { |
|
469 | 468 | if ((set < 0) || (set >= m_barSets.count())) { |
|
470 | 469 | // No set, no value. |
|
471 | 470 | return 0; |
|
472 | 471 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
473 | 472 | // No category, no value. |
|
474 | 473 | return 0; |
|
475 | 474 | } |
|
476 | 475 | |
|
477 | 476 | qreal value = m_barSets.at(set)->at(category); |
|
478 | 477 | qreal sum = categorySum(category); |
|
479 | 478 | if ( qFuzzyIsNull(sum) ) { |
|
480 | 479 | return 0; |
|
481 | 480 | } |
|
482 | 481 | |
|
483 | 482 | return value / sum; |
|
484 | 483 | } |
|
485 | 484 | |
|
486 | 485 | qreal QAbstractBarSeriesPrivate::categorySum(int category) |
|
487 | 486 | { |
|
488 | 487 | qreal sum(0); |
|
489 | 488 | int count = m_barSets.count(); // Count sets |
|
490 | 489 | for (int set = 0; set < count; set++) { |
|
491 | 490 | if (category < m_barSets.at(set)->count()) |
|
492 | 491 | sum += m_barSets.at(set)->at(category); |
|
493 | 492 | } |
|
494 | 493 | return sum; |
|
495 | 494 | } |
|
496 | 495 | |
|
497 | 496 | qreal QAbstractBarSeriesPrivate::absoluteCategorySum(int category) |
|
498 | 497 | { |
|
499 | 498 | qreal sum(0); |
|
500 | 499 | int count = m_barSets.count(); // Count sets |
|
501 | 500 | for (int set = 0; set < count; set++) { |
|
502 | 501 | if (category < m_barSets.at(set)->count()) |
|
503 | 502 | sum += qAbs(m_barSets.at(set)->at(category)); |
|
504 | 503 | } |
|
505 | 504 | return sum; |
|
506 | 505 | } |
|
507 | 506 | |
|
508 | 507 | qreal QAbstractBarSeriesPrivate::maxCategorySum() |
|
509 | 508 | { |
|
510 | 509 | qreal max = INT_MIN; |
|
511 | 510 | int count = categoryCount(); |
|
512 | 511 | for (int i = 0; i < count; i++) { |
|
513 | 512 | qreal sum = categorySum(i); |
|
514 | 513 | if (sum > max) |
|
515 | 514 | max = sum; |
|
516 | 515 | } |
|
517 | 516 | return max; |
|
518 | 517 | } |
|
519 | 518 | |
|
520 | 519 | qreal QAbstractBarSeriesPrivate::minX() |
|
521 | 520 | { |
|
522 | 521 | if (m_barSets.count() <= 0) { |
|
523 | 522 | return 0; |
|
524 | 523 | } |
|
525 | 524 | qreal min = INT_MAX; |
|
526 | 525 | |
|
527 | 526 | for (int i = 0; i < m_barSets.count(); i++) { |
|
528 | 527 | int categoryCount = m_barSets.at(i)->count(); |
|
529 | 528 | for (int j = 0; j < categoryCount; j++) { |
|
530 | 529 | qreal temp = m_barSets.at(i)->d_ptr.data()->m_values.at(j).x(); |
|
531 | 530 | if (temp < min) |
|
532 | 531 | min = temp; |
|
533 | 532 | } |
|
534 | 533 | } |
|
535 | 534 | return min; |
|
536 | 535 | } |
|
537 | 536 | |
|
538 | 537 | qreal QAbstractBarSeriesPrivate::maxX() |
|
539 | 538 | { |
|
540 | 539 | if (m_barSets.count() <= 0) { |
|
541 | 540 | return 0; |
|
542 | 541 | } |
|
543 | 542 | qreal max = INT_MIN; |
|
544 | 543 | |
|
545 | 544 | for (int i = 0; i < m_barSets.count(); i++) { |
|
546 | 545 | int categoryCount = m_barSets.at(i)->count(); |
|
547 | 546 | for (int j = 0; j < categoryCount; j++) { |
|
548 | 547 | qreal temp = m_barSets.at(i)->d_ptr.data()->m_values.at(j).x(); |
|
549 | 548 | if (temp > max) |
|
550 | 549 | max = temp; |
|
551 | 550 | } |
|
552 | 551 | } |
|
553 | 552 | |
|
554 | 553 | return max; |
|
555 | 554 | } |
|
556 | 555 | |
|
557 | 556 | |
|
558 | 557 | void QAbstractBarSeriesPrivate::scaleDomain(Domain& domain) |
|
559 | 558 | { |
|
560 | 559 | qreal minX(domain.minX()); |
|
561 | 560 | qreal minY(domain.minY()); |
|
562 | 561 | qreal maxX(domain.maxX()); |
|
563 | 562 | qreal maxY(domain.maxY()); |
|
564 | 563 | |
|
565 | 564 | qreal seriesMinX = this->minX(); |
|
566 | 565 | qreal seriesMaxX = this->maxX(); |
|
567 | 566 | qreal y = max(); |
|
568 | 567 | minX = qMin(minX, seriesMinX - (qreal)0.5); |
|
569 | 568 | minY = qMin(minY, y); |
|
570 | 569 | maxX = qMax(maxX, seriesMaxX + (qreal)0.5); |
|
571 | 570 | maxY = qMax(maxY, y); |
|
572 | 571 | |
|
573 | 572 | domain.setRange(minX,maxX,minY,maxY); |
|
574 | 573 | } |
|
575 | 574 | |
|
576 | 575 | Chart* QAbstractBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
577 | 576 | { |
|
578 | 577 | Q_UNUSED(presenter); |
|
579 | 578 | qWarning() << "QAbstractBarSeriesPrivate::createGraphics called"; |
|
580 | 579 | return 0; |
|
581 | 580 | } |
|
582 | 581 | |
|
583 | 582 | QList<LegendMarker*> QAbstractBarSeriesPrivate::createLegendMarker(QLegend* legend) |
|
584 | 583 | { |
|
585 | 584 | Q_Q(QAbstractBarSeries); |
|
586 | 585 | QList<LegendMarker*> markers; |
|
587 | 586 | foreach(QBarSet* set, q->barSets()) { |
|
588 | 587 | BarLegendMarker* marker = new BarLegendMarker(q,set,legend); |
|
589 | 588 | markers << marker; |
|
590 | 589 | } |
|
591 | 590 | |
|
592 | 591 | return markers; |
|
593 | 592 | } |
|
594 | 593 | |
|
595 | 594 | bool QAbstractBarSeriesPrivate::append(QBarSet *set) |
|
596 | 595 | { |
|
597 | 596 | Q_Q(QAbstractBarSeries); |
|
598 | 597 | if ((m_barSets.contains(set)) || (set == 0)) { |
|
599 | 598 | // Fail if set is already in list or set is null. |
|
600 | 599 | return false; |
|
601 | 600 | } |
|
602 | 601 | m_barSets.append(set); |
|
603 | 602 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
604 | 603 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
605 | 604 | emit restructuredBars(); // this notifies barchartitem |
|
606 | 605 | if (m_dataset) { |
|
607 | 606 | m_dataset->updateSeries(q); // this notifies legend |
|
608 | 607 | } |
|
609 | 608 | return true; |
|
610 | 609 | } |
|
611 | 610 | |
|
612 | 611 | bool QAbstractBarSeriesPrivate::remove(QBarSet *set) |
|
613 | 612 | { |
|
614 | 613 | Q_Q(QAbstractBarSeries); |
|
615 | 614 | if (!m_barSets.contains(set)) { |
|
616 | 615 | // Fail if set is not in list |
|
617 | 616 | return false; |
|
618 | 617 | } |
|
619 | 618 | m_barSets.removeOne(set); |
|
620 | 619 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
621 | 620 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
622 | 621 | emit restructuredBars(); // this notifies barchartitem |
|
623 | 622 | if (m_dataset) { |
|
624 | 623 | m_dataset->updateSeries(q); // this notifies legend |
|
625 | 624 | } |
|
626 | 625 | return true; |
|
627 | 626 | } |
|
628 | 627 | |
|
629 | 628 | bool QAbstractBarSeriesPrivate::append(QList<QBarSet* > sets) |
|
630 | 629 | { |
|
631 | 630 | Q_Q(QAbstractBarSeries); |
|
632 | 631 | foreach (QBarSet* set, sets) { |
|
633 | 632 | if ((set == 0) || (m_barSets.contains(set))) { |
|
634 | 633 | // Fail if any of the sets is null or is already appended. |
|
635 | 634 | return false; |
|
636 | 635 | } |
|
637 | 636 | if (sets.count(set) != 1) { |
|
638 | 637 | // Also fail if same set is more than once in given list. |
|
639 | 638 | return false; |
|
640 | 639 | } |
|
641 | 640 | } |
|
642 | 641 | |
|
643 | 642 | foreach (QBarSet* set, sets) { |
|
644 | 643 | m_barSets.append(set); |
|
645 | 644 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
646 | 645 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
647 | 646 | } |
|
648 | 647 | emit restructuredBars(); // this notifies barchartitem |
|
649 | 648 | if (m_dataset) { |
|
650 | 649 | m_dataset->updateSeries(q); // this notifies legend |
|
651 | 650 | } |
|
652 | 651 | return true; |
|
653 | 652 | } |
|
654 | 653 | |
|
655 | 654 | bool QAbstractBarSeriesPrivate::remove(QList<QBarSet* > sets) |
|
656 | 655 | { |
|
657 | 656 | Q_Q(QAbstractBarSeries); |
|
658 | 657 | if (sets.count() == 0) { |
|
659 | 658 | return false; |
|
660 | 659 | } |
|
661 | 660 | foreach (QBarSet* set, sets) { |
|
662 | 661 | if ((set == 0) || (!m_barSets.contains(set))) { |
|
663 | 662 | // Fail if any of the sets is null or is not in series |
|
664 | 663 | return false; |
|
665 | 664 | } |
|
666 | 665 | if (sets.count(set) != 1) { |
|
667 | 666 | // Also fail if same set is more than once in given list. |
|
668 | 667 | return false; |
|
669 | 668 | } |
|
670 | 669 | } |
|
671 | 670 | |
|
672 | 671 | foreach (QBarSet* set, sets) { |
|
673 | 672 | m_barSets.removeOne(set); |
|
674 | 673 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
675 | 674 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
676 | 675 | } |
|
677 | 676 | |
|
678 | 677 | emit restructuredBars(); // this notifies barchartitem |
|
679 | 678 | if (m_dataset) { |
|
680 | 679 | m_dataset->updateSeries(q); // this notifies legend |
|
681 | 680 | } |
|
682 | 681 | return true; |
|
683 | 682 | } |
|
684 | 683 | |
|
685 | 684 | bool QAbstractBarSeriesPrivate::insert(int index, QBarSet *set) |
|
686 | 685 | { |
|
687 | 686 | Q_Q(QAbstractBarSeries); |
|
688 | 687 | if ((m_barSets.contains(set)) || (set == 0)) { |
|
689 | 688 | // Fail if set is already in list or set is null. |
|
690 | 689 | return false; |
|
691 | 690 | } |
|
692 | 691 | m_barSets.insert(index, set); |
|
693 | 692 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
694 | 693 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
695 | 694 | emit restructuredBars(); // this notifies barchartitem |
|
696 | 695 | if (m_dataset) { |
|
697 | 696 | m_dataset->updateSeries(q); // this notifies legend |
|
698 | 697 | } |
|
699 | 698 | return true; |
|
700 | 699 | } |
|
701 | 700 | |
|
702 | 701 | void QAbstractBarSeriesPrivate::initializeAxis(QAbstractAxis* axis) |
|
703 | 702 | { |
|
704 | if(axis->type()==QAbstractAxis::AxisTypeCategories && axis->orientation()==Qt::Horizontal) | |
|
705 | { | |
|
706 | QBarCategoriesAxis* cataxis = qobject_cast<QBarCategoriesAxis*>(axis); | |
|
707 | Q_ASSERT(cataxis); | |
|
708 | QStringList categories; | |
|
709 | if(cataxis->categories().isEmpty()){ | |
|
710 | for (int i(1); i < categoryCount()+1; i++) | |
|
711 | categories << QString::number(i); | |
|
712 | cataxis->append(categories); | |
|
703 | Q_Q(QAbstractBarSeries); | |
|
704 | ||
|
705 | if(axis->type()==QAbstractAxis::AxisTypeCategories) { | |
|
706 | ||
|
707 | switch(q->type()) { | |
|
708 | ||
|
709 | case QAbstractSeries::SeriesTypeHorizontalBar: | |
|
710 | case QAbstractSeries::SeriesTypeHorizontalPercentBar: | |
|
711 | case QAbstractSeries::SeriesTypeHorizontalStackedBar: { | |
|
712 | ||
|
713 | if(axis->orientation()==Qt::Vertical) | |
|
714 | { | |
|
715 | populateCategories(qobject_cast<QBarCategoriesAxis*>(axis)); | |
|
716 | } | |
|
717 | break; | |
|
718 | } | |
|
719 | case QAbstractSeries::SeriesTypeBar: | |
|
720 | case QAbstractSeries::SeriesTypePercentBar: | |
|
721 | case QAbstractSeries::SeriesTypeStackedBar: { | |
|
722 | ||
|
723 | if(axis->orientation()==Qt::Horizontal) | |
|
724 | { | |
|
725 | populateCategories(qobject_cast<QBarCategoriesAxis*>(axis)); | |
|
726 | } | |
|
727 | break; | |
|
728 | } | |
|
729 | default: | |
|
730 | qWarning()<<"Unexpected series type"; | |
|
731 | break; | |
|
732 | ||
|
713 | 733 | } |
|
714 | 734 | } |
|
715 | 735 | } |
|
716 | 736 | |
|
717 | 737 | QAbstractAxis::AxisType QAbstractBarSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const |
|
718 | 738 | { |
|
719 | Q_UNUSED(orientation); | |
|
720 | return QAbstractAxis::AxisTypeNoAxis; | |
|
739 | Q_Q(const QAbstractBarSeries); | |
|
740 | ||
|
741 | switch(q->type()) { | |
|
742 | ||
|
743 | case QAbstractSeries::SeriesTypeHorizontalBar: | |
|
744 | case QAbstractSeries::SeriesTypeHorizontalPercentBar: | |
|
745 | case QAbstractSeries::SeriesTypeHorizontalStackedBar: { | |
|
746 | ||
|
747 | if(orientation==Qt::Vertical) | |
|
748 | { | |
|
749 | return QAbstractAxis::AxisTypeCategories; | |
|
750 | } | |
|
751 | break; | |
|
752 | } | |
|
753 | case QAbstractSeries::SeriesTypeBar: | |
|
754 | case QAbstractSeries::SeriesTypePercentBar: | |
|
755 | case QAbstractSeries::SeriesTypeStackedBar: { | |
|
756 | ||
|
757 | if(orientation==Qt::Horizontal) | |
|
758 | { | |
|
759 | return QAbstractAxis::AxisTypeCategories; | |
|
760 | } | |
|
761 | break; | |
|
762 | } | |
|
763 | default: | |
|
764 | qWarning()<<"Unexpected series type"; | |
|
765 | break; | |
|
766 | ||
|
767 | } | |
|
768 | return QAbstractAxis::AxisTypeValues; | |
|
769 | ||
|
721 | 770 | } |
|
722 | 771 | |
|
772 | void QAbstractBarSeriesPrivate::populateCategories(QBarCategoriesAxis* axis) | |
|
773 | { | |
|
774 | QStringList categories; | |
|
775 | if(axis->categories().isEmpty()) { | |
|
776 | for (int i(1); i < categoryCount()+1; i++) | |
|
777 | categories << QString::number(i); | |
|
778 | axis->append(categories); | |
|
779 | } | |
|
780 | } | |
|
723 | 781 | |
|
724 | 782 | #include "moc_qabstractbarseries.cpp" |
|
725 | 783 | #include "moc_qabstractbarseries_p.cpp" |
|
726 | 784 | |
|
727 | 785 | |
|
728 | 786 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,85 +1,86 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #ifndef ABSTRACTBARSERIES_H |
|
22 | 22 | #define ABSTRACTBARSERIES_H |
|
23 | 23 | |
|
24 | 24 | #include <qabstractseries.h> |
|
25 | 25 | #include <QStringList> |
|
26 | 26 | |
|
27 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 | 29 | class QBarSet; |
|
30 | 30 | class QAbstractBarSeriesPrivate; |
|
31 | 31 | |
|
32 | 32 | // Container for series |
|
33 | 33 | class QTCOMMERCIALCHART_EXPORT QAbstractBarSeries : public QAbstractSeries |
|
34 | 34 | { |
|
35 | 35 | Q_OBJECT |
|
36 | 36 | Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth) |
|
37 | 37 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
38 | 38 | Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
|
39 | 39 | |
|
40 | 40 | protected: |
|
41 | //TODO DEPRECIATED | |
|
41 | 42 | explicit QAbstractBarSeries(QObject *parent = 0); |
|
42 | 43 | |
|
43 | 44 | public: |
|
44 | 45 | virtual ~QAbstractBarSeries(); |
|
45 | 46 | |
|
46 | 47 | void setBarWidth(qreal width); |
|
47 | 48 | qreal barWidth() const; |
|
48 | 49 | |
|
49 | 50 | bool append(QBarSet *set); |
|
50 | 51 | bool remove(QBarSet *set); |
|
51 | 52 | bool append(QList<QBarSet* > sets); |
|
52 | 53 | bool insert(int index, QBarSet *set); |
|
53 | 54 | int count() const; |
|
54 | 55 | QList<QBarSet*> barSets() const; |
|
55 | 56 | void clear(); |
|
56 | 57 | |
|
57 | 58 | void setLabelsVisible(bool visible = true); |
|
58 | 59 | bool isLabelsVisible() const; |
|
59 | 60 | |
|
60 | 61 | protected: |
|
61 | 62 | explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d,QObject *parent = 0); |
|
62 | 63 | |
|
63 | 64 | Q_SIGNALS: |
|
64 | 65 | void clicked(int index, QBarSet *barset); |
|
65 | 66 | void hovered(bool status, QBarSet *barset); |
|
66 | 67 | void countChanged(); |
|
67 | 68 | void labelsVisibleChanged(); |
|
68 | 69 | |
|
69 | 70 | void barsetsAdded(QList<QBarSet*> sets); |
|
70 | 71 | void barsetsRemoved(QList<QBarSet*> sets); |
|
71 | 72 | |
|
72 | 73 | protected: |
|
73 | 74 | Q_DECLARE_PRIVATE(QAbstractBarSeries) |
|
74 | 75 | friend class AbstractBarChartItem; |
|
75 | 76 | friend class PercentBarChartItem; |
|
76 | 77 | friend class StackedBarChartItem; |
|
77 | 78 | friend class BarChartItem; |
|
78 | 79 | friend class HorizontalBarChartItem; |
|
79 | 80 | friend class HorizontalStackedBarChartItem; |
|
80 | 81 | friend class HorizontalPercentBarChartItem; |
|
81 | 82 | }; |
|
82 | 83 | |
|
83 | 84 | QTCOMMERCIALCHART_END_NAMESPACE |
|
84 | 85 | |
|
85 | 86 | #endif // ABSTRACTBARSERIES_H |
@@ -1,97 +1,101 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef QABSTRACTBARSERIES_P_H |
|
31 | 31 | #define QABSTRACTBARSERIES_P_H |
|
32 | 32 | |
|
33 | 33 | #include "qabstractbarseries.h" |
|
34 | 34 | #include "qabstractseries_p.h" |
|
35 | 35 | #include <QStringList> |
|
36 | 36 | #include <QAbstractSeries> |
|
37 | 37 | |
|
38 | 38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
39 | 39 | |
|
40 | 40 | class QBarModelMapper; |
|
41 | class QBarCategoriesAxis; | |
|
41 | 42 | |
|
42 | 43 | class QAbstractBarSeriesPrivate : public QAbstractSeriesPrivate |
|
43 | 44 | { |
|
44 | 45 | Q_OBJECT |
|
45 | 46 | public: |
|
46 | 47 | QAbstractBarSeriesPrivate(QAbstractBarSeries *parent); |
|
47 | 48 | int categoryCount() const; |
|
48 | 49 | |
|
49 | 50 | void setBarWidth(qreal width); |
|
50 | 51 | qreal barWidth() const; |
|
51 | 52 | |
|
52 | 53 | void setVisible(bool visible); |
|
53 | 54 | void setLabelsVisible(bool visible); |
|
54 | 55 | |
|
55 | 56 | void scaleDomain(Domain& domain); |
|
56 | 57 | Chart* createGraphics(ChartPresenter* presenter); |
|
57 | 58 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
58 | 59 | |
|
59 | 60 | void initializeAxis(QAbstractAxis* axis); |
|
60 | 61 | QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const; |
|
61 | 62 | |
|
62 | 63 | bool append(QBarSet *set); |
|
63 | 64 | bool remove(QBarSet *set); |
|
64 | 65 | bool append(QList<QBarSet* > sets); |
|
65 | 66 | bool remove(QList<QBarSet* > sets); |
|
66 | 67 | bool insert(int index, QBarSet *set); |
|
67 | 68 | |
|
68 | 69 | QBarSet* barsetAt(int index); |
|
69 | 70 | qreal min(); |
|
70 | 71 | qreal max(); |
|
71 | 72 | qreal valueAt(int set, int category); |
|
72 | 73 | qreal percentageAt(int set, int category); |
|
73 | 74 | qreal categorySum(int category); |
|
74 | 75 | qreal absoluteCategorySum(int category); |
|
75 | 76 | qreal maxCategorySum(); |
|
76 | 77 | qreal minX(); |
|
77 | 78 | qreal maxX(); |
|
78 | 79 | |
|
79 | 80 | Q_SIGNALS: |
|
80 | 81 | void clicked(int index, QBarSet *barset); |
|
81 | 82 | void updatedBars(); |
|
82 | 83 | void restructuredBars(); |
|
83 | 84 | void labelsVisibleChanged(bool visible); |
|
84 | 85 | |
|
86 | private: | |
|
87 | void populateCategories(QBarCategoriesAxis* axis); | |
|
88 | ||
|
85 | 89 | protected: |
|
86 | 90 | QList<QBarSet *> m_barSets; |
|
87 | 91 | qreal m_barWidth; |
|
88 | 92 | bool m_labelsVisible; |
|
89 | 93 | bool m_visible; |
|
90 | 94 | |
|
91 | 95 | private: |
|
92 | 96 | Q_DECLARE_PUBLIC(QAbstractBarSeries) |
|
93 | 97 | }; |
|
94 | 98 | |
|
95 | 99 | QTCOMMERCIALCHART_END_NAMESPACE |
|
96 | 100 | |
|
97 | 101 | #endif // QABSTRACTBARSERIES_P_H |
|
1 | NO CONTENT: file renamed from src/barchart/barchartitem.cpp to src/barchart/vertical/bar/barchartitem.cpp |
|
1 | NO CONTENT: file renamed from src/barchart/barchartitem_p.h to src/barchart/vertical/bar/barchartitem_p.h |
@@ -1,124 +1,117 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qbarseries.h" |
|
22 | 22 | #include "qbarseries_p.h" |
|
23 | 23 | #include "barchartitem_p.h" |
|
24 | 24 | #include "chartdataset_p.h" |
|
25 | 25 | #include "charttheme_p.h" |
|
26 | 26 | #include "chartanimator_p.h" |
|
27 | 27 | #include "baranimation_p.h" |
|
28 | 28 | #include "qvaluesaxis.h" |
|
29 | #include "qbarcategoriesaxis.h" | |
|
29 | 30 | |
|
30 | 31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | 32 | |
|
32 | 33 | /*! |
|
33 | 34 | \class QBarSeries |
|
34 | 35 | \brief Series for creating bar chart |
|
35 | 36 | \mainclass |
|
36 | 37 | |
|
37 | 38 | QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars |
|
38 | 39 | as groups, where bars in same category are grouped next to each other. QBarSeries groups the data |
|
39 | 40 | from sets to categories, which are defined by a QStringList. |
|
40 | 41 | |
|
41 | 42 | See the \l {BarChart Example} {bar chart example} to learn how to create a grouped bar chart. |
|
42 | 43 | \image examples_barchart.png |
|
43 | 44 | |
|
44 | 45 | \sa QBarSet, QPercentBarSeries, QAbstractBarSeries, QStackedBarSeries |
|
45 | 46 | */ |
|
46 | 47 | /*! |
|
47 | 48 | \qmlclass BarSeries QBarSeries |
|
48 | 49 | \inherits AbstractBarSeries |
|
49 | 50 | |
|
50 | 51 | The following QML shows how to create a simple grouped bar chart: |
|
51 | 52 | \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1 |
|
52 | 53 | \beginfloatleft |
|
53 | 54 | \image demos_qmlchart6.png |
|
54 | 55 | \endfloat |
|
55 | 56 | \clearfloat |
|
56 | 57 | */ |
|
57 | 58 | |
|
58 | 59 | /*! |
|
59 | 60 | Constructs empty QBarSeries. |
|
60 | 61 | QBarSeries is QObject which is a child of a \a parent. |
|
61 | 62 | */ |
|
62 | 63 | QBarSeries::QBarSeries(QObject *parent) |
|
63 | 64 | : QAbstractBarSeries(*new QBarSeriesPrivate(this), parent) |
|
64 | 65 | { |
|
65 | 66 | } |
|
66 | 67 | |
|
67 | 68 | /*! |
|
68 | 69 | Returns QChartSeries::SeriesTypeBar. |
|
69 | 70 | */ |
|
70 | 71 | QAbstractSeries::SeriesType QBarSeries::type() const |
|
71 | 72 | { |
|
72 | 73 | return QAbstractSeries::SeriesTypeBar; |
|
73 | 74 | } |
|
74 | 75 | |
|
75 | 76 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
76 | 77 | |
|
77 | 78 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : QAbstractBarSeriesPrivate(q) |
|
78 | 79 | { |
|
79 | 80 | |
|
80 | 81 | } |
|
81 | 82 | |
|
82 | 83 | void QBarSeriesPrivate::scaleDomain(Domain& domain) |
|
83 | 84 | { |
|
84 | 85 | qreal minX(domain.minX()); |
|
85 | 86 | qreal minY(domain.minY()); |
|
86 | 87 | qreal maxX(domain.maxX()); |
|
87 | 88 | qreal maxY(domain.maxY()); |
|
88 | 89 | |
|
89 | 90 | qreal x = categoryCount(); |
|
90 | 91 | qreal y = max(); |
|
91 | 92 | minX = qMin(minX, - (qreal)0.5); |
|
92 | 93 | minY = qMin(minY, y); |
|
93 | 94 | maxX = qMax(maxX, x - (qreal)0.5); |
|
94 | 95 | maxY = qMax(maxY, y); |
|
95 | 96 | |
|
96 | 97 | domain.setRange(minX,maxX,minY,maxY); |
|
97 | 98 | } |
|
98 | 99 | |
|
99 | 100 | |
|
100 | 101 | Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
101 | 102 | { |
|
102 | 103 | Q_Q(QBarSeries); |
|
103 | 104 | |
|
104 | 105 | BarChartItem* bar = new BarChartItem(q,presenter); |
|
105 | 106 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
106 | 107 | bar->setAnimator(presenter->animator()); |
|
107 | 108 | bar->setAnimation(new BarAnimation(bar)); |
|
108 | 109 | } |
|
109 | 110 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
110 | 111 | return bar; |
|
111 | 112 | } |
|
112 | 113 | |
|
113 | QAbstractAxis::AxisType QBarSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
|
114 | { | |
|
115 | if(orientation==Qt::Horizontal) | |
|
116 | return QAbstractAxis::AxisTypeCategories; | |
|
117 | else | |
|
118 | return QAbstractAxis::AxisTypeValues; | |
|
119 | } | |
|
120 | ||
|
121 | 114 | #include "moc_qbarseries.cpp" |
|
122 | 115 | |
|
123 | 116 | QTCOMMERCIALCHART_END_NAMESPACE |
|
124 | 117 |
|
1 | NO CONTENT: file renamed from src/barchart/qbarseries.h to src/barchart/vertical/bar/qbarseries.h |
@@ -1,55 +1,51 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef QBARSERIES_P_H |
|
31 | 31 | #define QBARSERIES_P_H |
|
32 | 32 | |
|
33 | 33 | #include "qabstractbarseries_p.h" |
|
34 | 34 | #include "domain_p.h" |
|
35 | 35 | |
|
36 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | 37 | |
|
38 | 38 | |
|
39 | 39 | class QBarSeriesPrivate: public QAbstractBarSeriesPrivate |
|
40 | 40 | { |
|
41 | 41 | public: |
|
42 | 42 | QBarSeriesPrivate(QBarSeries* q); |
|
43 | 43 | Chart* createGraphics(ChartPresenter* presenter); |
|
44 | 44 | void scaleDomain(Domain& domain); |
|
45 | ||
|
46 | QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const; | |
|
47 | ||
|
48 | ||
|
49 | 45 | private: |
|
50 | 46 | Q_DECLARE_PUBLIC(QBarSeries) |
|
51 | 47 | }; |
|
52 | 48 | |
|
53 | 49 | QTCOMMERCIALCHART_END_NAMESPACE |
|
54 | 50 | |
|
55 | 51 | #endif // QBARSERIES_P_H |
|
1 | NO CONTENT: file renamed from src/barchart/percentbarchartitem.cpp to src/barchart/vertical/percent/percentbarchartitem.cpp |
|
1 | NO CONTENT: file renamed from src/barchart/percentbarchartitem_p.h to src/barchart/vertical/percent/percentbarchartitem_p.h |
@@ -1,124 +1,115 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qpercentbarseries.h" |
|
22 | 22 | #include "qpercentbarseries_p.h" |
|
23 | 23 | #include "percentbarchartitem_p.h" |
|
24 | 24 | #include "chartdataset_p.h" |
|
25 | 25 | #include "charttheme_p.h" |
|
26 | 26 | #include "chartanimator_p.h" |
|
27 | 27 | #include "qvaluesaxis.h" |
|
28 | 28 | #include "percentbaranimation_p.h" |
|
29 | 29 | |
|
30 | 30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | 31 | |
|
32 | 32 | /*! |
|
33 | 33 | \class QPercentBarSeries |
|
34 | 34 | \brief Series for creating percent bar chart |
|
35 | 35 | \mainclass |
|
36 | 36 | |
|
37 | 37 | QPercentBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars |
|
38 | 38 | as stacks, where each bar is shown as percentage of all bars in that category. |
|
39 | 39 | QPercentBarSeries groups the data from sets to categories, which are defined by a QStringList. |
|
40 | 40 | |
|
41 | 41 | See the \l {PercentbarChart Example} {percent bar chart example} to learn how to create a percent bar chart. |
|
42 | 42 | \image examples_percentbarchart.png |
|
43 | 43 | |
|
44 | 44 | \sa QBarSet, QStackedBarSeries, QAbstractBarSeries |
|
45 | 45 | */ |
|
46 | 46 | /*! |
|
47 | 47 | \qmlclass PercentBarSeries QPercentBarSeries |
|
48 | 48 | \inherits QAbstractBarSeries |
|
49 | 49 | |
|
50 | 50 | The following QML shows how to create a simple percent bar chart: |
|
51 | 51 | \snippet ../demos/qmlchart/qml/qmlchart/View8.qml 1 |
|
52 | 52 | \beginfloatleft |
|
53 | 53 | \image demos_qmlchart8.png |
|
54 | 54 | \endfloat |
|
55 | 55 | \clearfloat |
|
56 | 56 | */ |
|
57 | 57 | |
|
58 | 58 | /*! |
|
59 | 59 | Constructs empty QPercentBarSeries. |
|
60 | 60 | QPercentBarSeries is QObject which is a child of a \a parent. |
|
61 | 61 | */ |
|
62 | 62 | QPercentBarSeries::QPercentBarSeries(QObject *parent) |
|
63 | 63 | : QAbstractBarSeries(*new QPercentBarSeriesPrivate(this), parent) |
|
64 | 64 | { |
|
65 | 65 | } |
|
66 | 66 | |
|
67 | 67 | /*! |
|
68 | 68 | Returns QChartSeries::SeriesTypePercentBar. |
|
69 | 69 | */ |
|
70 | 70 | QAbstractSeries::SeriesType QPercentBarSeries::type() const |
|
71 | 71 | { |
|
72 | 72 | return QAbstractSeries::SeriesTypePercentBar; |
|
73 | 73 | } |
|
74 | 74 | |
|
75 | 75 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
76 | 76 | |
|
77 | 77 | QPercentBarSeriesPrivate::QPercentBarSeriesPrivate(QPercentBarSeries *q) : QAbstractBarSeriesPrivate(q) |
|
78 | 78 | { |
|
79 | 79 | |
|
80 | 80 | } |
|
81 | 81 | |
|
82 | 82 | void QPercentBarSeriesPrivate::scaleDomain(Domain& domain) |
|
83 | 83 | { |
|
84 | 84 | qreal minX(domain.minX()); |
|
85 | 85 | qreal minY(domain.minY()); |
|
86 | 86 | qreal maxX(domain.maxX()); |
|
87 | 87 | qreal maxY(domain.maxY()); |
|
88 | 88 | |
|
89 | 89 | qreal x = categoryCount(); |
|
90 | 90 | minX = qMin(minX, - (qreal)0.5); |
|
91 | 91 | maxX = qMax(maxX, x - (qreal)0.5); |
|
92 | 92 | minY = 0; |
|
93 | 93 | maxY = 100; |
|
94 | 94 | |
|
95 | 95 | domain.setRange(minX,maxX,minY,maxY); |
|
96 | 96 | } |
|
97 | 97 | |
|
98 | 98 | |
|
99 | 99 | Chart* QPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
100 | 100 | { |
|
101 | 101 | Q_Q(QPercentBarSeries); |
|
102 | 102 | |
|
103 | 103 | PercentBarChartItem* bar = new PercentBarChartItem(q,presenter); |
|
104 | 104 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
105 | 105 | bar->setAnimator(presenter->animator()); |
|
106 | 106 | bar->setAnimation(new PercentBarAnimation(bar)); |
|
107 | 107 | } |
|
108 | 108 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
109 | 109 | return bar; |
|
110 | 110 | } |
|
111 | 111 | |
|
112 | QAbstractAxis::AxisType QPercentBarSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
|
113 | { | |
|
114 | if(orientation==Qt::Horizontal) | |
|
115 | return QAbstractAxis::AxisTypeCategories; | |
|
116 | else | |
|
117 | return QAbstractAxis::AxisTypeValues; | |
|
118 | } | |
|
119 | ||
|
120 | ||
|
121 | 112 | #include "moc_qpercentbarseries.cpp" |
|
122 | 113 | |
|
123 | 114 | QTCOMMERCIALCHART_END_NAMESPACE |
|
124 | 115 |
|
1 | NO CONTENT: file renamed from src/barchart/qpercentbarseries.h to src/barchart/vertical/percent/qpercentbarseries.h |
@@ -1,53 +1,51 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef QPERCENTBARSERIES_P_H |
|
31 | 31 | #define QPERCENTBARSERIES_P_H |
|
32 | 32 | |
|
33 | 33 | #include "qabstractbarseries_p.h" |
|
34 | 34 | #include "domain_p.h" |
|
35 | 35 | |
|
36 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | 37 | |
|
38 | 38 | |
|
39 | 39 | class QPercentBarSeriesPrivate: public QAbstractBarSeriesPrivate |
|
40 | 40 | { |
|
41 | 41 | public: |
|
42 | 42 | QPercentBarSeriesPrivate(QPercentBarSeries* q); |
|
43 | 43 | void scaleDomain(Domain& domain); |
|
44 | 44 | Chart* createGraphics(ChartPresenter* presenter); |
|
45 | QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const; | |
|
46 | ||
|
47 | 45 | private: |
|
48 | 46 | Q_DECLARE_PUBLIC(QPercentBarSeries) |
|
49 | 47 | }; |
|
50 | 48 | |
|
51 | 49 | QTCOMMERCIALCHART_END_NAMESPACE |
|
52 | 50 | |
|
53 | 51 | #endif |
@@ -1,126 +1,117 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qstackedbarseries.h" |
|
22 | 22 | #include "qstackedbarseries_p.h" |
|
23 | 23 | #include "stackedbarchartitem_p.h" |
|
24 | 24 | #include "chartdataset_p.h" |
|
25 | 25 | #include "charttheme_p.h" |
|
26 | 26 | #include "chartanimator_p.h" |
|
27 | 27 | #include "qvaluesaxis.h" |
|
28 | 28 | #include "stackedbaranimation_p.h" |
|
29 | 29 | |
|
30 | 30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | 31 | |
|
32 | 32 | /*! |
|
33 | 33 | \class QStackedBarSeries |
|
34 | 34 | \brief Series for creating stacked bar chart |
|
35 | 35 | \mainclass |
|
36 | 36 | |
|
37 | 37 | QStackedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars |
|
38 | 38 | as stacks, where bars in same category are stacked on top of each other. |
|
39 | 39 | QStackedBarSeries groups the data from sets to categories, which are defined by QStringList. |
|
40 | 40 | |
|
41 | 41 | See the \l {StackedbarChart Example} {stacked bar chart example} to learn how to create a stacked bar chart. |
|
42 | 42 | \image examples_stackedbarchart.png |
|
43 | 43 | |
|
44 | 44 | \sa QBarSet, QPercentBarSeries, QAbstractBarSeries |
|
45 | 45 | */ |
|
46 | 46 | |
|
47 | 47 | /*! |
|
48 | 48 | \qmlclass StackedBarSeries QStackedBarSeries |
|
49 | 49 | \inherits AbstractBarSeries |
|
50 | 50 | |
|
51 | 51 | The following QML shows how to create a simple stacked bar chart: |
|
52 | 52 | \snippet ../demos/qmlchart/qml/qmlchart/View7.qml 1 |
|
53 | 53 | \beginfloatleft |
|
54 | 54 | \image demos_qmlchart7.png |
|
55 | 55 | \endfloat |
|
56 | 56 | \clearfloat |
|
57 | 57 | */ |
|
58 | 58 | |
|
59 | 59 | /*! |
|
60 | 60 | Constructs empty QStackedBarSeries. |
|
61 | 61 | QStackedBarSeries is QObject which is a child of a \a parent. |
|
62 | 62 | */ |
|
63 | 63 | QStackedBarSeries::QStackedBarSeries(QObject *parent) |
|
64 | 64 | : QAbstractBarSeries(*new QStackedBarSeriesPrivate(this), parent) |
|
65 | 65 | { |
|
66 | 66 | } |
|
67 | 67 | |
|
68 | 68 | /*! |
|
69 | 69 | Returns QChartSeries::SeriesTypeStackedBar. |
|
70 | 70 | */ |
|
71 | 71 | QAbstractSeries::SeriesType QStackedBarSeries::type() const |
|
72 | 72 | { |
|
73 | 73 | return QAbstractSeries::SeriesTypeStackedBar; |
|
74 | 74 | } |
|
75 | 75 | |
|
76 | 76 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
77 | 77 | |
|
78 | 78 | QStackedBarSeriesPrivate::QStackedBarSeriesPrivate(QStackedBarSeries *q) : QAbstractBarSeriesPrivate(q) |
|
79 | 79 | { |
|
80 | 80 | |
|
81 | 81 | } |
|
82 | 82 | |
|
83 | 83 | void QStackedBarSeriesPrivate::scaleDomain(Domain& domain) |
|
84 | 84 | { |
|
85 | 85 | qreal minX(domain.minX()); |
|
86 | 86 | qreal minY(domain.minY()); |
|
87 | 87 | qreal maxX(domain.maxX()); |
|
88 | 88 | qreal maxY(domain.maxY()); |
|
89 | 89 | |
|
90 | 90 | qreal x = categoryCount(); |
|
91 | 91 | qreal y = maxCategorySum(); |
|
92 | 92 | minX = qMin(minX, - (qreal)0.5); |
|
93 | 93 | minY = qMin(minY, y); |
|
94 | 94 | maxX = qMax(maxX, x - (qreal)0.5); |
|
95 | 95 | maxY = qMax(maxY, y); |
|
96 | 96 | |
|
97 | 97 | domain.setRange(minX,maxX,minY,maxY); |
|
98 | 98 | } |
|
99 | 99 | |
|
100 | 100 | |
|
101 | 101 | Chart* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
102 | 102 | { |
|
103 | 103 | Q_Q(QStackedBarSeries); |
|
104 | 104 | |
|
105 | 105 | StackedBarChartItem* bar = new StackedBarChartItem(q,presenter); |
|
106 | 106 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
107 | 107 | bar->setAnimator(presenter->animator()); |
|
108 | 108 | bar->setAnimation(new StackedBarAnimation(bar)); |
|
109 | 109 | } |
|
110 | 110 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
111 | 111 | return bar; |
|
112 | 112 | } |
|
113 | 113 | |
|
114 | QAbstractAxis::AxisType QStackedBarSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
|
115 | { | |
|
116 | if(orientation==Qt::Horizontal) | |
|
117 | return QAbstractAxis::AxisTypeCategories; | |
|
118 | else | |
|
119 | return QAbstractAxis::AxisTypeValues; | |
|
120 | } | |
|
121 | ||
|
122 | ||
|
123 | 114 | #include "moc_qstackedbarseries.cpp" |
|
124 | 115 | |
|
125 | 116 | QTCOMMERCIALCHART_END_NAMESPACE |
|
126 | 117 |
|
1 | NO CONTENT: file renamed from src/barchart/qstackedbarseries.h to src/barchart/vertical/stacked/qstackedbarseries.h |
@@ -1,53 +1,51 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef QSTACKEDBARSERIES_P_H |
|
31 | 31 | #define QSTACKEDBARSERIES_P_H |
|
32 | 32 | |
|
33 | 33 | #include "qabstractbarseries_p.h" |
|
34 | 34 | #include "domain_p.h" |
|
35 | 35 | |
|
36 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | 37 | |
|
38 | 38 | |
|
39 | 39 | class QStackedBarSeriesPrivate: public QAbstractBarSeriesPrivate |
|
40 | 40 | { |
|
41 | 41 | public: |
|
42 | 42 | QStackedBarSeriesPrivate(QStackedBarSeries* q); |
|
43 | 43 | Chart* createGraphics(ChartPresenter* presenter); |
|
44 | 44 | void scaleDomain(Domain& domain); |
|
45 | QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const; | |
|
46 | ||
|
47 | 45 | private: |
|
48 | 46 | Q_DECLARE_PUBLIC(QStackedBarSeries) |
|
49 | 47 | }; |
|
50 | 48 | |
|
51 | 49 | QTCOMMERCIALCHART_END_NAMESPACE |
|
52 | 50 | |
|
53 | 51 | #endif |
|
1 | NO CONTENT: file renamed from src/barchart/stackedbarchartitem.cpp to src/barchart/vertical/stacked/stackedbarchartitem.cpp |
|
1 | NO CONTENT: file renamed from src/barchart/stackedbarchartitem_p.h to src/barchart/vertical/stacked/stackedbarchartitem_p.h |
General Comments 0
You need to be logged in to leave comments.
Login now