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