@@ -1,56 +1,65 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | // W A R N I N G | |
|
22 | // ------------- | |
|
23 | // | |
|
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 | |
|
26 | // version without notice, or even be removed. | |
|
27 | // | |
|
28 | // We mean it. | |
|
29 | ||
|
21 | 30 | #ifndef BAR_H |
|
22 | 31 | #define BAR_H |
|
23 | 32 | |
|
24 | 33 | #include "qchartglobal.h" |
|
25 | 34 | #include <QGraphicsRectItem> |
|
26 | 35 | |
|
27 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 37 | |
|
29 | 38 | class QBarSet; |
|
30 | 39 | |
|
31 | 40 | // Single visual bar item of chart |
|
32 | 41 | class Bar : public QObject, public QGraphicsRectItem |
|
33 | 42 | { |
|
34 | 43 | Q_OBJECT |
|
35 | 44 | public: |
|
36 | 45 | Bar(QBarSet *barset, QString category, QGraphicsItem *parent = 0); |
|
37 | 46 | |
|
38 | 47 | public: |
|
39 | 48 | void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
40 | 49 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event); |
|
41 | 50 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); |
|
42 | 51 | |
|
43 | 52 | Q_SIGNALS: |
|
44 | 53 | void clicked(QString category); |
|
45 | 54 | void clicked(QBarSet *barset, QString category); |
|
46 | 55 | void hovered(bool status); |
|
47 | 56 | void hovered(QBarSet *barset, bool status); |
|
48 | 57 | |
|
49 | 58 | private: |
|
50 | 59 | QString m_category; |
|
51 | 60 | QBarSet *m_barset; |
|
52 | 61 | }; |
|
53 | 62 | |
|
54 | 63 | QTCOMMERCIALCHART_END_NAMESPACE |
|
55 | 64 | |
|
56 | 65 | #endif // BAR_H |
@@ -1,83 +1,90 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | // W A R N I N G | |
|
22 | // ------------- | |
|
23 | // | |
|
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 | |
|
26 | // version without notice, or even be removed. | |
|
27 | // | |
|
28 | // We mean it. | |
|
29 | ||
|
30 | ||
|
21 | 31 | #ifndef BARCHARTITEM_H |
|
22 | 32 | #define BARCHARTITEM_H |
|
23 | 33 | |
|
24 | 34 | #include "chartitem_p.h" |
|
25 | 35 | #include "qbarseries.h" |
|
26 | 36 | #include <QPen> |
|
27 | 37 | #include <QBrush> |
|
28 | 38 | |
|
29 | 39 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 40 | |
|
31 | 41 | class Bar; |
|
32 | 42 | class QAxisCategories; |
|
33 | 43 | class QChart; |
|
34 | 44 | |
|
35 | //typedef QVector<QRectF> BarLayout; | |
|
36 | ||
|
37 | 45 | class BarChartItem : public ChartItem |
|
38 | 46 | { |
|
39 | 47 | Q_OBJECT |
|
40 | 48 | public: |
|
41 | 49 | BarChartItem(QBarSeries *series, ChartPresenter *presenter); |
|
42 | 50 | virtual ~BarChartItem(); |
|
43 | 51 | |
|
44 | 52 | public: |
|
45 | // From QGraphicsItem | |
|
46 | 53 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
|
47 | 54 | QRectF boundingRect() const; |
|
48 | 55 | |
|
49 | 56 | virtual void dataChanged(); // data of series has changed -> need to recalculate bar sizes |
|
50 | 57 | |
|
51 | 58 | virtual QVector<QRectF> calculateLayout(); |
|
52 | 59 | void applyLayout(const QVector<QRectF> &layout); |
|
53 | 60 | void setLayout(const QVector<QRectF> &layout); |
|
54 | 61 | void updateLayout(const QVector<QRectF> &layout); |
|
55 | 62 | |
|
56 | 63 | QRectF geometry() const { return m_rect;} |
|
57 | 64 | |
|
58 | 65 | public Q_SLOTS: |
|
59 | 66 | void handleModelChanged(); |
|
60 | 67 | void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY); |
|
61 | 68 | void handleGeometryChanged(const QRectF &size); |
|
62 | 69 | void handleLayoutChanged(); |
|
63 | 70 | void labelsVisibleChanged(bool visible); |
|
64 | 71 | |
|
65 | 72 | protected: |
|
66 | 73 | |
|
67 | 74 | qreal m_domainMinX; |
|
68 | 75 | qreal m_domainMaxX; |
|
69 | 76 | qreal m_domainMinY; |
|
70 | 77 | qreal m_domainMaxY; |
|
71 | 78 | |
|
72 | 79 | QRectF m_rect; |
|
73 | 80 | QVector<QRectF> m_layout; |
|
74 | 81 | |
|
75 | 82 | // Not owned. |
|
76 | 83 | QBarSeries *m_series; |
|
77 | 84 | QList<Bar *> m_bars; |
|
78 | 85 | QList<QGraphicsSimpleTextItem *> m_labels; |
|
79 | 86 | }; |
|
80 | 87 | |
|
81 | 88 | QTCOMMERCIALCHART_END_NAMESPACE |
|
82 | 89 | |
|
83 | 90 | #endif // BARCHARTITEM_H |
@@ -1,47 +1,52 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | // W A R N I N G | |
|
22 | // ------------- | |
|
23 | // | |
|
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 | |
|
26 | // version without notice, or even be removed. | |
|
27 | // | |
|
28 | // We mean it. | |
|
29 | ||
|
30 | ||
|
21 | 31 | #ifndef GROUPEDBARCHARTITEM_H |
|
22 | 32 | #define GROUPEDBARCHARTITEM_H |
|
23 | 33 | |
|
24 | 34 | #include "barchartitem_p.h" |
|
25 | 35 | #include "qstackedbarseries.h" |
|
26 | 36 | #include <QGraphicsItem> |
|
27 | 37 | |
|
28 | 38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 39 | |
|
30 | 40 | class GroupedBarChartItem : public BarChartItem |
|
31 | 41 | { |
|
32 | 42 | Q_OBJECT |
|
33 | 43 | public: |
|
34 | 44 | GroupedBarChartItem(QBarSeries *series, ChartPresenter *presenter); |
|
35 | 45 | |
|
36 | 46 | private: |
|
37 | // From BarChartItem | |
|
38 | 47 | virtual QVector<QRectF> calculateLayout(); |
|
39 | ||
|
40 | private: | |
|
41 | ||
|
42 | // Data | |
|
43 | 48 | }; |
|
44 | 49 | |
|
45 | 50 | QTCOMMERCIALCHART_END_NAMESPACE |
|
46 | 51 | |
|
47 | 52 | #endif // GROUPEDBARCHARTITEM_H |
@@ -1,47 +1,53 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | // W A R N I N G | |
|
22 | // ------------- | |
|
23 | // | |
|
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 | |
|
26 | // version without notice, or even be removed. | |
|
27 | // | |
|
28 | // We mean it. | |
|
29 | ||
|
30 | ||
|
21 | 31 | #ifndef PERCENTBARCHARTITEM_H |
|
22 | 32 | #define PERCENTBARCHARTITEM_H |
|
23 | 33 | |
|
24 | 34 | #include "barchartitem_p.h" |
|
25 | 35 | #include <QGraphicsItem> |
|
26 | 36 | |
|
27 | 37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 38 | |
|
29 | 39 | class QBarSeries; |
|
30 | 40 | |
|
31 | 41 | class PercentBarChartItem : public BarChartItem |
|
32 | 42 | { |
|
33 | 43 | Q_OBJECT |
|
34 | 44 | public: |
|
35 | 45 | PercentBarChartItem(QBarSeries *series, ChartPresenter *presenter); |
|
36 | 46 | |
|
37 | 47 | private: |
|
38 | 48 | virtual QVector<QRectF> calculateLayout(); |
|
39 | ||
|
40 | private: | |
|
41 | ||
|
42 | // Data | |
|
43 | 49 | }; |
|
44 | 50 | |
|
45 | 51 | QTCOMMERCIALCHART_END_NAMESPACE |
|
46 | 52 | |
|
47 | 53 | #endif // PERCENTBARCHARTITEM_H |
@@ -1,64 +1,92 | |||
|
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 | ||
|
21 | // W A R N I N G | |
|
22 | // ------------- | |
|
23 | // | |
|
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 | |
|
26 | // version without notice, or even be removed. | |
|
27 | // | |
|
28 | // We mean it. | |
|
29 | ||
|
1 | 30 | #ifndef QBARSERIES_P_H |
|
2 | 31 | #define QBARSERIES_P_H |
|
3 | 32 | |
|
4 | 33 | #include "qbarseries.h" |
|
5 | 34 | #include "qabstractseries_p.h" |
|
6 | 35 | #include <QStringList> |
|
7 | 36 | #include <QAbstractSeries> |
|
8 | 37 | |
|
9 | 38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | 39 | |
|
11 | 40 | class QBarModelMapper; |
|
12 | 41 | |
|
13 | // Container for series | |
|
14 | 42 | class QBarSeriesPrivate : public QAbstractSeriesPrivate |
|
15 | 43 | { |
|
16 | 44 | Q_OBJECT |
|
17 | 45 | public: |
|
18 | 46 | QBarSeriesPrivate(QBarSeries *parent); |
|
19 | 47 | void setCategories(QBarCategories categories); |
|
20 | 48 | void insertCategory(int index, const QString category); |
|
21 | 49 | void removeCategory(int index); |
|
22 | 50 | int categoryCount() const; |
|
23 | 51 | QBarCategories categories() const; |
|
24 | 52 | |
|
25 | 53 | void setBarMargin(qreal margin); |
|
26 | 54 | qreal barMargin(); |
|
27 | 55 | |
|
28 | 56 | void scaleDomain(Domain& domain); |
|
29 | 57 | Chart* createGraphics(ChartPresenter* presenter); |
|
30 | 58 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
31 | 59 | |
|
32 | 60 | QBarSet* barsetAt(int index); |
|
33 | 61 | QString categoryName(int category); |
|
34 | 62 | qreal min(); |
|
35 | 63 | qreal max(); |
|
36 | 64 | qreal valueAt(int set, int category); |
|
37 | 65 | qreal percentageAt(int set, int category); |
|
38 | 66 | qreal categorySum(int category); |
|
39 | 67 | qreal absoluteCategorySum(int category); |
|
40 | 68 | qreal maxCategorySum(); |
|
41 | 69 | |
|
42 | 70 | Q_SIGNALS: |
|
43 | 71 | void clicked(QBarSet *barset, QString category); |
|
44 | 72 | void updatedBars(); |
|
45 | 73 | void restructuredBars(); |
|
46 | 74 | void categoriesUpdated(); |
|
47 | 75 | void labelsVisibleChanged(bool visible); |
|
48 | 76 | |
|
49 | 77 | private Q_SLOTS: |
|
50 | 78 | void barsetChanged(); |
|
51 | 79 | |
|
52 | 80 | protected: |
|
53 | 81 | QList<QBarSet *> m_barSets; |
|
54 | 82 | QBarCategories m_categories; |
|
55 | 83 | qreal m_barMargin; |
|
56 | 84 | bool m_labelsVisible; |
|
57 | 85 | |
|
58 | 86 | private: |
|
59 | 87 | Q_DECLARE_PUBLIC(QBarSeries) |
|
60 | 88 | }; |
|
61 | 89 | |
|
62 | 90 | QTCOMMERCIALCHART_END_NAMESPACE |
|
63 | 91 | |
|
64 | 92 | #endif // QBARSERIESPRIVATE_P_H |
@@ -1,40 +1,69 | |||
|
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 | ||
|
21 | // W A R N I N G | |
|
22 | // ------------- | |
|
23 | // | |
|
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 | |
|
26 | // version without notice, or even be removed. | |
|
27 | // | |
|
28 | // We mean it. | |
|
29 | ||
|
1 | 30 | #ifndef QBARSET_P_H |
|
2 | 31 | #define QBARSET_P_H |
|
3 | 32 | |
|
4 | 33 | #include "qbarset.h" |
|
5 | 34 | #include <QMap> |
|
6 | 35 | #include <QPen> |
|
7 | 36 | #include <QBrush> |
|
8 | 37 | #include <QFont> |
|
9 | 38 | |
|
10 | 39 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
11 | 40 | |
|
12 | 41 | class QBarSetPrivate : public QObject |
|
13 | 42 | { |
|
14 | 43 | Q_OBJECT |
|
15 | 44 | |
|
16 | 45 | public: |
|
17 | 46 | QBarSetPrivate(const QString name, QBarSet *parent); |
|
18 | 47 | ~QBarSetPrivate(); |
|
19 | 48 | |
|
20 | 49 | Q_SIGNALS: |
|
21 | 50 | void clicked(QString category); |
|
22 | 51 | void restructuredBars(); |
|
23 | 52 | void updatedBars(); |
|
24 | 53 | |
|
25 | 54 | public: |
|
26 | 55 | QBarSet * const q_ptr; |
|
27 | 56 | QString m_name; |
|
28 | 57 | QList<QPointF> m_values; |
|
29 | 58 | QPen m_pen; |
|
30 | 59 | QBrush m_brush; |
|
31 | 60 | QPen m_labelPen; |
|
32 | 61 | QBrush m_labelBrush; |
|
33 | 62 | QFont m_labelFont; |
|
34 | 63 | |
|
35 | 64 | friend class QBarSet; |
|
36 | 65 | }; |
|
37 | 66 | |
|
38 | 67 | QTCOMMERCIALCHART_END_NAMESPACE |
|
39 | 68 | |
|
40 | 69 | #endif // QBARSETPRIVATE_P_H |
@@ -1,47 +1,52 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | // W A R N I N G | |
|
22 | // ------------- | |
|
23 | // | |
|
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 | |
|
26 | // version without notice, or even be removed. | |
|
27 | // | |
|
28 | // We mean it. | |
|
29 | ||
|
30 | ||
|
21 | 31 | #ifndef STACKEDBARCHARTITEM_H |
|
22 | 32 | #define STACKEDBARCHARTITEM_H |
|
23 | 33 | |
|
24 | 34 | #include "barchartitem_p.h" |
|
25 | 35 | #include "qstackedbarseries.h" |
|
26 | 36 | #include <QGraphicsItem> |
|
27 | 37 | |
|
28 | 38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 39 | |
|
30 | 40 | class StackedBarChartItem : public BarChartItem |
|
31 | 41 | { |
|
32 | 42 | Q_OBJECT |
|
33 | 43 | public: |
|
34 | 44 | StackedBarChartItem(QBarSeries *series, ChartPresenter *presenter); |
|
35 | 45 | |
|
36 | 46 | private: |
|
37 | // From BarChartItem | |
|
38 | 47 | virtual QVector<QRectF> calculateLayout(); |
|
39 | ||
|
40 | private: | |
|
41 | ||
|
42 | // Data | |
|
43 | 48 | }; |
|
44 | 49 | |
|
45 | 50 | QTCOMMERCIALCHART_END_NAMESPACE |
|
46 | 51 | |
|
47 | 52 | #endif // STACKEDBARCHARTITEM_H |
General Comments 0
You need to be logged in to leave comments.
Login now